Sunday, 8 June 2014

MVC Frameworks - CakePHP a quick Evaluation

A real project always throws up more issues than following the tutorials, I find that you not only tend to learn faster, but to a deeper level.

To try and evaluate CakePHP I made up a simple application. This was a simple car database to allow direct comparison of different makes and models comparing the following characteristics:

Price, Seats, 0-60 MPH time, MPG, Age, Road tax.

Within an hour of downloading CakePHP I had a working create, read, update, delete (CRUD) application. After 2 hours the filtering of the available fields to restrict the list to various required maximums or minimums and 20 cars details were manually entered. The application was essentially built working and tested to a basic level in 2 hours with 200 lines of code.

The real advantage though was those 2 hours were not hard pressed programming, it was a relaxed pace, and I am unsure without a framework I could get a CRUD application to the same level without a reasonable amount of planning time.

The framework does force you to work in a specific way, but brings in a number of advantages.

Less Code Required

Yes the framework overall will almost certainly have more than a basic CRUD application, but I only wrote 200 lines, which included all display code, I doubt that anyone could achieve similar functionality in the same amount of code (obviously unless they "cheat" and have multi-statement lines, single line loops etc...)

This brings the sub-benefits of:

  • Higher quality code - The less you need to write the easier it is to maintain concentration on higher quality easier to understand code.
  • Fewer bugs - Every extra line invites the possibility of error, either logical or even simple spelling mistakes.
  • Reduced maintenance - Fewer lines to read means more time spent fixing an issue and less time finding it.

More code reuse

The framework will contain methods and helpers for common coding issues, rather than re-writing these simple methods, or possibly worse writing lots of semi-duplicate methods throughout your code because you lack the appropriate planning / refactoring time.

Pattern Guidance

When you approach a new project you can tackle in a multitude of ways, a framework can help take a consistent and proven methodology to solving the issue and significantly reduce planning requirements.

Performance

While raw performance of applications may be considered an issue CakePHP has a number of built in performance indicators and actively helps you spot performance problems before they have impacted on your users. My application was perhaps too basic to demonstrate any potential scaling issues, but there is certainly plenty of control over the code to prevent performance being a likely blocker to the implementation of CakePHP in a project.

1 comment:

RNInterSystems said...

Andrew

First of all, please contact wrc.intersystems.com whenever the behavior of Caché surprises you. You definitely will be surprised by the helpfulness of our support advisors and we'll all do our best for you to have the predictably best behavior from your system.

Secondly, Caché is not unique in having behavior that, at first glance, is surprising with (for example) indices and NOT EQUAL where clauses. (Try googling "ORACLE NOT EQUAL INDEX")

Thirdly (and I feel sort of lame saying this) running Tune Table (http://docs.intersystems.com/cache20141/csp/docbook/DocBook.UI.Page.cls?KEY=GSQL_optimizing#GSQL_optimizing_tunetable) will improve SOME of the behaviors you're seeing. [I feel lame because we pride ourselves on minimizing the tuning needed for Caché systems and yet we don't (re-)initialize some of the tuning parameters automatically. Shame on us but stay tuned (ha, ha !!)]

I'd prefer not to get into a lengthy explanation of how you can improve the plan used (and why) for the different cases you cite. There are relatively easy steps to take for most and easy-to-understand explanations. Give us a call.

RN