Tuesday, February 7, 2017

Microservices and Reactive Architecture

Micro services
The Microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms. 

Critical characteristics of a Micro Services are
  1. Componentization via services
  2. Organized around Business Capabilities
  3. Smart End points
  4. Infrastructure Automation
  5. Design for failure


Key considerations for efficient Micro Services development and deployment.
  1. Infrastructure Automation and Rapid Provisioning
  2. Basic Monitoring
  3. Rapid Application Deployment
  4. Devops 


Advantages for Microservices are 
  1. Ability to deploy different services independently
  2. Reliability, due to the ability for a service to run even if another service is down. 
  3. Ability to build Services on different platforms, e.g. as a way to experiment with a new language.


Reactive Architecture
The need for error-tolerance and fast reaction in dynamic environments have resulted in reactive architectures. They have task-specific modules that initiate direct reactions in response to specific situations that occur in the environment. 

Key characteristics of Reactive Architecture are: 
  1. Responsive
  2. Resilient
  3. Elastic/Scalable
  4. Message Driven


Systems built as Reactive Systems are more flexible, loosely-coupled and scalable. They are significantly more tolerant of failure

Benefits of both Styles:
While Micro services enables looking at application in terms of small individually deployable services, Reactive Architecture helps building applications which can scale as need (at required later by scaling required services) and ensure fail over. Together they bring ease of maintenance, reliability, scalability and fail over to the application. 

Wednesday, February 1, 2017

Microservice implementation using OSGI, Apache Karaf and CXF

OSGi (Open Service Gateway Initiative) is a Java framework for developing and deploying modular software programs and libraries. It’s a specification that defines how to develop components that can be deployed and invoked as Services (as in SOA)

OSGi only defines specifications for component development and basic execution environment. OSGi specifications are implemented by projects like Apache Felix.

Apache Karaf adds utilities to Apache Felix. These include ability to Hot deploy, Logging and Monitoring etc.
It also includes a Container that contains these Utilities and along with Apache Felix. It also provides ability to Remote login to the container. Services developed using OSGi specs can be deployed into this container.

Karaf container sounds similar to Docker. In case of Docker developer need to build an image specifying OS, app server (like tomcat) and then application can be deployed in that Image. Where as Karaf Container has all necessary environment to run OSGi services. Developer need to bring the container up and deploy the services.

OSGi services when complimented by the features provides by Karaf can be a good choice to implement Microservices architecture. I don't feel OSGi service (deployed on plain Apache Helix) can meet all required criteria to be Microservice architecture. Because features like Scaling, Monitoring etc need to be custom implemented.

In fact OSGi services need to be exposed as REST services (using Apache CXF) so that they can be invoked from any application/platform/technology.

Below are the quick steps to set up and get basic service with REST interface up on Apache Karaf.

Lets first define a simple service

Interface:

public interface MyService {

public String printMessage();
}

Service Implementation

public class MyServiceImpl implements MyService {

@Override
public String printMessage() {
// TODO Auto-generated method stub
return "My Service";

}

}



Next define a REST interface for this service using Jersey framework

@Path("/myService")
public class MyRestService {

@Produces({ MediaType.APPLICATION_JSON })
@GET
public String getMessage() {
MyService service = new MyServiceImpl();
return service.printMessage();
}
}



Create a simple Java project to contain above code components. Compile, build and package as a Jar file. Now lets setup Karaf and CXF to deploy this bundle.

Below are the quick steps

  1. Install Karaf container. 
    • Download Karaf container(binary distribution for quick start) from http://karaf.apache.org/download.html
    • Unzip the contents to
  2. Start the container
    • /bin/karaf
    • Karaf shell should be active now (karaf@root()>)
  3. In Karaf shell execute below commands to install Apache CXF and HTTP features to enable http interface and rest services
    • feature:repo-add cxf 3.1.5
    • feature:install http cxf-jaxws http-whiteboard
    • feature:install  cxf-jaxrs
  4. Copy the Jar bundle to /deploy
  5. Command "list" should list the service just deployed if deployment is successful.
  6. Use command "bundle:diag" to check errors with last operation


Use URL "http://localhost:8181/cxf/sample/myService" to test the Service

This post discussed basic service implementation with Karaf. Shall look at other aspects of Microservice implementation in a later post.

Saturday, August 29, 2015

Docker on Mac OS 10.10.

