Thursday, December 23, 2010

Enterprise Java Flex Applications – Architectural Approaches

Rich internet application is becoming the new face of web based enterprise applications and flex is coming up as unanimous choice in this category. In this article, I presented few architectural approaches to use flex in java environment to develop web based enterprise solutions. Also, I tried to capture few advantages and challenges involved in using flex technology.

Architectural Approaches for Java Flex Application:

In this section I presented few architectural approaches for developing Rich Internet Enterprise Applications using java flex technology at presentation tier.

Architectural Approach 1: Using Flex HTTP Services:










Figure 1: Java Flex with JSP/Servlet/Struts at web tier

In this architecture approach the presentation layer (which consists of flex) uses HTTP services to communicate with server (web tier). The communication point on server side could be a JSP or Servlet which outputs the information in XML format instead of HTML format. Thus even frameworks like Struts or JSF can be used, but then these frameworks will be responsible for only generating the data to be given to presentation tier and not to generate the HTML screens. The flex layer then receives the data, parse it (can be automated) and then present it to user.

Advantages:

1. With this architectural approach, we can still use the standard n-tier J2EE enterprise architecture.

2. This approach requires only web tier to be molded slightly (as to generate XML data instead of HTML), rest of the layers will work irrespective of the presentation tier.

3. This architectural approach involves true separation of presentation logic.

Disadvantages:

1. This approach requires the web tier to generate XML data instead of HTML. For this the web tier needs to be modified and hence slightly bind to flex.

2. This approach doesn’t use the core reason of web tier presence. The web tier doesn’t serve its purpose fully here. If the presentation layer is fully in flex (not a mix of JSP/Flex), web tier presence would be an overhead.

3. Generating XML data at server end and then parsing it back at client end, is always an overhead.

Architectural Approach 2: Using Web Services:











Figure 2: Java Flex with SOAP Web Services

In this approach, important business functionalities are exposed as web services which are consume by Flex presentation layer. In this case, since there is no web tier, the flex layer becomes thicker and heavier as not only it has to call web services and parse the outcome but also has to perform some application logic which could have been delicate to web tier.

Advantages:

1. This is one more step towards SOA architecture.

2. Complete loosely coupled architecture as the same web services can be consumed by other presentation technologies or applications (like desktop application) irrespective of underlying technologies or platform.

Disadvantages:

1. With absence of web tier, the complete application and presentation logic lies with flex, which also means lots of code written in flex.

2. Can’t be used if presentation tier needs JSP and Flex combination. Helpful only for pure flex presentation.

3. Overhead of web service consumption, data serialization and parsing.

Architectural Approach 3: Using Flash Remoting (BlazeDS):










Figure 3: Java Flex with BlazeDS Data Services

This is a more Flex-kind of approach. In this approach Flex BlazeDS or LiveCycle data services are used at web tier. Data services tools exposed the java (pojo) classes as services which can be called directly from flex. The java objects are converted into ActionScript objects and then serialized using AMF binary format.

Advantages:

1. A cleaner and more flex like approach.

2. It’s quite fast as well compared with other approaches.

3. The same pojo’s can be used to expose as web services for other applications.

Disadvantages:

1. Again with absence of web tier (JSP/Servlet), the complete application and presentation logic lies with flex, which also means lots of code written in flex.

2. Can’t be used if presentation tier needs JSP and Flex combination. Helpful only for pure flex presentation.

Java Flex Technology: Advantages and Disadvantages

Advantages/Strengths:

1. Flex provides excellent user interface without much efforts. The UI components are rich from look-n-feel as well as from functionality perspective. Many UI features like validation, waiting/loading icons, hover effects, resizable components, layouts etc comes inbuilt with flex which otherwise would take lot of extra efforts if coded using HTML/JS.

2. Flex unanimously is the best choice when it comes to media oriented rich user interface.

3. If developed using Flash Builder (which is a paid plugin in Eclipse IDE), rich UI can be built easily without much efforts. In other words, rich user interface developed within no time.

4. Flex handles data more efficiently and effectively as compared to browser HTML processor.

Disadvantages/Weaknesses:

1. First and the foremost disadvantage of using Flex technology is that it requires an additional environment to run. In case of RIA, to open screens in web browser, it requires additional plugins to be installed. Although this sounds very trivial but in many companies and firms this may not be possible due to various security constraints.

2. The IDE (Flash Builder) is paid software. This adds additional costs to the project. Although the browser plugin is freely downloadable which doesn’t add any cost at run time.

3. One needs to learn additional language (ActionScript) while working with Flex.

Friday, December 10, 2010

10 effective ways to become a good programmer

A good programmer is someone who always looks both ways before crossing a one-way street. ~Doug Linder

Working as a software programmer in IT industry, one thing that drives us daily to the work place; is that fun and passion lies in programming. But to make that programming a fun and to get an eternal elation out of it, one needs to learn and adhere to some basics which make you a good programmer.

I am not writing mantras which you can follow to become a good programmer, but the intention is to collate a list of helping tips which I learned and implemented in the industry to get good results. There is no definition of a good programmer, but here we are referring to the category of programmer who have developed excellent IT solutions and helped in overall growth of this industry.

