Using MySQL INNER JOIN in CakePHP Pagination

First of all, I've got to hand it over to Matt he really did a BBBIIIGGG favor to the CakePHP community by publishing his guide to advanced CakePHP Techniques. This guide / book will give a great insight into the framework to anyone who is a seasoned programmer and is picking up Cake for the first or so time. And I'm going to be floating ideas to compliment the advanced techniques and all in all promote good programming practices of what I'm aware of.

Now, I've seen a lot of shitty code when it comes to CakePHP. Yes, I've even seen mysql_query() calls in views ! ... yes, I've lived that day and kept my sanity in tact. But I can't blame the programmers too because obviously they were newbies and were under a lot of pressure to "get things going" by their blood sucking employers. Anyhoo ... this might be the subject of another post, BUT I really had to get it out of my system ... *phew* ... feel so light now :)

So, MySQL INNER JOINS ... when should you use them ? - simple answer: when you want to filter out data in your result set. And it's quicker than filtering out results in the "WHERE" clause. Don't have any metrics to show to support this conclusion right now, but I speak in the light of many tests I've conducted on large datasets. A more simpler theory is that the "WHERE" clause needs to filter out a lot more rows in a result-set obtained as a result of using "LEFT JOIN". CakePHP's logic however is sound to use LEFT JOIN as the intention is not to filter out the records, it's merely to include whichever records belongs to the conditions you supply. That's why it's "Containable" behavior is so cool (special thanks to Felix on that for maturing it and making a part of the Cake's core).

The more you familiarize yourself with Cake's datasource classes the better. The most excellent example was published on the bakery by Nate on how to use JOINs in CakePHP. I think this should be made part of the documentation too. This could actually make you get rid of "overriding" Controller::paginate() function. When you come to know about the flexibility offerred by the datasource class you love it even more :P - a simple example:

  1.  
  2. class PostsController extends AppController {
  3.  
  4. public function by_tag ( $tag ) {
  5. /**
  6.   * This will fetch Posts tagged $tag (say, 'PHP')
  7.   */
  8. $this->paginate['Post'] = array(
  9. 'limit' => 10
  10. , 'contain' => ''
  11. , 'conditions' => array(
  12. 'Post.published' => 1
  13. )
  14. , 'fields' => array('Post.*', 'Tag.*')
  15. , 'joins' => array(
  16. 'table' => 'posts_tags'
  17. , 'type' => 'INNER'
  18. , 'alias' => 'PostTag'
  19. , 'conditions' => array(
  20. 'Post.id = PostTag.post_id'
  21. )
  22. )
  23. , array(
  24. 'table' => 'tags'
  25. , 'alias' => 'Tag'
  26. , 'type' => 'INNER'
  27. , 'conditions' => array(
  28. "PostTag.tag_id = Tag.id AND Tag.name = '$tag'"
  29. )
  30. )
  31. )
  32. );
  33.  
  34. $data = $this->paginate('Post');
  35. $this->set(compact('data'));
  36. }
  37. }
  38.  

This is just a simple example of what you can achieve by adding simple joins in your Model::find() conditions and of course in the paginate part. I've stretched it a bit further. I've actually used sub-queries and sub-joins, really complex stuff when paginating some complex data sets. Thanks to the 'joins' I never had to override the Controller::paginate() method ever. Just for the sake of example, let's say I want to retrieve posts tagged in 'PHP' and 'CakePHP' written by users who have a rating above 3. Of course this can be done in other ways, here is one using a sub-query join in CakePHP elegantly:

  1.  
  2.  
  3. // work this out wherever you want it - in your model or controller
  4. // but if I were you, I'd put this in my model
  5.  
  6. $join = "SELECT posts.id AS POST_ID FROM posts JOIN authors ON (posts.author_id = authors.id)";
  7. $join = $join.' '."JOIN users_ratings ON (authors.user_id = users_ratings.user_id AND users_ratings.rating > 3)"
  8. $join = $join.' '."WHERE 1=1";
  9.  
  10. // in your controller
  11. $this->paginate['Post'] = array(
  12. 'limit' => 10
  13. , 'contain' => ''
  14. , 'conditions' => array(
  15. 'Post.published' => 1
  16. )
  17. , 'fields' => array('Post.*', 'Tag.*')
  18. , 'joins' => array(
  19. 'table' => 'posts_tags'
  20. , 'type' => 'INNER'
  21. , 'alias' => 'PostTag'
  22. , 'conditions' => array(
  23. 'Post.id = PostTag.post_id'
  24. )
  25. )
  26. , array(
  27. 'table' => 'tags'
  28. , 'alias' => 'Tag'
  29. , 'type' => 'INNER'
  30. , 'conditions' => array(
  31. "PostTag.tag_id = Tag.id AND Tag.name IN('PHP', 'CakePHP')"
  32. )
  33. )
  34. , array(
  35. 'table' => '('.$join.')'
  36. , 'alias' => 'FILTERED_RESULTS'
  37. , 'type' => 'INNER'
  38. , 'conditions' => array(
  39. "Post.id = FILTERED_RESULTS.POST_ID"
  40. )
  41. )
  42. )
  43. );
  44.  

