How do programmers code so quickly?

Quoting a post on Quora Digest,

  • They know how to use their keyboards to do work. Keyboards are way faster than mouse once you know how to use them. They’re also more amenable to muscle memory. Are you clicking around to open new files? When I’m coding I barely touch my mouse.
  • They know how to use their tools, especially on the command-line. Ctrl+R for reverse search, Ctrl+A/E for beginning/end of lines, for auto-completing filenames, etc. These become muscle memory after a point.
  • They are very good at debugging and are likely to isolate, identify, and resolve a bug 100x quicker than a beginner. This isn’t just because they “know more.” Oftentimes they know just as much as you, but have a more disciplined approach to finding the source of unexpected problems.
  • They have a better sense of where to look for information and aren’t afraid to navigate through manpages or even source code to understand how some other system is behaving. If I’m having trouble with a poorly-documented Ruby gem, for example, I’ll often look at the gem’s source code to see if I can make sense of what’s going wrong. I’d say 90% of the time this is quicker than Google.

More insight in to debugging – Debugging — Experts vs. Novices

Cheers Folks, Happy Coding  🙂

WSO2 Carbon Kernel 4.3.0 Released !!

Featured image

What is WSO2 Carbon ?

WSO2 Carbon redefines middle-ware by providing an integrated and componentized middle-ware platform that adapts to the specific needs of any enterprise IT project – on premise or in the cloud. 100% open source and standards-based, WSO2 Carbon enables developers to rapidly orchestrate business processes, compose applications and develop services using WSO2 Developer Studio and a broad range of business and technical services that integrate with legacy, packaged and SaaS applications.

WSO2 Carbon kernel, the lean, modular, OSGi-based platform, is the base of the WSO2 Carbon platform. It is a composable server architecture which inherits modularity and dynamism from OSGi framework. WSO2 Carbon kernel can be considered as a framework for server development. All the WSO2 products are composed as a collection reusable components running on this kernel. These products/components inherits all the core services provided by Carbon kernel such as Registry/repository, User management, Transports, Caching, Clustering, Logging, Deployment related features.

Key Features

  • Composable Server Architecture – Provides a modular, light-weight, OSGi-based server development framework.
  • Carbon Application(CApp) deployment support.
  • Multi-Profile Support for Carbon Platform – Enables a single product to run on multiple modes/profiles.
  • Carbon + Tomcat JNDI Context – Provides ability to access both carbon level and tomcat level JNDI resources to applications using a single JNDI context.
  • Distributed Caching and Clustering functionality – Provides a distributed cache and clustering implementation which is based on Hazelcast- a group communication framework
  • Pluggable Transports Framework – Based on Axis2 transports module.
  • Registry/Repository API- Provides core registry/repository API for component developers.
  • User Management API – Provides a basic user management API for component developers.
  • Logging – Supports both Java logging as well as Log4j. Logs from both these sources will be aggregated to a single output
  • Pluggable artifact deployer framework – Can be extended to deploy any kind of artifacts such as Web services, Web apps, Business processes, Proxy services, User stores etc.
  • Deployment Synchronization – Provides synchronization of deployed artifacts across a product cluster.
  • Ghost Deployment – Provides a lazy loading mechanism for deployed artifacts
  • Multi-tenancy support – The roots of the multi-tenancy in Carbon platform lies in the Carbon kernel. This feature includes tenant level isolation as well as lazy loading of tenants.

New Features

  • Simplified logging story with pluggable log provider support.
  • Upgraded versions of Hazelcast, Log4j, BouncyCastle.
  • Improved Composite application support.

How to Contribute

  • WSO2 Carbon kernel code is hosted in GitHub.
  • Carbon 4.3.0 release work is carried out in “release-4.3.0” branch of this GitHub project.
  • Please report issues at Carbon JIRA and Send your pull requests to release-4.3.0 branch.

Contact us

WSO2 Carbon developers can be contacted via the mailing lists:

Cheers folks, Happy Coding 🙂

Introducing WSO2 Carbon 5 (C5)

Kishanthan's Blog

Carbon 5 will be the next generation of WSO2 Carbon Platform.

Over the years, the existing carbon platform was used to build different set of products at WSO2 and helped implementing many solutions. The platform has gained maturity over time. This maturity and the experiences acquired over time, helped to identify the areas which can be improved or can be implemented using a better way in carbon platform.

Carbon Kernel is the base framework for all the WSO2 products. The core concepts of kernel such as deployment, clustering, configuration and context model, multi-tenancy, etc are inspired from and developed using the kernel architecture of Apache Axis2. The Apache Axis2 is a web-services engine. But its is also a server framework with the run-time and configuration model, which can be run independently. This was adopted at carbon kernel and this made carbon kernel tightly coupled with Apache Axis2.

Another point is…

View original post 210 more words

Basic CRUD operations using Jaggery


