OOP and SQL
Posted: Sun Mar 26, 2006 9:54 pm
For me personally OOP number one goal and priority has always been reusability...
Yes even over encapsulation data hiding and all the bells and whistles of OOP.
I use OOP in PHP, quite a bit actually...but I have a hell of a time using classes for anything database related...
I feel you loose reuse when you have SQL statements inside a member function, kind of like you loose reuse of a class with HTML inside member functions.
There are too many databases and abstraction layers available and in everyday use to force anyone user into using MySQL or AdoDB, etc...
As nice as OOP would be in working with SQL I can't seem to get myself going on on it...
I'll list my reasons:
1) Database systems are a plenty (MYSQL, MSSQL, SQLIte, etc...)
2) Adbstraction layers...AdoDB being popular but not standard...there are others
3) Database schemas change often and are also typically bound to one given project. There is no such thing as ONE single registration form...some people want date of birth, others want current age.
When I write anything OOP I want reusability, drop-in and go..no tinkering with implementation just plug and go.
I'm curious to hear how you deal with the above?
Do you favour encapsulation over reusability?
Cheers
Yes even over encapsulation data hiding and all the bells and whistles of OOP.
I use OOP in PHP, quite a bit actually...but I have a hell of a time using classes for anything database related...
I feel you loose reuse when you have SQL statements inside a member function, kind of like you loose reuse of a class with HTML inside member functions.
There are too many databases and abstraction layers available and in everyday use to force anyone user into using MySQL or AdoDB, etc...
As nice as OOP would be in working with SQL I can't seem to get myself going on on it...
I'll list my reasons:
1) Database systems are a plenty (MYSQL, MSSQL, SQLIte, etc...)
2) Adbstraction layers...AdoDB being popular but not standard...there are others
3) Database schemas change often and are also typically bound to one given project. There is no such thing as ONE single registration form...some people want date of birth, others want current age.
When I write anything OOP I want reusability, drop-in and go..no tinkering with implementation just plug and go.
I'm curious to hear how you deal with the above?
Do you favour encapsulation over reusability?
Cheers