Friday 5 October 2007

WTF!

WTF is a site that I read regularly as a form of entertainment. It's funny to laugh at stupid code. We all do. Some of it we could see ourselves having written in another time or another place.

A recent post by Alex Papadimoulis has made me lose a lot of respect for the cynical, smirking moderator of the site.

The post discusses "The Mythical Business Layer" in a three tier architecture. The other layers are the "presentation" and the "persistence" layers. In particular it makes comments about this being a "fairly broad term" and "If you think about it, virtually every line of code in a software application is business logic". The article continues on to explain why the author believes this.

This is what I strongly disagree with and I have a few reasons why. The statement above is the same as saying that all data used by an application is business data. This is not the case with meta data which is data about data. In the same way there is logic in an application that is not related to the business domain:
  • It can be more conceptual like defining how to render output in different formats like PDF, HTML or XML;
  • Propriety database indexing that is implemented in code, in order to allow faster access to large data tables; and even
  • Generic workflow infrastructure that allows many applications to specify the path through a scenario. This may not be specific to the particular business rules being implemented but assist in allowing this to occur without the programmer having to redesign the wheel.
Programmers use these concepts daily and they are independent of the specific business being implemented.

The idea of a business layer is not one big blob of code in one class or an overly complex component to do the job. The business layer is a conceptual layer that can be implemented in different architectures through services in SOA, modular decoupled components in a COM based architecture or even RESTful services.

The author uses the following quote from another famous Michael Jackson to argue his point:

"Programmers… often take refuge in an understandable, but disastrous, inclination towards complexity and ingenuity in their work. Forbidden to design anything larger than a program, they respond by making that program intricate enough to challenge their professional skill."

What he should have also discussed is the idea that oversimplification in code or to argue your point is also a habit of programmers, who are people who like to deconstruct things. A fabulous example of this is the summation to this post that presents in a matter-of-fact manner "The Ideal Approach" arguing that simple code is not fun but it is the best way to do it.

I've been doing this a while and in my opinion, simplicity is beauty. Anyone can obfuscate their code to kingdom come but a good coder just lays it out. I agree with him in some ways. However he has misinterpreted the idea of a Business Logic Layer. Often the BLL contains generic code and even the more complex parts of the application's code and this is justified. It uses third party libraries and internal libraries which are general and useful.

!("every line of code in a software application is business logic");

I think I'll stop reading WTF today. It's all crumbled around the naivety of the guy in control. Maybe as programmers we shouldn't be overly complex but maybe simplicity also misses the point once in a while.

1 comment:

Anonymous said...

Nice post Damana. FWIW, I stopped reading Daily WTF a long time ago :-)