Screenshot from 2014-01-18 13:10:58WSO2 has released Jaggery.js, a framework to compose web apps and HTTP-focused web services in pure JavaScript for all aspects of the application: front-end, communication, Server-side logic and persistence. The framework will reduce the gap between writing client-side web application pages and back-end web services.

In this series of Jaggery.js tutorials, I’m going to talk about how to perform basic CRUD operations using Jaggery.js.Jaggeryjs

Note
If you want to know what and how Jaggery.js works, please refer my previous post for further clarifications.

Technologies and Tools used in this article:

1. Setting up  

I hope you have downloaded all the necessary tools which are mentioned above.

  • Download and unzip jaggary then go to {Jaggery_home}/bin and execute following commands on the terminal. If you are a Linux user sh server.sh or windows user server.bat to start the serverScreenshot from 2014-01-18 13:07:32
  • Create a folder called crud inside {Jaggery_home}/apps/ folder path
  • Make sure your MySQL up and running, create a DB called tasks
  • Copy MySQL connector jar file ( mysql-connector-java-5.*-bin.jar ) in to  {Jaggery_home}/carbon/repository/components/lib

2. Standard web project 

follow the instruction as it is.

  • Create a Jaggery configuration file called jaggery.conf which specifies the application specific configurations.for this example it contains application URL mappings. application context as follows.
{
 "displayName":"DB", 
 "urlMappings":[ 
 {
 "url":"/welcome/*",
 "path":"/modules/serverReq.jag"
 }]
}
  • Now we are going to create our first jaggery file. In-order to isolate the server-side logic create serverReq.jag jaggery file inside modules directory.
  • Basic CRUD operations as follows.