And this will elegantly filter out the posts you need :P

Conclusion:  you can really write any kind of a query and really devise a condition based system that would add filters auto-magically. (I will present such a system in another post) - Remember, CakePHP is all about auto-magic ! ... which is actually the culmination of "convention over configuration" so use it to the fullest !

CakePHP Archivable Behavior

Alright folks ... yeh I know I've been out of the picture really long and me blog is looking deserted for real now. Anyhow, I've got a bunch of posts in the pipeline. Thanks to Ahmed of SoccerLens for convincing me to start posting again :).

Enough chit chat ... so the cool thing I bring you here my friends is this Behavior I just baked up for a client. The Archivable Behavior. I love CakePHP's behavior architecture and had Mariano Iglesias's SoftDeletable behavior in mind before baking this baby.

What it does ?

It simply puts the record you want to delete in another table. I see no use bloating my existing table by adding a "deleted" field, especially when it would need to go through this process many times. Imagine, how big your table would get when you simply soft delete a record and it just sits there and is rarely used. I've seen this kind of methodology run into trouble when you are search the table. MySQL has to go through a lot of unwanted, deleted records and extract the active ones, it slows down the search process, especially when you are using UUIDs.

Usage:

This example follows for a Model, say, "MyPosts".


public $actsAs = array('Archivable'=>array('table'=>'my_posts_archives'));

If you don't specify a the table key, it will simply look for the table, 'my_posts_archived'. The schema for the archives table is simple. It's the same as the table my_posts but it has an additional field, my_post_id. You're going to have to create that table yourself. If you're like me and use PhPMyAdmin it should be really simple by going into Table -> Operations -> copy.

Once you're done with setting up the table and attaching the Archivable behavior with your model, anytime you execute the statement $this->MyPost->del($id); it will simply move the record from my_posts table to my_posts_archives table.
You can also use $this->MyPost->unarchive($id); to achieve reverse, i.e. remove the archived record from the archive table and move it back to the main table. As simple as that ! :P

Notes:

I've baked this on CakePHP 1.3.0.0 with PHP 5.2.4. Although this should run smooth on CakePHP 1.2.x too but if you are using PHP 5.3 you're gonna have to make some adjustments when objects are passed via reference in the code.

Download the Behavior

Have fun ya'all ;)

Integrating MediaWiki With CakePHP

Hi Folks. As you might have guessed from the title, I was up trying to integrate MediaWiki with a CakePHP application of mine. Yeah, all hell did break loose while I was at it. As naive as it may sound, I was dreaming something like an API bridge between the MediaWiki and CakePHP. But like I said, it was a dream, and as the notion suggests, "so you wanna build an API bridge between MediaWiki and CakePHP in one night ?" - "DREAM ON SUCKER !" because you'll never find the time and the nerve to do it ... doh !

May be some day, if no one beats me to it, I'd get that bridge up and running. But till then let me explain a nifty way of doing this.

Your best chance to include a MediaWiki with your CakePHP application is via some RewriteRule magic in your .htaccess file. You simply need to specify which URL you want to be pointed to your wiki application. In my case, I simply wanted all http://mysite.com/wiki/ requests to map to /doc-root/wiki instead of /doc-root/app.

I usually don't keep the App folder type of structure in my CakePHP apps but this particular application was an exception. The concept is to:

"read the URL you want pointing to the MediaWiki and change your document root to the folder where you are keeping the MediaWiki"

Now, here is the file structure of my the application I was working on:

  • / < app_name >
    • / branches
      • / sohaib
        • / app
        • .htaccess
      • / wiki
        • index.php
        • .htaccess
        • ....

