Saturday 9 February 2013

Rich yet Simple business task framework for Java

RichBiz

This framework focuses on writing any kind of business logic to make it more maintainable, testable, reusable and real time. It essentially focuses on following points and promotes developer to adopt the same while writing the business logic of any kind of use case, preferably which executes at server side. 
  • Task Oriented Programming
  • Fork and Join
  • Asynchronous  Execution
  • Memoization
  • Intelligent Statistics

This framework will greatly simplify business logic code by java's custom annotation feature. I have applied all the standard practices which i have used in my experience as java developer 

Everyone is talking about web application performance, scalability, exposing responsive services and mighty tech talks on clustering and its adoption to achieve these things. But most of us could not observe the fact that “Scaling the application” is different than “Scaling the Code” and these two aspects have to work in association to achieve true scalability.

One could think of “Scaling the Application” by having multiple instances on same as well as different nodes. This will help you facilitate the execution of number of requests from different users. What about execution of single request? Does it get scaled when we add more nodes or CPU’s? No, it does not!  big NO !

When we add more nodes so to our cluster, we are making it respond to more number of request from user but then due to large network infrastructure and increasing complexity several unwanted delays get added to total response time for processing the end user request. One should expect that the execution time of a particular use case on cluster environment to be greater than execution time on development environment where almost everything is on local machine. This is due to old linear programming practices which assume single threaded execution of given code.

If someone really wants to scale the code, then he/she better focus on how can the underlying CPU cores could be utilized to produce maximum throughput. This is where concurrent programming practices such as fork-join comes into practice which suggests division of business use case into smaller meaningful independent task units and executing them concurrently. More the number of processor more is the concurrent execution of task which ultimately results in optimum use of production system hardware and better response time to end user.

Task Oriented Programming
Like in OOP it is recommended practice to have single responsibility to a class, in TOP it is recommended that a single Task should represent a meaningful undividable execution unit if it does not represent a Job itself.
Job or complex task in TOP is collection of tasks or other Jobs along with the precedence execution rule.
TOP focuses on breaking down big fat business logic into smaller, reusable Tasks and arranging them to construct a business logic flow which in turn could be reusable as a Job.

Fork and Join
This particular algorithm from concurrent programming practices helps execute two or more independent Tasks concurrently to reduce the execution time which in general is addition of execution time of each Task.

Asynchronous Execution
Not every Task or unit of code is necessary to execute immediately to produce meaningful outcome; hence execution of such Task can be delayed which drastically reduces the total execution time of Job.

Memoization
Memoization is an technique of memorizing the function calls with the given arguments so that memorized result will be returned  on next function invocation with same arguments instead of executing a function again which is computationally  or system resource intensive act.
Memory cache or Disk cache can be used according to the requirement. This technique acts a steroid for any sort of application when performance is key factor.

Intelligent Statistics
To promote continuous re-factoring of code base for optimal performance, it is good practice to record a code execution statistics. Execution statistics calculation and information should be saved asynchronously which ensures that there is no non-functional logic execution overhead.
Statistics can be used to produce Management Information Reports which is essential to business. Reports may reflect certain meaningful information such as the consumption of various business services during the specific time period.


No comments:

Post a Comment