Well, Docker is everywhere now!! For last few weeks studying their applicability in DevOps, Micro services etc. Today wanted to make my hands dirty with some Docker samples. But its not smooth start. Just wanted to share the issues and resolution at one place.

After installing docker as per documentation on Mac (OS X 10.10) and launching the CLI first error got was “Default is not running. Please start this with docker-machine start default.” After googling around and analysing different solutions, found the issue is with Virtualbox version. (I had Viirtualbox version 5.0 already installed.). The issue is resolved with installing test Test-Build 5.0 (https://www.virtualbox.org/wiki/Testbuilds). The link for issue is  https://www.virtualbox.org/ticket/14412 

After restarting Docker, next error I got is with ca.pem file. After starting Default VM error shown is “ca.pem: no such file or directory”. After executing below two commands, docker started normally


docker-machine regenerate-certs default
docker-machine restart default

Below are the links that helped me solve the issues
http://stackoverflow.com/questions/32240742/after-installing-docker-docker-machine-env-default-fails-because-ca-pem-is-not


Wednesday, February 25, 2015

Code on Your Own device (CYOD)


In my blog post in Feb, 2011  "Work on move... or coding on mobile" I envisioned possibility of coding on a mobile device. Today I was talking to my colleague who said he uses only iPad for work no Laptop!!. I asked how do you code? He connects to server using Microsoft Remote Desktop, connects a key board to iPad and codes!!. Some time back from I got to know  from IoT team of a light weight version of eclipse that works on Raspberry PI which got 1GB RAM. Today I use a phone that got 3GB RAM!!!. Don't think its long way to have Eclipse and JRE on Mobile devices. (I guess there are some issues to install eclipse directly now but there are alternatives like Ubuntu Virtual Box on Android and Eclipse on top of it, root the device and install Linux etc).

So can we see "Code on Your Own device" movement soon!!!

Saturday, February 7, 2015

Facebook for Business - Mind Map

I tried to summarize my understanding of Facebook's applicability for Business. 



Apart from Facebook's Graph API and Ads API below are few things worth learning about


Open Graph
Open Graph lets apps tell stories on Facebook through a structured, strongly typed API.
Stories used share the things people are doing on webpage/App. Ex: “X has finished reading Y book on Google Reads”, “A bought product B on XYZ Store”. These are posted on user’s Facebook page as posts
Insights API can be used to track the stories, likes and comments on them.
Facebook exchange
Facebook Exchange helps you reach people who have expressed an interest through their online behavior so you can reach them with a similar kind of product or service.
Ex: Target user who searched for product or clicked a web site.
Uses Demand-side platforms
PMD Center
The Facebook Preferred Marketing Developer (PMD) program is a community of hundreds of best-in-class developers /companies Facebook marketing solutions.
Companies get additional support from Facebook platform representatives
Public Content Solutions (PCS)
Partnership with companies which  are experts in integrating Facebook and Instagram into their customers’ experiences connecting audiences and fans
Privileged access to data and content APIs and dedicated support resources

Direct collaboration with Facebook business development to help support and grow your business


Friday, February 7, 2014

Issue with Facebook Graph API

Facing an issue with Facebook API. Looking out for help to understand the reasons and resolve the same
We are trying get public wall messages containing a particular keyword.We created application with permissions including read_stream and manage_posts. Application visibility is public and most of other settings are defaults. We could see API working and getting the feeds. Last week we observed an issue. Search API is not picking up messages from certain users. We picked up couple of such ids did some testing. Privacy settings all seems to be fine. Posts visibility settings are public both at feed level and account leven. Platform is turned on. Visibility to search engines is on. For these selected IDs we tried to get wall feeds using their IDs. Below are the observations.

1. For a certain ID we could get all messages both in search and wall retrieval. Both with our application key and default Graph API Explorer access key.
2. For one ID we for messages using Graph API Explorer but not with our application. With our application only feeds we see response are friend request accepts and likes to some other public posts.
3. For another ID Graph API explorer is giving empty results and out application key is giving likes etc as observed in above case.
4. For one of the Use we asked him to turn off the Platform, we were getting messages before. When turned off we stopped getting messages. When turned on we didn't get all messages but only likes etc.
5. When we use Social Mention (socialmention.com) and search for keyword, we could see all messages.

We feel it has to do something with the Application and access key permissions but couldn't get much details. Any help in cracking this is welcome.

Update (May 05, 2014):
The issue is with the way access token generated.

While generating access key we can select permissions to match application requirements. Any thing beyond basic permissions require permission from User. For example if we choose user_location permission, user need to provide permission to get that information. If no additional permissions selected, application will not require any permission and can access all the public data. But if any additional permissions are selected and user not given permission, we cannot get even the public data of that user. With default permissions I generated access key and could get all public data as expected.

Monday, January 6, 2014

"Apache Flume: Distributed Log Collection for Hadoop" - Book review

We have been working on Apache Flume for quite some time now. We used it to load data from Social network into MongoDB and also for log collection. Recently I read a book on Apache Flume titled "Apache Flume: Distributed Log Collection for Hadoop".
 
This is a good starter material for a serious Flume developer. 2nd Chapter provides a good step by step guide to setup and get running with Flume. Liked the way the flow is presented and the mention about important arguments that can be provided to Flume command line. Other useful information from this book is about the Monitoring tools. Though the description is brief good to have introduction to some tools. Overall book gives good details with examples on Flume flow and architecture which includes Channels, agents, sinks, interceptors etc. It would have been more helpful if last two chapters were elaborated more.

Tuesday, July 9, 2013

Modes of Big Data Analysis


We can look at analysis in three modes based on trigger for analysis.
  • Offline/Batch Mode
    • Analytics performed and results are made available for applications to use
    • Ex: Clinical Trails, Voice of Customer
  • Real Time – OnDemand
    • Analysis done and results are presented when requested.
    • Ex: Up-sell/Cross-sell
  • Real Time – Stream based
    • Monitor streaming data (Twitter messages, Transaction logs, data from Sensors) and trigger analysis based on event/data.
    • Ex: Monitor and analyze online transactions for Fraud, Monitor social media messages for serious incidents.

 

And below are the implementation approaches:
  • Massive Parallel Programming (Data Bases and Programming)Hadoop MapReduce
  • Scalable Database – NoSQL databases and Databases with ability to store huge data (Ex Oracle ExaData) and to perform operations on data.
  • In-memory Analytics - an approach to querying data when it resides in random access memory (RAM), as opposed to querying data that is stored on physical disks.
  • Big Data Appliance - combination hardware and software products designed specifically for analytical processing.
  • Processing in Memory (PIM) - a chip architecture in which the processor is integrated into a memory chip to reduce latency.
  • In-Database Analytics - a technology that allows data processing to be conducted within the database by building analytic logic into the database itself.
  • Real-time Stream Processing & CEP
Combination of above approaches need to implement the Analytic Apps
 
Almost 2 years back, for couple of months, I had my first stint with Big data and Hadoop before moving on to Social Analytics. As I resumed my interest into Big data I was looking at my old work and above are from one of my early presentations.

Sunday, January 6, 2013

Klout4Java : Java wrapper for Klout partner API


One more contribution for Open source. Uploaded klout4java, a Java wrapper for Klout Partner API v2. I had calls to klout API in our Social Analytic platform. As v1 of klout API getting deprecated, I had to upgrade and I couldn't find any Java wrapper for v2. This lead me to write a wrapper for myself and I uploaded the same for community use.

The link to klout4java http://code.google.com/p/klout4java/

Sunday, November 18, 2012

Jab Tak Hai Jaan - Twitter Metrics


One of the topic that attracts good twitter traffic in India is movies. And if the movie is a much awaited Diwali release from Super star, then its a simple expectation to have a good twitter buzz. And on its release day Jab Tak Hai Jaan was a trending topic. I did collected the tweets related and in this blog will present some metrics. Some might call this Analysis but I prefer metrics/report because no Statistical or NLP algorithms involved to derive these results.

Data was from 11/12/2012 18:33 to 11/14/2012 12:15. Twitter Steaming API is used to collect the data and the keywords that were tracked are "JTHJ", "Jab Tak Hai Jaan" and "SRK". Not much of data cleaning applied as these keywords are not so common. Total tweets collected are 104,654 of these Retweets are 31177 (30%).
First lets see simple report, the tweet time line. The graph shows the tweets trending. The value on x-axis is dd/yy HH. Around 3'O Clock in afternoon of 13th Nov is the peak.

Below table shows top sources for traffic with re-tweet segregation. I expected percentage of re-tweets will be more for mobile devices. But my assumption seems to be wrong from below data. Surprisingly, twitter for Blackberry is more popular than iphone though the margin is less. This data also signifies the dominance or abundance of Android.


Source Total tweets Original Original% Retweets Retweets%
web 38043 24635 64.76 13408 35.24
mobile web 14813 10382 70.09 4431 29.91
twitter for android 14359 9285 64.66 5074 35.34
twitter for blackberryâ® 8828 6698 75.87 2130 24.13
twitter for iphone 8035 5287 65.80 2748 34.20
facebook 4682 4658 99.49 24 0.51
tweetdeck 1490 1069 71.74 421 28.26
tweet button 1429 1398 97.83 31 2.17
twitter for ipad 1276 807 63.24 469 36.76
ubersocial for blackberry 1114 935 83.93 179 16.07
tweetcaster for android 1103 774 70.17 329 29.83

Most of the tweets with triple figure  re-tweet count are from celebs. Of the top 10 3 are from Sharukh, 3 are from reviewers (like taran adarsh). One from Yash raj films also in top 10. Looks the movie team engaged themselves well in Social Media, which I feel is very important for successful social media marketing. Below are top 5 tweets with max re-tweets.


Tweet Retweet Count Author
RT @iamsrk: Very touchng how all of u r buyng tckets for jthj and excted about t. It makes me feel very wanted & postvely pro ... 1221 iamsrk
RT @bipsluvurself: Jab Tak Hai Jaan mkes u wnt 2 find ur soulmate ur true love.Infuses romance in2 ur life.A must see!Saluting the King  ... 641 bipsluvurself
RT @priyankachopra: As everyone comes together to Celebrate Yashji tonight..I sit far away and thank him for touching all our lives..wis ... 567 priyankachopra
RT @iamsrk: En route to Jalandhar for JTHJ...havent slept a wnk all nght...eyelds r feelng lke a mattress. Hope ts a long slow flt... 561 iamsrk
RT @taran_adarsh: Those asking, yes, all three Khans - SRK, Aamir & Salman - were under one roof for #JTHJ premiere. Premiere and po ... 493 taran_adarsh

In the next blog will try to interpret actual review of the film from Tag Cloud generated from these tweets.








Tuesday, November 13, 2012

otter4java - Java wrapper for Topsy's Otter API

Finally today I uploaded my first version of code for long back started my open source project... otter4java. Java wrapper for Topsy's Otter API. In this version I included only search call. Will include other endpoints in future versions. 

Also included in this current version is integration with Crawler. We can crawl the links from the results from search to get the contents. Output is stored as xml files (one for each result) with URL and content as fields. I used crawler4j for this.

Link to the code : http://code.google.com/p/otter4java/

Sunday, November 11, 2012

Social Influence Ranking - My take

I read some where that a celebrity is paid good money if tweeted about a product.The concept "Social Influence" is becoming prominent thanks to Social. There are quite a few sites that calculate influence scores.
Most of these methods assign either a score or level to the Social ID. But how efficient is this to use in Social Marketing? 
Lets consider ID of a popular Sports Star. He might have got millions of fans and his tweets might be re-tweeted numerous times. He might also be re-tweeting or replying to tweets. This will result in good Influence score for him. Now if a pesticide company wants to use Social channel, they might as well get influenced by the influence score and get this sports star tweet about their product. Will this of any help. In most cases no! because most of the people in his circle will be interested in sports and with little or no interest towards pesticides.
Leave aside marketing, will this score help me find whom to follow in my area of interest?I doubt, because they give high level score but doesn't say in which field they are influential. I remember Klout API does give some description about topics the person generally talk about but still it wont assign score against topic.I feel the scoring should ideally against topics and not just for ID. For example the above Sports star ID will have a high score for sports and low in politics and agriculture.I am not sure if there is any tool/site that provide this information. So far I haven't came across any. There are sites that can extract topics from feeds/data. We need this to be incorporated into Social Influence ranking algorithms for better use.

Sunday, August 12, 2012

Satyameva Jayate - Twitter (Sentiment) Analysis


As we all know Social media is changing or influencing lot of the traditional communication mechanisms. Its providing more wide platform for people to share thoughts, advertise products and analyze user's feelings. For those close to technology, Social Media monitoring, Social Analytics, Social Engineering etc are buzzwords heard more often these days. Its hard for any body to ignore Social Media now. From my experience so far FMCG, Entertainment media are among the areas that has their presence more in Social Media. Its very common to see references to Twitter in print and electronic media these days.

Amir Khan's completed his Satyameva Jayate's (SMJ) first season. keeping aside the sensitiveness of topics, accuracy of facts, its impact on society etc, SMJ is certainly one of the shows which is talked about more in Social Media. Thought of using my experience in Social Analytics to present some of the analysis on SMJ from twitter feeds. I will start with basic analysis in this post.

First lets see the tweet density, the number of related tweets during the 13 week time. The peaks that you observe are, as expected, are on the days the show telecast.Overall trend line show little decline in tweet. Also few episodes in between are less popular. These are when topics like domestic voilance, use fertilizers etc discussed. Alcohol Abuse, Aging parents, Water conservation topics got some increased attention on twitter. Of course, this might reflect only immediate reaction to show. Will try to present detailed analysis by presenting average week analysis and topic wise analysis in future posts. Next lets see the Sentiment Analysis.
Lets first look at the Positive trend, that is the percentage of the total tweets with positive sentiment over period of time. Adjacent graph depicts the positive sentiment. Overall trend line shows a little decline in positive sentiment. From initial observation it looks tweets during episode on medicine bear more positive sentiment compared to other episodes. Again, this graph reflects overall mood of the user in general. More deeper analysis, like feature based Sentiment Analysis, is required to capture exact mood of the audience. It will answer questions like, is this positive sentiment during healthcare episode is towards Amir's views or towards Health care industry? 

Finally lets look at Negative trend graph. Graph on left hand side shows the same. As observed the overall trend line shows increase in Negative trend. As mentioned earlier will provide deeper analysis in future posts. Main intention of this post is not to do postmortem of SMJ but to show some applications of Social Analytics with an interesting and relevant case study.

Before closing, a word about data collection and analysis techniques. Data was collected with Twitter Search API using keywords. Of the keywords used SMJ, Satyameva Jayate, Amir Khan, SatyamevJayate, smjindia are the common keywords used for all episodes and episode specific keywords like AlcoholAbuse, dignity4all etc based are used. I wont rule out possibility of missing some tweets partly because of timing of search and partly because of accuracy of Search API itself. I generally executed Search program couple of times on Sunday and once during week. For Sentiment Analysis used Sentistrength Algorithm (http://sentistrength.wlv.ac.uk/) with modified Lexicon. Again the accuracy of this Sentiment Analysis might not be high. I expect this to be around 65%. In fact from our experience so far this is reasonable accuracy especially for Social Media data which doesn't follow language grammar. For more information on Sentiment analysis of Twitter feeds look at this white paper I co-authored - http://t.co/aXAv7aly.

Monday, March 28, 2011

JSF Validations, Dependency injection etc

For last few months I am getting to customize quite a few JSF features. This is JSF 1.1 and I some times I feel some level of dependency injection would have made my life easy. I shall disuss couple of examples below.
As in struts validations kicks in whenever you submit a form. But there are many instances where I need to submit form (bcause I need all values in screen) but don't perform validatiions for one action on a screen and for other action I need to perform validations. Basically I like to skip validations if there is a reauest parameter named SkipValidation present or target method name starts with 'load'.
In struts I achieved this by overriding processValidation method and adding a condition so that validation is skipped if method name follows certain pattern. I thought I can do a simillar thing in jsf. Wanted to modify ValidationPhase such that validation is skipped in certain cases.
But the class that implements validations is hardcoded or instanciated in LifecycleImpl class. To create a custom life cycle, you need to create Impl class configure it web.xml, create ContextListener to populate FacesConfig and bind all faces listeners to new impl class. And I add no to minimal code in tbhese classes. If I could inject the class that implements validation phase using some config file via dependency injection, I could have avoided lot of coding.
I will discuss another instancd onvolving StateManager in my next post.

Tuesday, March 22, 2011

My first Android app...

Last night I successfully implemented my first Android application. I wrote app which will place a call to my wife's mobile. I named it 'Call My Wife' :). Now I can call my wife with one tap. Though it just little more than Hello World sample, its fun and exiting to get something end to end done and also to see some thing I developed running on my mobile.


Its a small first step and I hope I will be able publish my own application in Android market soon. I thinking of building some application using my expierence in Indian Language Technology.

Monday, February 14, 2011

Work on move... or coding on mobile

One thing that amazed me recently is the advancements in mobile world and the speed of these innovations. Especially the android market. The first mobile that I got had a small screen and a 2D snake game. It was just a phone!! Three yrs back when I got a walkman series phone I loved the quality of music it offered. After 3yrs I thought of buying a new one and confused... so many features in little phone...finally got a good smart phone. And ofcourse android.
Recently I read review of a phone with 2 screens and these can be combined as one screen in tablet mode!! Looking at these1GHZ and 32GB+ mobiles I think its not long away before we can start  coding and test on a mobile itself. We might soon get eclipse for mobile platform and SDF. We already have oracle lite, database that can be installed on devices. May be we can say "work on move" instead of "work at home".
(I am posting this from my mobile using google's blogger android app)

Sunday, September 12, 2010

10 Years on... Java Coding and Akshara...

Its almost 10 years that I started writing Java Code. I like relook at the begining and introduce my first project/product I worked on.
Its 2001 January I started my 6th Sem Project as part of my MCA (in University Of Hyderabad) course. I decided to work on a module of Multilingual (Indian Languages) text editor along with my classmate Ganesh under Prof K Narayana Murthy. This project is executed as part of TRCT (Technology Resource Center for Telugu) in University. This is one of the 11 reaserch centers/organizations setup for developing Tools and Technologies for Telugu. Being open source and to achieve platform independency it was decided to develop this product using Java. This is why and how it (Java coding) started. No prior or formal training!! Started with Java1.1 but soon moved to 1.2. Person working on this product had to leave and we had to take over complete product and this happened around Feb 2001. We got first basic version done in couple of months... but was slow (on 216 and 512MB machines). So we had re-design basic things and code. The next version came out impressive and promising. It was named "Akshara" - Advanced Text Processor for Indian Languages.
Project got over in July 2001. I was supposed to join in my first Job in SQL Star International but thanks to rcession joining date was delayed..... Luckily I was offered Job in same organization I did my project and to work on same product along with 2 of my classmates. So in 1st Aug 2001 I started coding for Money... For next two and Half I continued there and during that time we added more features to Akshara and also created a chat tool and a Technology for web input and output along with other things.





After many years and many projects Akshara still remains my best work so far from personal satisfaction factor. Below are few features of Akshara.

  • Open sorce
  • Platform Independent
  • 14 Indian Language support
  • Basic Text editing featured and styling (Alignments, text styles etc)
  • Uses own and open format (XDL) for storing files
  • Embeded Email Client
  • Spell checker
  • Text to Speech
  • HTML file creation with CSS

References to Akshara can be found at below links

http://www.lisindia.net/Telugu/telugu_Tech.html
http://tdil.mit.gov.in/TDIL-OCT-2003/text%20editors%20&%20word%20processors.pdf

Sunday, January 17, 2010

Using Re-Use...

As discussed in last post re-using existing code/components is one of the key thing for better development. Every organization will have repository of reusable components but how do we ensure their re usability? From my recent observations things that can be reused are

1. Common functionality exposed as services
2. Validation and other similar utilities
3. Edit rules and other UI logic

One stage where we can identify reuse is during design phase. You can easily identify the reusable services/components at this stage, But you can identify reusable validation utilities and other reuse opportunities only if you undertake detailed/low level design. But how many times we perform low level design? In these cases onus of identifying the reuse lies with developers and development leads. But bigger challenge here how will these guys know that there is some thing that can be easily reused? As a simple example a developer who is required to do date validations will know that there is a Date validation utils already written by some one else? In general hectic schedules it is very much possible that we oversee reuse opportunities and end up coding again (reinvent wheel).
The thumb rule that I like to propose for developers is... while coding if you happen to code any thing that is not very close to Business of the application, then there is an opportunity for reuse. For example if you are coding a rule like - calculations based on some combinations of values selected on UI and some algorithm specific to application then there wont be much reuse opportunity. But if you are coding some Date validations, UI edit rules using Javascript (like restricting text field to accept only numbers) there is chance for reusing some thing existing. If you observe these are independent and had no close relationship with any business logic. In these kind of cases, you can search your organization's repository to find out suitable utilities.

I will continue discussing this topic with specific examples in further posts.

Recently I read some overview of Language called Scala which promises excellent support for component development. And it says Software development will become similar to assembling hardware. Means you will just need to put together some components and get the final product. This is an interesting thought and planning to spend some time on this.

Friday, August 28, 2009

A Good Developer

What it makes to be a good developer? This question keeps popping now and then in my mind especially when I hear complaints from managers and leads saying their developers are not good enough. In Sun Tech Days couple of years back, there was a session according to which below are the 7 best habits of a good developer.

  1. Understanding the Problem
  2. Use appropriate tool
  3. Strive for Simplicity
  4. Keep your code clean
  5. Learn to debug
  6. Leverage whatever available
  7. Plan ahead

Lets discuss these in the context of general projects in Indian service industry

1. Understand requirements. This doesn't mean developer must have domain knowledge and understand business requirements but at least they must understand what should be done on click of Submit, click on Cancel, what formatting and validations need be done etc

2. Tools should have been decided before development start so lets not dwell much on this

3. 'Think Simple' - I keep telling my developers. Your performance is not measured based on number of lines you code or how complex your logic is.

4. Learn to code lean and clean code. This is possible only when following coding standards becomes a practice rather than compulsion. Also developer should emphasize on learning programming than programming language. I don't mean we don't have to learn any language but if you don't know how to solve a problem and write a basic algorithm there is no use of becoming an expert in Syntax of any language. Again you don't have to solve complex issues. Take for example age validations, if you don't know how to calculate age is there any use even if you know whole Date API in Java? Also emphasis more and more going in getting things done than on how? If developer gets a function point implemented that's enough, we rarely see leads reviewing for algorithm or developers caring to analyze their logic. No one to blame because of time lines but if you want to become a good developer your logic and its performance does matter a lot. Remember the Algorithmic subject thought in college and the order of executions?

5. Debug the code - No one writes a perfect code in one shot. With the latest IDEs and plug-ins debugging is easy than coding.

6. Leverage whatever available - Most of the things we do these days we are not the first ones doing them (Unless you are lucky like me). Refer organization's reusable repository, colleagues experience or online community to get the code. God had given us Google and a brain to use it.
7. No need to stress about time lines... Think and plan ahead. One of my professor used to emphasize to have complete algorithm written on paper and analyzed before even writing single line of code. Plan should include similar thing.. plan what to be coded and how to so that you wont end up with rework or stuck in middle.

To summarize, to become a good developer first thing to learn is problem solving (say analytical skills or whatever). Learn from all possible sources (read open source code, online material etc).

As Brian Kernighan and Dennis Ritchie say.. "only way to learn programming language by programing in it".

Any training can teach you API but not thinking.....

Friday, August 7, 2009

HTTP Session Managemet - Restricting approach

HTTP Session management - a frequent discussion point in many projects and frequent reason for performance issues in the projects. Recently I happened to review a project which takes nearly 5 mins to load a page that contains a table data. And after visiting this page application becoming slow. Reason is, application retrieves all data in one call and stores it in session scope and is not removed after traversing out of the page.Time and again managers feel need for design that controls session usage. Recently I initiated a discussion on IASA forum to gather ideas from community. I always felt HTTP session proper usage should be more of guidelines than framework. But if session timeout is more than usual 20mins, we might have to go for policing policy. Based on responses in the forum and my experience I think of below solution.


  1. Applications cant totally avoid session but should limit the usage. So while design identify the objects required to be maintained in HTTP session. Create a Class which will act as place holder for all data to be kept in session. This will be POJO with the objects that require to be kept in session as fields. So only objects that have setter method on this object can be set to session.

  2. Add a Session Listener. This will be a class implementing HTTPSessionListener. This need to be configured in web.xml. There are three methods in this interface. One of the will get executed whenever an attribute is added. This method in listener implementation should remove the added attribute excepting the predefined ones. (Apart from the object of above class, application container will keep some objects in session. Listener should discount them too. This will restrict the HTTP Session usage)

  3. Container object created in step1 can have a public method to calculate the size of itself (which means size of objects in session). Application can use this method for auditing like displaying http session data from application on a special page etc.

  4. Above solves one part of the problem, application still need to take care of clearing the data (by assigning null to the field). This can be taken care by application code. If need to be part of framework you can provide a configuration file which defines permitted data for each action/module. Define a some Intercepting filter that will examine the Container object and remove the unwanted data.

Its easy to implement and maintain. As every one agree its good design and implementation adhering to design that will result in good application