Say, like me, you want to get all URLs with "/wiki" to be directed to the MediaWiki app, then a small change you'll make int the .htaccess file highlighted in red above would be:


RewriteEngine on
RewriteRule ^(.*)/wiki/(.*) wiki/ [NC]
RewriteRule ^(.*)/wiki/(.*) wiki/$1 [NC]
RewriteRule ^$ app/webroot/ [L]
RewriteRule (.*) app/webroot/$1 [L]

This tells Apache to first look for URLs containing /wiki - and redirect these to to the /sohaib/wiki folder where another .htaccess file awaits the request (highlighted in green above). This file is identical to the one you can find in /webroot folder of your app. You can copy paste this file to your wiki folder.


RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php?url=$1 [QSA,L]

This connects your /wiki requests to the index.php file of your media wiki. And thats it as non-technical as I could be in trying to explain what you can do. I am not going into the exaplaination of the code in the .htaccess files. You'd be able to find good resources via google. But if you're like me, you'll settle for the documentation on mod_rewrite on Apache.org

But let me tell you, this is a very simple demonstration of what you can achieve with mod_rewrite ... this thing is COMPLEX and way too much voodoo, especially when regular expressions come into play. So be careful, it's addictive :P - Hope this helps anyone out there trying to integrate a MediaWiki with their App. Over and OUT !

Free WordPress Themes by WooThemes

I just changed my blog theme to a really cool theme by WooThemes. At last ! I've found a decent theme and got rid of the all-black look I was using to protest my procrastination. At least this one has a simple and fresh look. So these are the downsides of not being a designer. But I find it odd some times. Though I don't design but do I have an eye for it. Wonder which category I'd fall into ? - Some kind of warp zone between a design itself and a designer ... huh ?

I've gotta say, these guys have some really excellent themes. They are giving away some themes for free, I suggest you try em ! ... these guys got talent :P - And also check out thier premium themes, they're really worth it. Hope you like em'

Here is a list of the free themes as of Thursday, April 16th, 2009:

Irresistable

irresistable

Blog Theme

blog-theme

Snapshot

snapshot

The Premium News

the-premium-news

Typebased

typebased

Technorati Profile

Wall Street And Auto Industry by Calvin & Hobbs

So I received an email from a friend explaining the plight of Wall street and the auto industry in a nutshell by Calvin and Hobbs. And this was published about 15 years ago !

calvin-n-hobbs

Why Avoid The “else” Construct ?

Till now I have seen a fair amount of code, the good, the bad and o yes! the ugly and the really really ugly. Ok, so you are a programmer, what makes you think a chunk of code is "good" or "bad" ? - I haven't had the opportunity to discuss this with fellow programmers in detail, so I think the best way to air this would be to document this.

First thing that comes to my mind about good code is READABILITY ... it's imperative the code should be readable and understandable. This however, is automatically achieved when you follow the most optimum way of execution and is even prettier in OOP. Structured code provokes ugliness. And I have noticed that the code gets uglier when there are more and more if-elseif-else construct nesting. I have seen programmers abusing this construct a lot ! You are better off using a SWITCH-CASE construct (which should also be used if and only if necessary).

I know you must be thinking: So what's up with the "else" construct ? and what does this guy have against it ? - Well, in all honesty, I don't have anything against it. It's just that the "else" construct refrains me to write beatiful code :P - Ask yourself, why would you need a lot of else statements anyways ? (do keep in mind that for menu choices you always have the good 'ol switch-case). This may not hold true when you are executing via the structured approach. When using OOP, it just doesn't make much sense. Of course, a simple "if-else" is ok as its simple and readable too. But when you are dwelling into if-elseif { if - else }-else { if - else } it becomes more complex and consequently turns into a nightmare. Imagine yourself trying to debug a 100 lines of code out which at least 40 are consumed by the nested "if" construct. Hehe, I know ! - It scares me too :)

So what does it mean when you have used nested "if-elseif-else" structure a one too many times ? I answer this based on my own code more than a year ago. It means:

1. You are not breaking down problems into smaller chunks, that's for sure! - consequently you have become that greedy Ostrich who swallowed the whole freshly baked potato! so obviously the aftermath is the same. You jump, cry and get frustrated when you need to refactor the code or even worst, debug it.

2. Poor design ! - Yes ! poor design ! I don't care if you agree with me here or not, but you don't have a robust and scalable design before you put your cowboy hat on and went riding that keyboard. You did not think twice before coding. The rationale goes like this: An "if-else" construct denotes a change in variables and you address that change by changing the execution flow. Making the right decisions when a change occurrs. In an OO way, that variable change denotes a "state" change. So you do what you should according to that particular state. Similar to your reactions based on your emotional state,

