Monday, 30 July 2007

Pattern overkill

In my previous entry I've written about abstract factories. I've written how to choose a specific concrete factory. So that's a strategy, isn't it? It wouldn't be correct to use a single strategy; you should leave the door ajar to use different strategies, so you should use an abstract factory to create these strategies...

And that's when you become the next Iran since a fly is near, you need to kill it, and a nuclear bomb is the sure way to go (a cockroach would be a different issue, though).

Joel Spolsky called this Architecture Astronauts. Daniel Alonso said "If something is simple, just do it". Of course, talk is cheap; I have to do a full disclosure: sometimes I've done useless patterns, just for using patterns' sake. I guess every programmer does the same from time to time, and somebody who has just learnt patterns does it all the time. My latest example is that I've created an abstract factory, with a complex class hierarchy for instantiating 16 different types of objects from an "Indestructible" database, so I can easily add new classes whenever they add a new object types. Which last happened in 2001.
In a related note, a building from a Spanish electric utility has its floor numbers projected, instead of using copper numbers. I guess whenever they want to add a new floor between two, it's one less thing to think about.


Add to Technorati Favorites

Friday, 20 July 2007

People with too much time in their hands...

...do different things:
  • Manually backup all of their mobile phone book entries because they don't have the cable
  • Read and clasify all their mails
  • Add a blog entry about people with too much time in their hands
Add to Technorati Favorites

Wednesday, 18 July 2007

The Willy Wonka abstract factory

I think for the time being I have said everything I have to say about outsourcing. So now I'll leave this controversial topic and start writing a bit about software patterns. So, if you are not so technically oriented, it will be boring for a while.
One software pattern I find extremely useful is the abstract factory. I think polimorphism is only really useful with abstract factories. However, there is a point where you must chose one (and only one) concrete factory. How do you choose?
One strategy I found useful is to use a map between a key and the constructor or the key and a structure containing the constructor. As you can see, all the constructors or structures are very similar, just like Oompa Loompas, and that's why I call this decission strategy the Willy Wonka.
The advantages is that only declarative code needs to be added to add new classes, so bugs can hardly be introduced

Add to Technorati Favorites

Thursday, 5 July 2007