Things I Can't Say

5 AM July 2, 2004

In the middle of projects, I sometimes find myself in despair over the quality of the code that surrounds me. Obviously, the right response is not to have a whinge, so I don’t always ennunciate my frustrations.

Right now, though, I’m working on a project with just one other developer – a developer who thinks before he codes, and understands the implications of the code he writes. Everything is just peachy, so it’s a good time to share some of the things I’ve wanted to say previously, but couldn’t…

  • Just because you found it in a pattern book, doesn’t mean that it is good, or appropriate. I’ve yet to see a proper use of the Visitor pattern that wasn’t coded by an evil genius, the majority of Singleton implementations are broken, and the Factory has been irredeemably overused. All things considered, it’s better to come up with your own design, recognise the patterns within it, and only then consult your favourite pattern reference.
  • Just because it is a standard, doesn’t mean that it is good. Shucks, even Sun have turned their back on EJB1.0 and 2.0.
  • JNDI is not always better than a properties file. And even if it was, from where do you get the address of the LDAP server? A properties file, no?
  • If changing a configuration parameter would likely necessitate a change in the code, then that parameter should be compiled into the code. It should not be in a properties file. Duh.
  • Good API design is like good UI design. Most programmers think they’re great at both, and they’re wrong twice over. The “I“s in API and UI stands for “Interface” – not “Internals” – so don’t expose your users to the internals. Understand what your users need to do with your component and give them an interface that lets them do that with as little fuss as possible.
  • RDBMSs are not to be treated as a directory of flat files. In particular, selecting a large portion of a database table and throwing away what you don’t want is stupid. Use SQL WHERE and ORDER BY clauses.
  • Not every application needs a database. Flat files can be as ‘secure’ and and as ‘fast’ as an RDBMS.
  • I cannot think of a single system where the additional deployment and architectural complexity of EJBs is paid back by a reduction in coding time, additional integration friendliness or an increase in performance. Not to say that such a system does not exist, just that it must be rare. Oh, and transparent distribution only works when performance is not an issue.
  • Sometimes cutting and pasting is good. Throw-away code does not need to be an elegant masterpiece.
  • In most situations though, elegance is good. Elegant code is code that can be both understood and modified with a minimum of effort. DRY is a good heuristic, if not taken to extremes.
  • Bad code without bugs beats good code with bugs.
  • Shipping code with bugs beats non-shipping code without bugs.
  • Write code for clarity rather than speed. Please. More problems are caused by complicated code and than “inefficient” code.
  • Choose a design that fits the budget. Better a sub-optimal design that is fully implemented and tested than a beautiful design that is incompletely tested and not properly debugged.

That is all. Thankyou for listening.

By alang | # | Comments (6)
(Posted to javablogs, Java and Rants)

Comments

At 14:29, 02 Jul 2004 Barre Dijkstra wrote:

Nothing to add except: Amen.

(#)
At 18:45, 02 Jul 2004 Joe Grossberg wrote:

I strongly disagree with this one:

"Shipping code with bugs beats non-shipping code without bugs."

I can assure you that this isn't the case for bugs that are serious enough to make "nothing" better than "something":
* security holes
* bugs that erase data
* bugs that send emails to many people

When a client is switching to a new system, bugs are even less tolerable. If some flaws prevent them from doing what they need to do -- and used to be able to do with the legacy system -- the shipped code has a negative net value.

(#)
At 01:04, 03 Jul 2004 Keith Pitty wrote:

Glad you got that off your chest, Alan! And, as usual, you raise many thoughtful points.

I do, however, I agree with Joe. Perhaps your edict could be qualified as follows: "Shipping code with bugs, provided they are not severe, beats not shipping code without bugs." It is a question of judging when to ship.

(#)
At 15:15, 03 Jul 2004 Alan Wostenberg wrote:

Bugs always reduce the value of software.

(#)
At 23:29, 04 Jul 2004 Pete wrote:

Ah! Pity the poor patterns! I am continually saddened by the apparent understanding that patterns are something that are added to code.

I've always believed that patterns represent what is already in the code - they just need to be recognised.

Given that, I agree with you, Alan - when you see someone trying to "add" patterns into a system - that's a sign of a problem beginning to happen.

Cheers.

(#)
At 22:22, 05 Jul 2004 Mark Ziebell wrote:

Alan, will we see any more posts on this topic? ... I'd hate to see a pattern emerge...

(#)

Add Comment




(Not displayed)






(Leave blank line between paragraphs. URLs converted to links. HTML stripped. Indented source code will be formatted with <pre> tags.)




© 2003-2006 Alan Green