<%
 var query1 ="CREATE TABLE example(
             id INT NOT NULL AUTO_INCREMENT, PRIMARY KEY(id), val VARCHAR(200));";
 var query3 ="SELECT * FROM example;";
 var query4 ="SHOW TABLES LIKE 'example';";
 config = {};
 var dataSource = new Database("
             jdbc:mysql://localhost:3306/tasks", "root", "root", config);
 result=dataSource.query(query1); 
 %>
  • Let’s move on to client side logic. for that create a javascript file called crud.js
CRUD = new function() {
   console.log("CRUD operations protocol has been initiated ");
   this.getValues = function(){
   var id = Math.floor(Math.random()*100000);
   var d = new Date().toString();
   var dateStr = d.substring(0, d.indexOf(":",20));

   var textFName = document.task.fName.value;
   var textLName = document.task.lName.value;
   var textConNo = document.task.conNo.value;

 $.post("welcome/", 
 { 
   first: textFName, 
   last: textLName, 
   contact: textConNo, 
   time: dateStr, 
   action: "add", 
   id:id 
 },
 function(data){
  $(data).hide().prependTo(".val").fadeIn("slow");
  console.log("fadein executed");
  $("#message").hide();
  $("#fName").val("");
  $("#lName").val("");
  $("#conNo").val("");
 } ); 
} 
}
  • Create your index.jag file and paste the following code
<html>
<body>
  <div class="row">
   <div class="col-lg-4">
   <form id="task" name="task">
     <div class="input-group">
     <span class="input-group-addon">First Name</span>
     <input type="text" class="form-control" id="fName" placeholder="Employee First Name">
     </div></br>
     <div class="input-group">
     <span class="input-group-addon">Last Name</span>
     <input type="text" class="form-control" id="lName" placeholder="Employee Last Name">
     </div></br>
     <div class="input-group">
     <span class="input-group-addon">Contact No</span>
     <input type="text" class="form-control" id="conNo" placeholder="Employee Contact #">
     </div></br>
     <button class="btn btn-default " onclick="CRUD.getValues();">Save changes</button>
     </form> 
  </div>
 </div>
</body>
</html>
  • So that’s all folks, then after you execute the code correctly you will be getting inputs as follows

Screenshot from 2014-01-18 13:10:47

Download the source files and try it out , Next post will be about, how to deal with POJO using jaggery.js till then , Happy coding 🙂

References

Jaggery.js – The delicious Javascript framework

Why JavaScript ?

There is no denying that since its inception in the mid 90’s, JavaScript has become one of the most popular Web development languages. So it has become the top language due to its ability to deliver rich, dynamic web content, its relatively lightweight and its high ease of use. In recent years, we’ve seen its continued evolution beyond the desktop to areas such as mobility and server-side web applications. There are strong odds in favor of JavaScript becoming the dominant language of the enterprise.This isn’t to say every other language will atrophy overnight (They won’t !) but legacy systems count on them for sure. So yet a revolutionary,a simple, open language, equally adapted to building both client and server-side apps? There’s no such thing as technology perfection, but JavaScript looks like the next best thing.

A modern web application invariably includes a significant client-side Javascript component.Why then are we using a completely separate language for server-side programming? You don’t have to switch our brain here and there, now we can use Javascript for server-side-programming for an example Node.js which is based on Google’s V8 JavaScript engine, that makes wonders. I’m directing this post towards another revolutionary server-side Javascript framework called.” jaggery.js “. Jaggery uses Javascript as the server-side programming language, the obvious choice for simplification. let’s get on with it. shall we ?

Jaggeryjs

Jaggery is a framework to write webapps and HTTP-focused web services for all aspects of the application: front-end, communication, Server-side logic and persistence in pure Javascript. One of the intents of this framework is to reduce the gap between writing web apps and web services. Importantly, Jaggery is open-source and released under Apache 2.0. if you interested to read the full manifesto read it from here [5] .

Enough said, here’s a simple example, a step beyond the basic hello world to help you get a sample of Jaggery’s core implementations. enjoy 🙂

<%
var jsonString = '{"name":"Pubudu","company":"WSO2"}';
print(parse(jsonString));
%>

You can try above code on Jaggery-Tryit . Download jaggery framework form the parent site [2] and do your experiments, here few sample implementations which helps you to learn in depth about what jaggery can do.

My next blog post will be about Basic CRUD operations using Jaggery, till then happy coding 🙂

References

[1] http://wso2.com/library/articles/2012/10/introducing-jaggery-the-newer-easier-way-of-writing-web-apps/

[2] http://jaggeryjs.org/

[3] http://wso2.com/library/webinars/2012/05/wso2-product-release-webinar-introducing-jaggery-serverside-javascript-framework-composing-web-app/

[4] http://jaggeryjs.org/samples.jag

[5] http://jaggeryjs.org/about.jag

Effective logging practices ease enterprise development

There are tons of logging frameworks out there including  log4j, but the right one for you will depend on your platform and system.

The best logging techniques will depend largely on your platform and the design of your system. You need to know/decide how much information you need to diagnose a particular type of problem. Generally, you should instrument your code in a way that does not require a lot of code repetition or modification. You should also be able to modify the level of logging (Low through Verbose) through configuration without having to shut down or restart any services.

The moral of the story is to :

  • Know the need of logging
  • Understand the options available and which suits you best (varies with Platform/OS/etc)
  • Plan the strategy in advance before implementation.
  • Keep reviewing the make changes.

Happy Coding 🙂

Resources

[1] Effective logging practices ease enterprise development

What Are Pull Parsing and Push Parsing?

so it is essential to understand the meaning and the concept behind pull parsing. XML documents can be parsed using a “pull-based” or a “push-based” (StAX) process. Pull parsing is a recent trend in XML processing. The previously popular XML processing frameworks, such as SAX and DOM, were “push-based” (SAX); this meant that parsing control was in the hands of the parser itself. This approach is fine and easy to use, but it was not efficient in handling large XML documents because a complete memory model will be generated in the memory. Pull parsing inverts the control; therefore, the parser proceeds only at the user’s command. The user can decide to store or discard events generated from the parser. OM is based on pull parsing.

Addition resources
[1] http://www.ibm.com/developerworks/xml/tutorials/xmlintro/
[2] http://www.ibm.com/developerworks/xml/library/x-stax1/index.html
[3] http://www.ibm.com/developerworks/library/x-jaxp/#download

Happy Coding 🙂

How to draw a Control flow graph & Cyclometric complexity for a given procedure

Cyclomatic Complexity 

Cyclomatic complexity is a software metric used to measure the complexity of a program.

These metric, measures independent paths through program source code.Independent path is defined as a path  that has at least one edge which has  not been traversed before in any other paths.

Cyclomatic complexity can be calculated with respect to functions, modules, methods or classes within a program.

Cyclomatic Flow

Compound Condition 

where one or more Boolean operators such as logical OR, AND, NAND, NOR are present is a conditional statement

IF a OR b
then procedure x
else procedure y
ENDIF

A predicate node will be created for each statement.
Compound Logic

Check the following code fragment

insertion_procedure (int a[], int p [], int N)
{
    int i,j,k;
    for (i=0; i<=N; i++) p[i] = i;
    for (i=2; i<=N; i++)
    {
        k = p[i];
        j = 1;
        while (a[p[j-1]] > a[k]) {p[j] = p[j-1]; j--}
        p[j] = k;
    }
}
  • first and foremost start numbering the statement
insertion_procedure (int a[], int p [], int N)
 {
(1)    Int i,j,k;
(2)    for ((2a)i=0; (2b)i<=N; (2c)i++) 
(3)        p[i] = i;
(4)    for ((4a)i=2; (4b)i<=N; (4c)i++)
       {
(5)       k=p[i];j=1;
(6)       while (a[p[j-1]] > a[k]) {
(7)           p[j] = p[j-1]; 
(8)           j--
          }
(9)          p[j] = k;
       }
  • Now you can clearly see which statement executes first and which last etc. so drawing the CFG becomes simple.

cfg
Now, to calculate cyclomatic complexity you use one of three methods

  1. Count the number of regions on the graph: 4
  2. No. of predicates (red on graph) + 1 : 3 + 1 = 4
  3. No of edges – no. of nodes + 2: 14 – 12 + 2 = 4

That’s about it , Happy Coding 🙂