Does your bad Java code need help? (from Rules and Flow)

by Paul Browne

Picture the scene: a self help group meeting, plastic chairs arranged in a circle. Sitting on the chairs are an assortment of (mainly) men in their 20's or 30's, some smartly dressed, others with 2 day old beards. They fail to look each other in the eye, until one plucks up the courage and mumbles 'Hello, I'm Paul , and I've been writing bad Java code for 10 years'.


Taking a deep breath he continues: 'When I got into Java I was using JSP for everything - HTML, talking to databases, doing workflow - anything I could get my hands on'. Seeing the shock on his comrades faces he adds 'I was young and I didn't know what I was doing'. 'Then I found Struts and MVC and things became a little bit better. My days had a bit more structure, but things didn't seem right. Even after I got treatment based on EJB, Spring and Hibernate, I still feel that there is a void at the centre of my coding life'.


The rest of the group nodded - This was a classic case. 'I fell in with a bad crowd. Business types with suits and violin cases. They said they'd pay me good money if I built them something just like they asked. Now they don't believe that it works - it's all techie stuff to them. Those boys are going to play rough if I can't show them the goods and let them review the code. What can I do?'


There was silence for a while. Then the group leader said

You need to build a system where non-technical people can review the important parts. You've used all the major frameworks, and while they're good in what they do, they're not helping here. And if you sacrifice maintainability , performance or speed of development, the suits are going to get you.

'It's a tough one. Does anybody have any suggestions?'



What would YOU suggest?



10 Comments

Scott
2007-10-02 07:47:22
The title of this article has almost nothing to do with its content. Is this an article or an advertisement for 'Drools'? Pure crap.
Paul Browne - Technology and People
2007-10-02 07:53:14
@Scott. Thanks for your opinion.


Given that the article advocates using Business Rules to restucture possibly (bad) Java code and make it clear to non-technical users, can you let me know where the mismatch is?


Yes, I'm passionate about JBoss Drools, and make no apology for promoting it's use where (and only where) it is of benefit.


What would you suggest as an alternative?


Paul

Scott
2007-10-02 09:58:05
@Paul


Sorry for the 'crap' comment there, I felt I had been mislead and my time wasted.
Here's a suggestion for the title:
Does your bad Java code need help? Consider this brief JBoss Drools tutorial.

Er
2007-10-10 08:57:14
The premise is bizarre. In what world do nontechnical suits conduct code reviews?


"So suits will like how the code looks" may be the worst justification for choosing a technology ever.


If you are unable to convince your suits that your system meets the required functionality, that's a different problem.

Paul Browne
2007-10-10 11:54:32
@Er


Not so bizarre. When your code goes through User Acceptence Test, what are the suits doing but (indirectly) reviewing your code by testing that it does what they expect it to. You do do UAT , don't you ? :-)


Most Agile teams would agree that the sooner you catch bugs the easier / cheaper / quicker they are to fix. What could be quicker than showing the suit 'here are the rules in the application that I've just done - are they what you expect?'


Better than waiting for 3 months until it finally gets around to user test *or worse* slips through to production and you're trying to patch the holes in a live system.


That's my experience anyway. Your mileage may differ.


Paul


2007-10-12 13:02:28
"Nontechnical suits"???


Are there any other kind of "suits"???


;-D

JavaGalaxy.com
2007-10-16 02:46:06
This is a good article. I wanted to add one more point here, writing good code doesn't mean the code quality is good. You haven't mentioned anything about javadoc. Providing java doc to your code will also help others to understand what your code would want to achieve.
Cody
2007-10-26 11:38:29
I have been searching vigorously for an introductory article into Drools, and so far this article is the closest thing to one that I've found. As an entry-level developer I think that the article is very well written. I am learning each day the rules of J2EE and why each one is beneficial. The use of Drools gives developers even more flexibility in writing their code. This is especially significant when it comes time to maintaining applications. Nice job Paul.
Paul Browne - People and Technology
2007-10-27 13:24:14
Cody,


Thanks for the compliment. This blogpost is based on some of the documentation I wrote for the JBoss Rules guys (just the doc, the actual tech sample was already there). More Samples are available at the JBoss Drools site:
http://downloads.jboss.com/drools/docs/4.0.3.15993.GA/html/ch10.html


On this site (OnJava - OReilly) Birali Hakizumwami has written a very good article on Enterprise Services with Drools http://www.onjava.com/pub/a/onjava/2007/01/17/building-enterprise-services-with-drools-rule-engine.html.


There are 2 other articles that I wrote for this site - I don't consider them as good as Birali's as they use the older Drools 2 (xml) syntax, but most of the concepts are the same:
http://www.onjava.com/pub/a/onjava/2005/08/03/drools.html
http://www.onjava.com/pub/a/onjava/2005/08/24/drools.html

Leo
2007-12-03 05:27:53
Does your bad Java code need help? Consider this brief JBoss Drools tutorial.


Agree.