Tuesday, April 18, 2006

How to become a Java Developer?

Who is this post for?

Anyone trying to switch careers ( I was in mainframes, asp then php developer then a swing developer before I switched to this web-app java development), or who is already in Java and wants to get to the next level.

What this post is about?

Few years back I was slogging on a swing app without knowing what the market was all about - though the swing app taught me the good and bad about Java - it did not help me in getting a job. This post is a guideline for that directionless soul...

this.post :

Heres some philosophy of mine. Ask yourself - how much did you spend last year on books on technology? If technology is your livelihood, think of it as an investment. You need to invest a lot ( and read a lot ) to get good returns. So do not hesitate to buy books, magazine subscriptions - its worth every penny/paisa/rouble.

Lets start.

Step 1 : Get to know Java's strength.

Assuming it was me years ago, happily coding php in dreamweaver and nodding along with the posters in slashdot who say how bloated and slow java is and how fast and nimble php or any scripting language is...Here are some of the arguments "for" java to that nay sayer that I was.

Java is not for a 10 page web application.
Java is not for a guest book like application.

Java is for an enterprise. Something big - really big - having some 500 plus pages, 100 or more modules.
Java is when you need your app to scale to crazy levels - say 2000 users per second?
Java is when your app has to live and be maintained over a period of - say 10 years?
Java is when your client wants important stuff like transaction, security, clustering, fail safe
Java is when you have a team of 20 or more developers, 10 or more Analysts and a no-nonsense client who will sue your company for any goof ups.

Ask yourself and try to find answers. How has Java become to what it is today? Sun is not microsoft when it comes to hype, marketing - still - how did Java become the next COBOL? ( meaning - something the enterprise trusts, and also there are lot of developers with Java expertise ). Why is there such a huge ecosystem in the Java world?

Frameworks ( Spring, IBatis, nano container, pico container, Struts),
IDEs ( IntelliJ, Eclipse, Netbeans, JDeveloper, WSAD),
Webservers ( Tomcat, Weblogic,Websphere,Oracle App Server,JBoss),
Object Relationship Mapping ( Hibernate, Toplink),
Tools ( JUnit, Ant, Maven, Cruise Control),
EJBs ( Entity, Session and Message Driven )

and the above list is not even 50% complete.

Its a little overwhelming but it all makes sense - each one exists to solve a specific problem. You need not try and understand everything in one go - you simply cannot and even the most experienced developer might not know all. But once you have the fundamentals in place you can quickly master any of the above technologies or the new ones that are being cooked right now.

I have given you a nice path to go from a dabbler to becoming a master - that I found through trial and error and from my friends and co-developers. So rest easy and keep reading.


Check this link - comparision of programming languages to see for yourself how Java is doing.

Step 2 : SCJP, fundamentals

It takes a month of preparation to clear SCJP - Sun's certification program. What do you get out of this?

Very clear understanding of the language's syntax
OO Basics - Polymorphism, Inheritance, Encapsulation - are drilled into you
Collections - A Java Developer's best friend

I strongly suggest you take the SCJP exam. Everything else is built on top of this so its very essential to have a clear understanding of Java.

Books I own : Head First Java, Khalid Mugal's book for SCJP.

Step 3 : Jump into web application world

Download Tomcat.
Download Eclipse. ( Notice the No in Notepad.)

Write a simple hello world servlet and print it on a web page.
Send a string on the response to a JSP page and print the value on the JSP page

Download mysql database server and start it up.

Connect to mysql and try saving some data. Dont worry about the beauty of code, design etc- just get it working.

Move on to Struts and see what MVC is all about. I have 2 posts on struts on my blog. If you have patience try reading them.
Try writing a simple web application - a guestbook - in Struts.

All along you might be asking - why the heck do I need to do so much? Again the answer is these technologies were not designed for a small app in mind. Its for a goliath - an enterprise.

Here are some design tips :

1. Separate the business logic from the Action Servlets. Write unit tests to test the business logic. Write unit tests before you write business logic. This is called Test Driven development (TDD). Net is full of resources - this is a powerful programming style - and my company - thoughtworks - believes in it strongly unlike any other company.

2. Separate stuff like Database connection into seperate objects - and use that object in those objects that need database access.

3. Most important - keep all logic out of your JSPs. Its only for presentation. The most complex logic a JSP page can ever have is iterating a collection and displaying it on the page. If you are curious, explore custom tags - so you can even move most of the logic needed for presentation into java class files.

Books I used : Head First JSP / Servlets, Struts in Action.

Step 4 : Become a smart Java developer - with your best friend - Ant.

Ant probably is the most widely used tool. Get to know Ant - try incorporating starting and stopping tomcat inside your build.xml. So you can do cool things like :

ant startserver
ant stopserver
ant runalltests

ant can also compile your application
ant can deploy your applicaton
ant can win you girls.

Step 5 : Get adventurous

Incorporate hibernate
Try doing some AJAX stuff in your app - its very very easy - and might give you the edge in a job hunt


Step 6 : Next step

Having a fair knowledge of Java, Struts can get you a entry/medium level developer position. To go to the next step you can explore the following areas :

EJBs - Great concept but bad reputation - Read Head First EJB.
Design Patterns - Get to know Factory pattern, Command pattern - my favorite and the rest - Read Head First Design Patterns book.
SOA, Web Services - These buzz words are picking steam this year - find out about them and arm yourself for that curve ball in the interview.

If you have specific questions, email me or post a comment here and I will be more than happy to respond to your question.

Good luck and welcome to the world of Java !!