“Oh yet another new framework that solves an non-existing problem”

Design patterns drawn into ridiculousness

I am quite an avid reader on Hacker News and almost everyday I notice a new web frameworks popping up. The big thing in web frameworks nowadays is apparently to implement as many design patterns as possible. Everything should be as loosed coupled as possible.

Imagine that you need to instantiate an object.
Let’s call it Shoe.
Maybe we need factory that builds custom shoes with given parameters? So we decide to create a Shoe factory. But to be fair..  That is how you produced shoes yesterday.
Let’s say “What if we need a custom made shoe factory?” Creating a factory that creates custom factory shoe factory enables us to create a shoe factory which creates shoes in just that part of the program. So we create a Shoe Factory Factory.  And it gets even more sillier.

My point being
is that a lot of web frameworks tries its best to please it’s own developers. To be efficient in one certain web framework today, you need around a year to dig into it. First to understand the thought process behind. Just to realize the grandeur in the clever idea of implementing a (for instance) ShoeFactoryFactory pattern into their framework.

Another point is that when I read why the authors of the framework have implemented several of their “feature” (which includes a lot of extra work for the developer) is that it’s covering a scenario that is very unlikely to happen. One reason was “What if the customer wants to switch out their entire database?”. I have yet not known this to happen in my 12 years as a  programmer. Maybe because I’ve been using databases that are open source and free to use? None of  my clients has ever known about what database lies in the backend and couldn’t be less bothered. Most of the clients call the entire application “the database”.  As long you have a web application that can export the data to XML or JSON you’re in a good place.

Global space – should be dead space?

I also never understood the big fear about using the global space. I know why you should avoid it. It’s never smart to have a huge collection of data in the global space. It complicates the code a great deal. The global variables were later replaced by objects implementing the singleton pattern, which is that you have one object you can access from everywhere and access it’s data. This of course became heavily misused, and created a lot of mess.  So “service providers” were introduced with the same problem but with even more encapsulation, but it’s still “global space”

It’s my belief that you always at some point have the need to access global space in web development somehow. It doesn’t really matter which methodology (singleton, service provides or global vars) you use, only use it smart and as little as possible. I fully agree that the fundamental thought about keeping data in global space is bad, but if it solves a problem which would overcomplicate the code, I would just say: Go for it!

Tagged with:

Leave a Reply

Your email address will not be published. Required fields are marked *

*