Happy => Smile || Laugh

, Angry => Frown || Break something || Punch someone

, Sad => Cry || Whiskey++

In OO you can actually encapsulate execution as behaviors according to the change in state. As a result, you design is robust and scalable. All you need to do is invoke the right behavior for the right state. For that you'd probably need a simple IF statement.

3. Obviously either you haven't heard or you aren't interested in the philosophy behind "return home early" - a term coined by Felix from debuggable.com - READ IT as it addresses programming psychology you might make use of.

Doh ! I've run out of time. I'm going to try to put some code slides up. You look at the code and decide for youself.

The Grunts And Groans Of Working From Home

Before starting with me grunts and groans here’s a little note:

To all those who don't have experience of “working from home” try to turn off your judgments while you read. It's a classic example of “you don't know how it's like”. And those who fancy this way of doing business well guess what? you still don’t get to be a slacker.

First off, being human, we have to socialize in some way. For most of us, just having 100+ friends on facebook or any other social network is appealing, but not the real thing. Socializing becomes a challenge when working from home amidst many others. This is the biggest challenge what I have experienced so far, and overcame it too (this part would require a separate post :P). Thank god I don't work alone now. But still, one could rot if one does not step out of the house so very often. To counter this, surely you’d socialize on all those social networks out there, but to get the real thing, here is what I had found useful:

  • - Spend some good 30 minutes outside (and this is for the worst of the introverts out there, it should be an hour or so – no offence). Take a stroll in a park / peaceful place or join a gym. Some fresh air won’t kill ya! But staying inside surrounded by 4 walls will definitely do some damage to your brain.
  • - Try to network up with people who are in the same line of business as you are. And meet up!
  • - Keep an eye out for different events happening out there that are even mildly related to your industry. Try to show up on those. Trust me you’ll feel great when you meet the alike. And probably the best way to do that would be to join a local community.  Finally! You might be able to put all those social networking apps to the right use :P – I’m sure you’d be able to find your local user group through these networks.

Apart of the social issue, here comes another. People don’t tend to take you seriously when you tell them you work from home. This can be frustrating at times. People are still getting used to the idea and some just reject it. This is especially true for countries like Pakistan and I’m sure India’s in the list too. Like many other countries, we both have a family oriented environment and mostly I find people “branding” themselves based on the companies they work in a one too many times. So after having a couple of these experiences, the idea came like a lightning bolt! Yup ! get yourself a business card!, just shrink the “what you do part” in a single understandable phrase. For instance, I use “Software Engineer” that works for me. The funny part is, I’ve experienced that people don’t really understand the “software” part :P they just calm down when they hear “engineer”, which is actually really cool as I’m always giggling when witnessing this. Ah! On the other hand, this always makes me wonder when the hell we are going to get out of this entire stereo-typical behavioral pattern.
The third evil is keeping loose work timings. This can be cancerous to your work! – seriously! Some people may not realize this until after they find themselves in the middle of a crisis. And I had to find this the hard way … doh ! You have to separate your work timings. Sure sure, you must be thinking I didn’t choose to work from home just so that I work strict timings. Unfortunately, to keep professionalism, discipline is important. Can’t say this for sure about designers and the more creative kind but I can say this certainly for programmers. Although, you might be one of those people who are most creative during specific times of day, then you should time yourself according to that. You see this is where working from home comes in handy. You can choose your own timings.
A few things can help you achieve discipline. You can start off by creating a separate email, IM and phone for your work. It’d be easier to discipline your work this way. Although here I would have to admit that I haven’t been able to implement that yet, but keeping in view my plans, I might not need to. Trust me, it’s really important to keep your private and work contacts separate. The next thing you’d know is that your private email is bombarded by client requests and your private phone is ringing so very often with clients on other end and your folks giving you strange looks.
In essence, the important thing is that you should find time and reflect on other important aspects of your life during the day. I think I know now why there is an 8 hour per day work limit. It helps strike a balance between your private and work life. Honestly, when you are working from home you can cross that work limit very easily without even knowing what you did till later. But there are always exceptions. People who are passionate about something won’t stop at nothing till they achieve it. If you’re not that obsessive about something, then you should strike a balance with discipline.
I’m sure my experiences are quite similar with other people. Let me know if there are any differences you find. That would surely help me understand this better :)

