Over a million developers have joined DZone.

10 Things I Never Want to See a Java Developer Do Again

· Java Zone

Microservices! They are everywhere, or at least, the term is. When should you use a microservice architecture? What factors should be considered when making that decision? Do the benefits outweigh the costs? Why is everyone so excited about them, anyway?  Brought to you in partnership with IBM.

Curator's note: Andy is the CEO of OSI (Open Software Integrators). He's a forward-thinker and exceptional blogger.

William F. Buckley, Jr. once said, “A conservative is someone who stands athwart history, yelling Stop, at a time when no one is inclined to do so, or to have much patience with those who so urge it.” I don’t know much about that, but I want to yell, "Stop!" at the hordes of Java developers doing any of the following -- or when I’m forced to do them.

0. Traverse a resultset and construct an object

while (result.next()) {
 String name = result.getString(“name”);
 String address = result.getString(“address”);
 String email = result.getString(“email”);
 String phone = result.getString(“phone”);
 stuff.add(new AddressEntry(name,address,email,phone));
So if you’re a hipster-developer, and not a professional, obviously ORMs are bad because you read it in some blog by a developer who once had a “performance problem” with Hibernate.  Hand coding this “obviously” makes it “better”, but surely you can use JDBCTemplate or something.  I’ll stick with JPA/Hibernate though thank you (cue the clueless flaming).

1. Write PL/SQL on a transaction system

Over time, your business logic will move into the RDBMS.  Your beloved device transaction will move to the database.  Someone will turn this into something resembling COBOL and tied to triggers that call other flattened out versions on a materialized view.  In other words, in a short period of time you’ll have the ultimate intractable legacy system.  This is good news for Oracle investors, but what is good for Oracle is bad for the rest of us.

2. Write/debug or even use a Swing application

For years I thought I was so horrible at GUI code that I should never touch a front-end.  As it turned out Java should never touch the front end.  Swing is slow.  Yes you can make fast Swing code if you’re Sun and writing NetBeans and don’t have to worry about browsers and can pour a lot of money into it....but Swing is slow.  It is also unpleasant and makes GUIs that by default look like a cartoon about native GUIs.  Then there is Java’s sandbox model...

3. Cast

Java Generics is not perfect or even the solution to the problem I would have preferred.  There are the occasional edge case that Java’s Generics can’t handle efficiently...

That said, I really don’t want to
Foo bar = (Foo) FooFactory.get(“bar”);
ever again.  Unfortunately, there are libraries that haven’t gotten the message and there is always legacy code, but let’s all be good little boys and girls and eat our vegetables, write unit tests and use generics.

4. Do date calculations with Calendar or Date

Life is too short to deal with complicated date/time calculations using the JDK Date and Calendar classes.   The built-in classes provide only the most primitive operations and are everything except intuitive.  Use a modern library like JODA Time.  Unless you’re the type who writes webapps in x86 assembler, in which case you might enjoy doing date arithmetic using the JDK Date and Calendar stuff.

5. Configure Session Replication

It is not 2000.  All of the distributed cache products and projects have rebranded themselves as NoSQL Key-Value stores.  Let’s use AJAX/Javascript if we need stateful clients and not use HttpSession for...anything.  This will make for highly reliable scalable applications that we can all enjoy and no more deep dark marshalling exceptions that go bump in the night.  Don’t get me wrong, this was a fun time, it bought my wife a minivan (I prefer my Ninja 650), but now it is time to make better, faster and smarter stuff.

6. Write a sort algorithm

Most of the horrible, I didn’t pay attention in algorithms class, sorting code is written by people that also didn’t notice that Java has the sort algorithm you need (or there is a third party library somewhere with your name on it) or they just didn’t notice how Comparable and Comparator work.  Go forth and read that now and commit the sin of self-sorting no more.

7. Write my own Linked List, Stack, Queue, etc

Admittedly writing a basic linked list is pretty durn easy.  Wikipedia has a nice page (http://en.wikipedia.org/wiki/Linked_list) on linked lists with the code and all.  So yes, I could cut-and-paste, but why?  Maybe I’m just lazy, but I prefer using a data structure that has already been through the testing ringer.  No actually I am lazy, I go to great efforts to remain so.

8. Write my own pool, collection or general concurrency code

Know Doug Lea.  Love Doug Lea.  Be one with Doug Lea’s java.util.concurrent.  Doug Lea is not a mere mortal he is a highly parallel being capable of thinking the solution to any concurrency problem before you do. 

9. Deal with logging frameworks

How do you spell a word that means all of Commons logging, SLF4J, etc: S-U-C-K.  Sun caused this problem by not just taking Log4J’s interface into the JDK years ago.  Oracle could help fix it by making java.util.logging not suck.  That said, I’d rather everyone standardize on the suck that is java.util.logging than another person come up with another “brilliant workaround” for allowing us all to have “logging choice”.  “I’ll have a Coke”  “Is Pepsi okay?”  “Whatever, they both make you fat, what’s the difference?”


Discover how the Watson team is further developing SDKs in Java, Node.js, Python, iOS, and Android to access these services and make programming easy. Brought to you in partnership with IBM.


Published at DZone with permission of Andrew C. Oliver. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}