Monday 30 September 2013

How to approach a Java Web application

Java web development has evolved since its birth up to today. Am not going into history but am going to answer this question that might immediately pop in  your mind if  you are considering java for your web applications.

Question:
What is the approach to use in developing Java web applications? (In other words, what do I do and where do I start from if I want to develop a web application in Java?)

Response:
This may sound like a simple and lousy question if you have not ventured into the actual development of web applications in Java, but for those who have tried you probably know what this means.
You have probably heard people saying scattered and non-comprehensible statements regarding how to do web applications in Java. If you are down there in an illusion, or if you have an Idea, lets face it. 

In Java, there are a number of approaches/technologies you can use for a web application. I will leave out a lot of verbose that you might not benefit you if you want to start immediately so, I will go straight to what you need to know.

To develop a good web application in Java,
 One you have to know about MVC (Model View Controller) architecture. There are a lot of materials on this topic to get you started, and am not talking about any technology in detail here. I strongly suggest that you first get some understanding of MVC because later, everything in Java web application development built around it.

Two, Choose a framework and learn how to use it. There are a number of frameworks built to  simplify MVC and make development easier e.g Spring MVC, Struts 2, JSF. e.t.c So, look out for a Java  web application framework and this will help you not to re-invent the wheel as you do your development. I immediately advise that you learn JSF(Java Server Faces) since it holds all the future for Java web applications. JSF alone is very wide and has a huge learning curve so I suggest you look out for a framework built on top of JSF, which is what most developers do anyway. So, get some few tips and some understanding on JSF and Learn a JSF Framework instead. There are very many JSF Frameworks but the most common ones are PrimeFaces, IceFaces, RichFaces, Oracle ADF. Each of these is very good in its own way but your choice might depend on a number of factors. I have used Oracle ADF but I now use PrimeFaces. If you want a clean comparison that will help you to make your own choice, see here.  

Three, you need to know JPA (Java persistence) and EJB(Enterprise Java Beans). To bring the whole picture very clearly, JSF (Using your chosen JSF Framework e.g Primefaces) will be your provider for the Views, JPA for the Models, and EJBs for the Controller and Logic. This makes MVC but with the combination of best practices.

Four, choose the right IDE(Intergrated Development Environment). Some IDEs can really complicate things for no good reason. I have met people who have lived in fear for Java web development just because they started off with IDEs that made everything seem so complicated and abstract. I suggest you use NetBeans as your IDE. A simple JSF application using NetBeans might help you understand. An IDE is purely a personal choice to make but NetBeans is free, reliable, professional, easy and straight forward;  the fact the Oracle company which owns Java also owns the tool, you can smell a bright future in this regard. A minute, if you intend to use Oracle ADF as your JSF Framework, strictly JDeveloper is the IDE. If you can't wait to develop a JSF application in NetBeans, start right away started using this tutorial

Some one is grumbling that I didn't talk about JSP(Java Server Pages) , Servlets or JDBC.  Well, we can't hide away from the fact that some frameworks like Struts 2  and others you may know have been widely used, but lets also come to the fact that despite their success there is transformation going on right now. So, It's a personal choice to transform with others or keep in the past. As for me, I will focus on what the future holds for Java web and Enterprise applications which is what I have talked about above. Don't forget that, If you Invest in best practices, you will always spend less time to produce very good work , but if you do the other way round, you will always spend ages to produce even the simplest thing. If you bet, try it.

Let me know what you think. Your opinion is highly appreciated.

No comments:

Post a Comment