Home arrow Blog arrow Objects save the day, sort of
Shameless Plugs
Main Menu
Home
Blog
Contact Me
Development RSS Feeds
IT Healthcare RSS Feeds
Prephotosts
Hire Me!
Member Login
Username

Password

Remember me
Forgotten your password?
No account yet? Create one
AdSense
The RPNA, 1 kB
Objects save the day, sort of PDF Print E-mail
Written by Edward Prevost   
Thursday, 03 April 2008
Recently on the NYPHP(php-talk) mail-list, there was a discussion around how to appropriately name SQL variables...

$sql  $sql1  $sql2

Some suggested that this was too vague, after all, the real-world issue here is longevity; in that we want code that isn't completely confusing for others to review or inherit. It was suggest that...
the variables be named in a more meaningful manner, say after what it is they are doing, or what the query should result in...

$sqlINSERT_AgeSexLoc   $sqlDELETE_ALL_ASPUsers   $sqlUPDATE_FirstName

It immediately appeared to me that there was an easier way to do this, after all, what's the point of having a fully OO PHP5 if we aren't going to use it, right? And I think that may just be the issue, we tend to over-engineer solutions when we are given such robust tools. But even tools, as robust as PHP5, can be used with a gentle touch, to offer up some interesting solutions, such as this. What if we made a VERY SIMPLE class, that forced the developer to display certain information that made it obvious as to what was being done in SQL... Objects save the day! (sorta)

So, I wrote a VERY SIMPLE class, to demonstrate this concept, in fact it all-together lacks certain best practices and doesn't utilize the full breadth of OOD, however, because of this, the way in which a developer interacts with the class, makes for virtually self explanatory code... check it out.

sbdDAO (SIMPLE DB DAO)


Image
Last Updated ( Thursday, 03 April 2008 )
Next >
A CovenantEDesign Project.
All Content Copyright © Edward Prevost 2000-2008
Disclaimer: All thoughts and opinions expressed here are not necessarily reflective of Covenant E-design, its employees, clients or affiliates.