What We Mostly Use in Java
Ok, I haven’t written any tool to scan entire worlds Java code to find out these syntax elements. But definitely, all of us have gone through thousands of lines of good and bad code since we learned this language – Java. Not only me but all those who call themselves as Java developer have traveled along with this language in its journey, which started long back with a tag of platform independent object oriented language to the recent versions where everything is getting annotated. It is not just a tag but a truth that Java code is portable. This is also true that this language has got enough features to call it a rich language. If not, it would have vanished long back, and would not have created such a huge community of users. Bottom line is – which is nothing new that I am telling you – it is a good language.
Ok, let us come out of the appreciating manager mode and focus on reality. Have you ever checked what do you mostly write in your Java code? What contributes to up to 80% of your code? Open any application source code and you can see yourself.
- Un-Conditional Love: Yes, you and I both know, hundreds of conditions hit us in a day, and interestingly we successfully take decisions based on those to live further. Same thing continues in Java code, ifs and buts, I mean else, keep jumping here and there to present our conditional mind dump.
- Catch me if You Can: try- catch –finaly is what we write for everything where we are sure of something going wrong. Yes! we are sure that there can be an exception, then we have this catch block and the code gets filled in with try – catch and hundreds of exceptions, call it checked, business and what not.
- Cast Away – All that we want to do it cast the objects into our types, required types, before operating on them. Hence write generic code and for specific operations cast them down.
- In the Loop: Simple, to repeat what you just did, loop it. May be for, may be while or sophisticated variants of these two, but we can’t avoid looping as we have multiple objects and repeated operations.
- Lord of the (st)Rings: Strings and strings and Strings all around. Declare, concatenate, substring, compare, condition and finally print, hundreds of string operations clog each application code.
- Bone Collector: Collections to handle same type of objects and in different collection types ArrayList is the favorite one. More freedom can be felt with this collection.
- Eden Log: Where am I in flow, what did I do wrong, what are the values of attributes at this stage, from where I entered, from where I am going to exit, and so many other probing questions are answered using these log statements. Now we are externalizing some of those using aspect oriented programming but still sysouts and log statements flood the code.
Now all those who know java better most of the things which are outside this. Mind you this is just 20% of your program.
If you enjoyed this post, please consider to leave a comment or subscribe to the feed and get future articles delivered to your feed reader.
