Friday, November 26, 2010

Winston W Royce - Father of waterfall

 Uncle Bob posted an article, What killed waterfall could kill agile. He mentioned about a person named Dr Winston W Royce (whom uncle bob called the "Father of waterfall") who published a paper,  Managing the Development of Large Software Systems: Concepts and Techniques, in which a system of developement now know as the Waterfall model was described.

 What shocked me in that paper was not that he advocate the waterfall model, but rather he condemns it. In his own words
"I believe in this concept, but the implementation described above is risky and invites failure".

 The funny thing is so many generations of programmers who studied in colleges and university were brought up believing that it was one of (or depending on how old you are) or "the" model of how software actually gets built. Now we know better, that's why we have things like the Agile movement, Kanban and so on

 If you read the paper, you will discover he has views on how to improve the process and what is surprising is how similar it is to practices that we are advocating today.

His 4th and 5th recommendation looked remarkably like Agile practices.

 Step 4: Plan, Control and Monitor Testing
Code inspection
He advocates the use of code inspection by a second party, he said the use of computers would be too expensive for this task. But with the computing power we have today. Software like Findbugs or JTest can help in the first line of bad code detection and Pair Programming helps in that aspect too.

 Code Coverage
Code coverage is also advocated in fact he advocates testing every logical path if possible and if he is the customer he would not accept delivery until this step is done. Although he acknowledges the difficulty in accomplishing this step for large programs.

 Step 5: Involve the customer
He knows that software design and specifications is open to a wide interpretation even after agreements, customer involvement in his words should be "formal, in-depth and continuing". 

 Let's not remember Winston W Royce as "Father of the waterfall" but rather one who saw how software development could be done better 40 years ago.  

Saturday, November 20, 2010

Relational selects in YII

How do you do relational selects in YII? The kind where you have a many to many relationship on a table. The YII page on relational queries didn't have many good examples on how to do it, so I tried it out and found it to be actually quite easy, its quite like how you would do for single table query.

The above figure was taken from the YII page on relational queries (I was too lazy to do up my own example).

We will just concentrate on the tbl_post , tbl_post_category and the tbl_category tables.

I will assume you know how to overwrite the relations function in CActiveRecord to setup the relations correctly.

So the scenario is, I would like to retrieve posts that are in a certain category. 

The idea is to use the with() method that is part of CActiveRecord, we would like to retrieve the categories together with the Posts.

So the query would look like this:


In the with portion you specify the relations that you want to load in this case categories, and with it you can specify the different relation query options like select, condition and so on. In this case we use the "condition" option to specify what from categories that we want to retrieve. For this we want to retrieve all the Post with categories name = "FunStuff".

Simple rite!