“Stealth Programmers” - A New Species ?

Yes! ... while you sleep, there are those who lurk in the dark. Stay in the shadows and make you applications you can only imagine at best. This is a new breed of programmers here in Pakistan. Finally the plague has formed it's roots here. Yes people, STEALTH has come into the Programmer here now. Let me explain how I got to realize this.

So here I was wondering why the hell I don't have a portfolio up even after 2 years ? and suddenly it struck me three times, almost like three speedy pats hitting my back simultaneously, the words "and you'll be like a *stealth* programmer for us". Yes, I recall clearly about 3 clients of mine saying this to me. So what is a "stealth programmer" anyways ? Simple observation reveals that people who wear masks of different companies (some big names like Apple Inc.) are constantly looking for resources. Reliable and efficient resources. People who not only work just so that they earn their kitchen money, but also because they are passionate about what they do. These people are hired by these companies with a promise (technically known as NDAs : non-disclosure-agreements) that they must not reveal their identity and they must not do anything with the code outside their boundaries, may them be virtual or physical, and code them their ideas.

All this commotion about design patterns followed by great frameworks to address them, in most cases, were designed and developed by the "stealth" breed. Authors of languages like Python (Guido Van Rossum) and Ruby (Yukihiro Matsimuto) were stealth programmers. Heck, Linus Torvald had a "stealth" status when developing the Linux kernel. It was this species that lay the foundations of the "open source" community.

Friends, the Stealth virus has officially hit Pakistan. Me, my friends, and a number of "senior" people I know are living examples. And this virus continues to claim people here, as the awareness grows. And I don't think that I'm referring to "free lancers" here. It's a big term, a super class that encompasses "stealth" programmers too.

And it's about time that this "stealth" community should be consolidated in one place. Because most of these people are best of the best in their fields and passionate therefore well motivated. Several companies in the U.S. made use of this breed in the 80s including Apple Inc. and these companies really owe their success to these people indeed. Entrepenuers here can take a hint :D

ESlavery, The oDesk Experience

The first time I saw oDesk I was pretty excited. I liked their system pretty much at first glance. I thought, "ah ! now here's something that can serve us better !" ... you put in work hours and you'd get paid for it for sure, no chance of being stiffed. However, surprisingly, my experience was quite different. I wouldn't put the blame on oDesk entirely, but about 90% would be justified. Its Just that their system is not friendly for the more creative. Don't get me wrong here, but let me layout my specific experience briefly in points:

1. I didn't have much difficulty in landing a client

2. I wouldn't be that judgemental about the guy, but he did one thing that I still don't understand why. He tried to tell me that $2000 a month is a good salary in the U.S. of A. Naturally, I wasn't that dumb to take his word for it. Coz, most of us live in the U.S. virtually. But I chose not to challenge his false claim.

3. So he did succeed in bringing down my rate, which frankly I did just for the heck of it to try the system out. And of course, I told him that once "we are good" with each other, it was going to go up to my desired mark. I sort of wanted to prove my worth to him.

4. When I started working is when I noticed that I worked about 9 hours and the system logged about 6 or 7. It was eating 2 hours straight ! - so I investigated.

5. Viola ! ... turns out, the oDesk's system calculates your performance based on your "keystrokes" ! ... HOW SMART IS THAT ?

6. Anyhow, I tried to talk to my client, who by the way claimed to be a programmer himself. The guy said, "if the system says you worked 6 hours, you worked 6 hours". I don't know, why he was trying to be an a`hole but at that point I lost all interest. I mean, I am in this line of work because I love doing it, not entirely because of money. So naturally, I asked him to spare me the pain.

So in essence, oDesk's system of performance recording is good, BUT only for jobs like data entry etc. Would you imagine that this guy had me "write" down my brainstorming sessions !! ??? .... how the F*** can you write and brainstorm at the same time ? - if you can, then you have a gift ... really ... you do ! In entirety the experience was really annoying for me. After that, since I had a bad experience associated with oDesk, I didn't bother to look back. And thank God I didn't have to either.

Here is what I ask: ** How can you indulge in CREATIVE THINKING / PROCESS when you know that this time won't be accounted for ? ** so in these regards, oDesk is pathetic ! Heck, check the comments of this post and you'll know how oDesk is **bad** for many buyers too. And futhermore, you can go knock yourself out with this google search.

