When I were a lad... Generics - are - good .... rant?

Still feeling old, but code wise now. I've just been accused of forming an opinion based on being set in my ways. For the first time I had to consider whether that was actually the case.

I'm not a generics fan, some people might already know this. I use them alot for work and today I spent some time refactoring some code to make use of them and saved alot of effort. Thats great! I still think using generics because "it makes the code look tidy" or "removes a lot of casting" is a pretty crappy reason to add their complexity to the code base. If you're using a collection thats supposed to have specific things in it, chances are that collection represents something significant. As such it should be part of your data/oo/design model - and hence probably should be represented as it's own class. It's really that simple. That way all the casting and/or generic handling is hidden away inside that class - way more flexible, analogous to why event objects make sense. As always, it's about playing to the crowd. If you're sure your code base maintainers and users will get everything you're doing with generics - and you're sure you're not shooting yourself in the foot, it can't be bad!

Today, I did learn to like generics when used for something interesting. The downside is that the syntax for that use became unwieldly and to most Java code formatting sycophants ugly.

So, Generics forever! etc.


But really, thats just a side issue, I had to consider whether my initial dislike for generics came from being stuck in my way. Hmm.. maybe a bit? How to test it? Let's look at technologies I've considered over the last few months:

JSF+EJB - Jury is still out for me, haven't used it enough. The technology is sound, the front end is a bit error prone for my tastes. It's way over weight for a simple web access to a underlying service but for something more enterprise in scale, i.e. where the logic is really in the EJBs I think it probably makes sense.

AOP - Definitely a winner for me this one. Aspects are interesting topic that I've only really just started to get used to. Every time I consider them as an approach (which isn't that often, they don't fit everywhere after all ;)) they solve so many problems. Though the downside for me at the moment is the frameworks for AOP seem complex and intricate to integrate into most of the stuff I do at home.

Java Annotations - Again, awesome cool. I'm constantly finding uses for them from conventional access and persistance meta data to intergrating scripting languages by generating proxy objects based on annotating the target java class. Nice.

IoC - Injection is cool, there is no doubt. It's a really useful tool in some cases. However, I do think the majority of developers have been using the concept of IoC a lot longer than the current crop of buzzy frameworks have been around. I'm also not a fan of sticking the configuration for injection out in compile time excluded files. However, that'll probably get better with more IDE support.

JBossMC - I hated this initially. A POJO Container! Whats the fricking point? Why would anyone do that? Actually, it's neat as a 5 year old on the first day of school. It's a great basis for any container based server, I'm actually wondering about starting a game server project based on it, kinda Project Dark Star lite. JBossMC + JBoss Cache make a powerful combination.

Right, they're the ones I can think of. Written stright out without thinking about it. I think I'm pretty open to new techs and approaches. I don't fear change (much).

I also don't think just because something is new it has to be jumped on and used ASAP - especially not in a commercial environment. Which brings me on to something else, projects that die.


A project that stops development doesn't become useless instantly. Infact, it never does. If Java was stopped tomorrow, we'd all still have the Java toolset and VM. We could continue to developer software just fine. If it was closed source, it's more of a problem because there arn't any bug fixes possible (see GTGE recently) - however, open source projects that stop development for a bit, or even forever, don't die unless the users flake out and don't pick up the slack.

If a project is useful, it's useful. Evident in FScript which is proving fantastic for my gaming needs and hasn't been touched since 2005!

Reply

*
*
The content of this field is kept private and will not be shown publicly.

*

  • Lines and paragraphs break automatically.
Verify comment authorship
Captcha Image: you will need to recognize the text in it.
*
Please type in the letters/numbers that are shown in the image above.