Monday, March 23, 2009

Paul on Joel on Software

Joel Spolsky is doing some bashing of SOLID Principles here :
 ....just to give you one example, a part of the SOLID principles was that if you write a class, that class has contracts with all the other classes that it interacts with, and those contracts should be expressed in interfaces [PDF]. So you shouldn't just interact with the class, because that class may change. If you have a particular class that you need to use, you should make a custom interface just for what you're going to use in that class. That interface, then, never has to change. And the interface is the only thing that you have to #include.
People that say things like this have just never written a heck of a lot of code. Because what they're doing is spending an enormous amount of time writing a lot of extra code, a lot of verbiage, a lot of files, and a million little classes that don't do anything and thousands of little interface classes and a lot ofrobustness to make each of these classes individually armed to go out into the world alone and do things, and you're not going to need it. You're spending a lot of time in advance writing code that is just not going to be relevant, it's not going to be important. It could, theoretically, protect you against things, but, how about waiting until those things happen before you protect yourself against them?
Hear, hear!


  1. Oh double hear, hear!!!!

    The shop I work at makes me write EJB remote and local facades and delegates with interface classes to make sure all the methods in the contracts. Never mind that we're never, ever going to factor the EJBs and the EJB clients, I'm not even sure what practical benefit the interfaces have. After all, their written once and only used twice: once for the local facades and delegates and once for the remotes, which as I said will NEVER get used.

    My friend and colleague was out of town for a few days so I couldn't ask him for the help I usually ask him for. While talking to the other developers It turns out that despite this "policy" no one EVER writes the remote delegates.

    When my friend got back he admitted that he knew this, and as far as he's aware, he's the ONLY PERSON who actually writes the remote classes.

    When I asked him why on earth for, he said to think of them "like an insurance policy, in case we ever need them".

    I think I looked at him like he was insane and in a controlled voice said "Look insurance works like this: you pay say $100 in premiums and if things go bad, you get a $100,000 pay out. What you're saying is pay $100,000 now, and in case things go bad, we'll give you the $100,000 back."

    He actually saw my point.

    - GL

  2. P.S. nobody ever writes the interfaces either :-)