I won't get myself in the "oDesk haters" category ... BUT ... I would consider my self in "prefer to boycott oDesk" kind. Because if I ever pick up a client on oDesk, I would seriously either BILL him based on different milestones OR make sure that we both trust each other so that I can put in offline time and he would authorize it and won't stiff me. Still, day by day I hear about new improvements on how to *track* the employee. And these guys are really pushing it so much that it really sounds more like slavery, or "eslavery" to be exact. (well said by "O Rover" there)

Common sense demands you don't get lost in all the **goodies** marketed by such companies. These guys promise definite pay to the employees and the supposed "power" to the very insecure employers out there so that they could check their eSlave from as many angles as possible. In the end this creates an environment of distrust if you plan to work with more creative individuals. Because the more creative ones WILL take their time to THINK before acting and more importantly they need their space!

It would be highly unlikely to get an intuitive, extendable app unless there is sufficient trust between the employee and the employer. On the other hand, if the programmer drops out in the middle of the project, the employer still has to pay him / her WITHOUT having their work done. And based on these facts I can never agree that oDesk has brought any innovation and / or revolutionized the way of working. They are just using your insecurities to the best of their own interests.

To balance the sarcasm above, I can only do but one thing, and that is to advise anyone planning out on doing business on oDesk to beware, don't get traped in their warp zone of false promises, but lay out your concerns on the table with the client and try to educate him / her that you both are better off trusting each other more rather than the system. Because seriously, the system will make both of you feel like smart asses and un-decievable. Not true in the real world.

Thinking Patterns - Perfectionist huh ?

I have been noticing this habit of mine lately. So I'm working on some code, basically a component in CakePHP and I find my self really frustrated. Obviously reason is the way it's coded. I don't know why but unwillingly I am judging the Author. I might cook up another post dedicated to that subject particularly, something like the "state of mind" of the coder. Basically any experienced developer can tell what the Author of any piece of code had in his / her priority list when coding something. Anyhow, I find my self *refactoring* the *bad* code even when I'm specifically asked by the client NOT to do that, as in don't spend the precious hours on refactoring. Just get to what you're supposed to do, complete the task and scram! - Well ... I just couldn't help it and I ain't invoicing my client for it too. So bad code ticks me off, that's for sure.

Darn ! now I'm confused :( ... what to make of this ? ... am I a *perfectionist* ? or just too weak to keep myself from the knocking on forbidden doors ? - blast ! since I hold a good opinion about myself so I'm showing the latter two fingers up ! Hell ! ... come to think of it ... "knocking on forbidden doors" is something I've been doing for quite a while :P and I enjoy it too :P

I also notice one other thing. Most "legacy" type coders tend to keep stuff a bit tightly coupled. Whereas I'm always looking for loose coupling. Don't get me wrong on this, I do make use of tight coupling sometimes but it's governed by special circumstances. The whole idea is to make things re-usable, and my idea of re-usable is not just in one application but all.

Since I am ranting on the subject, so I'd like to voice it out clearly today. Though I am not a regular reader of debuggable but I find my self agreeing to most things with these guys. For instance, looking at an example code, one can really sneak into the thinking patterns of the author. I wish I could lay my finger on it, but I wish I could find some sort of metrics that should at least give me 80 ~ 90% correct results of my hypothesis. So far, I do know this (and I'm sure most seniors would agree in the field) that there are two generic classes of people. One who acutally think in terms of **patterns** and others who display traits of **linear** thinking. Linear thinking is good for an abstract approach to solve problems and it gets most jobs done. But in an efficient way ? ... I would disagree on this. This is because I have witnessed a handful of projects failing due to this. Not to forget that most cases were with developers on CodeIgniter ... but these are not the shortcomings of the framework, but because it's non-mvc-strict policy is abused by most programmers. Infact, I've seen developers running towards CodeIgniter just because it's ok with a hack here and a hack there. Heck! I've seen usage of SQL statements in CakePHP's VIEWS ! ... YES ! ... VIEWS !! ... boy was that a sight ! and dear god I don't want to see that again. I won't name, but it was from the students of a school here in Lahore people are so fond of (kind of a status symbol - arrogant bastards they are indeed). So I see this as a culmination of the typical "just get it done" plus "linear thinking" analogy. I just hope we could escape it's evils.

Alright ... so my question still hangs ... am I a perfectionist ? - Well ... I'd say "yeh sort of" - I mean the obsessive compulsive behavior is there, but not to the extent of his level.