So I've been working to understand the Java code I need to extend at work. And it's quite a bit of culture shock after being a Perl Hacker for the last... well, a long time. I've done Perl in some capacity now for over nine years.

Java folks love abstraction. Thanks to Kasia's blog entry on Interfaces, a bit of chatting with her, and reading up a bit, I now get interfaces. They're Java's answer to multiple inheritance. The provide a contract of sorts between various objects. And object that implements interface foo must provide (at least) all the methods defined in the interface. It's enforced at the language level. Very good.

The downside is that folks can get carried away, building so much structure that the real workings of a system end up obscured and hidden behind so many layers of indirection and abstraction. It makes my head hurt a bit. I've spent a bit of time manually drawing out some inheritance diagrams (anyone have a free tool to automate it) based on reading the code and associate javadocs.

I suspect that once I get my head wrapped around all the interfaces, I'll be far more productive and have a real understanding of the system's design.

The other thing I've noticed is that Java folks are big in infrastructure and re-usability. Really big. I'm starting to wonder if I'll ever see code that looks like someone wrote it to actually get some work done--without much regard for the random person who might want to sub-class it someday, maybe.

Don't get me wrong. This isn't bad, but it sure is different. It takes some getting used to. Instead of learning a new language and gradually putting it use, I'm forced to also learn several large frameworks along the way. It's a bit of a double hit. I feel like I've been thrust into a foreign country where I need to learn the language and function as a useful member of society--once with a lot of unwritten and complex rules that I just need to figure out.

Hey, I could have written about Apple's various MacWorld announcements but it seems like blogspace has that covered very well without me today.

Posted by jzawodn at January 07, 2003 09:04 PM

Reader Comments
# Dave Smith said:

Ah, the joys of Premature Generalization in frameworks. Extreme Programming helps prevent it, but not after the fact.

on January 7, 2003 10:03 PM
# Simon Willison said:

"anyone have a free tool to automate it?" - I've never done any professional Java work, but I have found the class browsing tools in Eclipse very helpful for getting a good overview of a large hierarchy of code.

on January 8, 2003 01:05 AM
# kasia said:

It's really easy to get caught up in too much abstraction in Java. On the other hand, generalizing code can have *huge* benefits later on. It's a judgment call.. and the happy balance between 'understandable' and 'flexible' isn't all that easy to see.

What many people miss is that not every object needs an interface and not every interface has to cover all possible basis.

on January 8, 2003 05:28 AM
# Gavin said:

While I'm not keen on all of XP, one of the ideas I do like is: Do The Simplest Thing That Could Possibly Work

on January 8, 2003 06:03 AM
# ade said:

Try Pasta: http://javacentral.compuware.com/pasta/
It's free, as in beer, from Compuware but it shows you the package structure and class structure in a nice visual format.

on January 8, 2003 07:32 AM
# Morgan Deters said:

You may also want to check out http://www.dmst.aueb.gr/dds/sw/umlgraph/

I've used it successfully for understanding a few inheritance hierarchies in the past.

And Graphviz (required for the above) is a good tool to have around anyways, IMHO.

on January 8, 2003 02:06 PM
# Vijay said:

For automated documentation generation (including a nice class diagram), see doxygen, http://www.doxygen.org

Also, if you're an emacs guy, I think the jde mode will help you too.

on January 10, 2003 03:55 AM
# Rob S said:

"Java's answer to multiple inheritance." ... did u mean Java's answer to polymorphism?

on January 10, 2003 04:45 PM
Disclaimer: The opinions expressed here are mine and mine alone. My current, past, or previous employers are not responsible for what I write here, the comments left by others, or the photos I may share. If you have questions, please contact me. Also, I am not a journalist or reporter. Don't "pitch" me.

 

Privacy: I do not share or publish the email addresses or IP addresses of anyone posting a comment here without consent. However, I do reserve the right to remove comments that are spammy, off-topic, or otherwise unsuitable based on my comment policy. In a few cases, I may leave spammy comments but remove any URLs they contain.