Tuesday, July 31, 2012

Catalyst done wrong

     Perl fans enjoy their language because it allows them to be
     expressive. As such, for better or for worse, we aggressively
     defend our right to do it our way. One place where this
     attitude should be left at the door is with frameworks such as
     Catalyst can easily be thought of as an easier way to make a web
     app. while this is certainly true, it is more accurate to say that
     it is a means of delegating basic web application architecture
     decisions.  The delegation of directory and namespace structure
     and these built in methods certainly make things easy, but the
     fact of the matter is that this is a mere side-effect.

     This is important because these architecture decisions are made
     for a reason; to separate the logic, database, and markup. While
     this is certainly not everyone's cup of tea, it allows one to
     focus on one of these fundamental components at a time; and keeps
     us from asking that age old question: Is that stray quotation
     mark coming from the html, the query, or my Perl?
     Unfortunately, I keep finding myself working on Catalyst code
     that for one reason or another decides to re/undo some of these
     architectural decisions.

     For example, I've seen cases where people decide that that they
     should slice some logic out of the controller and put it into a
     new directory.  They put it at the same level as the model view
     and controller. This always seems to over-compartmentalize the
     code. The caveat of mvc is that you have to manage your app in
     three different places. Why do I need a fourth?

     Then they create libraries the way you would in an intro to Java
     class where a class is a noun and all of the actions it performs
     are verbs.  What results is a cancer that grows out of control.

     As the application slowly metastasizes, The library names don't
     match the database tables and there are always more and more
     excuses to create more mvc inconsistent modules. The result is an
     undocumented abomination that lacks the consistency of the rest
     of the application

     Developers who do this aren't awful for doing this. On the
     contrary, they are applying well accepted best practices to their
     creations. They want to architect their own application; which
     doesn't work so well when the application you are working on has
     already been architected. So if you are working on a catalyst app
     and you find yourself wanting to try any of the above, do
     yourself a favor; choose a more flexible framework or roll your