1. Work on Basics

As it is true for any industry and any job, the conceptual understanding is the key for success. Unless one has strong conceptual foundation, he/she can never be a good programmer. The core conceptual understanding helps you in designing and implementing the best solutions in the best possible way. If still you feel gap in core computer science and your programming language specific concepts, it’s never too late to go back and review the basics.


2. Start putting question tags (how, what) with every set of code you write

One thing that I realized creating a clear separating line between good programmer and rest is that zeal to know what and how it is happening. There is small group of people who can never leave a code without knowing exactly what is happening when it executes. I understand that in tight deadlines, we don’t get this liberty always and hence have to leave the code just knowing that it’s doing its job. Although this is a bit different topic of how to handle such situations, but as a programmer one can always try the level best to dig into as much as one can. And believe me, this becomes a habit with time and then you do it unknowingly every time.


3. You learn more by helping others

Most of us have a common tendency of turning our heads towards forums or groups only when we need help. And again a clear separation between the good programmer and rest that the formers visit these places more often to help others. This makes them learn more then they learn getting their problem solved by someone else. Within a team as well, help others to solve their problems. Believe me, understanding others’ problem in their context, investigating on that and providing solutions; will leave you much more learned than before.


4. Write simple, understandable but logical code

As in almost every aspect of life, the formula of KISS (Keep it simple and short) works in programming as well. Write more logical code and avoid complexity. Sometimes people do write complex code just to prove their capability to write such codes. My experience says that simple but logical codes always works well, resulted in fewer issues and are more extendable. I remember an excellent quote

Good code is its own best documentation. As you're about to add a comment, ask yourself, "How can I improve the code so that this comment isn't needed?" ~Steve McConnell


5. Spend more time in analyzing the problem, you’ll need less time to fix it

Spend more time in understanding and analyzing the problem and designing solutions for it. You will find the rest of the things quite easily doable. Designing not always mean using modeling languages and tools, it can be as simple as looking at sky and thinking solution in your mind. Those who have habits of pressing keyboard (for coding) the moment get the problem, usually ended us something different than the requirement.

If you cannot grok the overall structure of a program while taking a shower, you are not ready to code it. ~Richard Pattis


6. Be the first to analyze and review your code

Although a bit difficult, but try to break your own code before others can and with the time you will learn to write close-to-bug-free code. Always do a close and unbiased review of your code. Also never hesitate to take others view on your code. Working with good programmers and taking their feedbacks will surely help you become a good programmer.


7. Don’t dismay yourself by looking at changing technology world

Over these periods in IT industry, I met with many people who are either disappointed by their work or even left it to search new job saying they want to learn and work in latest technologies. I don’t see any problem with this aspiration but the very first incorrect word is the ‘latest technologies’. What we are hearing everyday and mean here is new tools, APIs, frameworks and others means coming up everyday to make the programming easier and quicker. This anyway will continue in technology world. But what needs to be understood is that the core and basic technologies changes with much lesser pace than frameworks, tools and APIs around it. This is like the sea where the surface water moves very rapidly but the deep water is relatively calm and concentrated and most of the aqua lives survive here. So, feel yourself in that deep water and close to core technologies. For e. g. in Java enterprise world, lots of web frameworks exist and new ones coming every other week. But the core concepts of request based client-server communication, MVS pattern, filters/servlets/JSP, resource bundling, XML parsing etc remains same. So spend more time in learning these core concepts rather than worrying about ever changing frameworks and tools around it. Believe me, with the foundation of core concepts, you will always find easier to learn new frameworks, tools and APIs.


8. Work-around don’t work for longer time

Many times software programmers implement work around solutions (may be because of lack of time, lack of problem understanding or lack of technology experience). But over the period these work around solutions always resulted in corrupting the code, making it less extendible and maintainable and lot of wastage of time later on. Always prefer to implement when you know the in-out of the solution. I understand that it becomes unavoidable in some circumstances, but it’s like, one should speak truth always but you tell lie in some circumstances.


9. Read documentation

One of the essential habits of good programmer is that they read lots of documentation. May it be specifications, JSR, API documents, tutorials etc. Reading documents helps you creating that essential foundation based on which you program in best of the way.


10. You can learn from others code as well

I interacted with some excellent programmers who actually have java source project inside their IDE all the time and read/refer that in daily work. They do it not only to fulfill their appetite of knowing the basics but also to learn ways of writing good programs. Reading and referring reliable and known open source code or your senior’s code, can also help you making your programming better.


And the last, not listed above: Don’t compare yourself with others

Your comparison of yourself with others will only result in evolution of negative feelings and un-healthy competition. Everyone has got his or her strengths and weaknesses. It is more important that we understand ours and work on it. I have seen many times that so called ‘fundoo-programmers’ (fundamentally strong programmer) also make silly mistakes. So, analyze yourself, list down your areas of improvement and work on it. Programming is a real fun, enjoy it.

Any fool can write code that a computer can understand. Good programmers write code that humans can understand. ~Martin Fowler