Tony Marston
Posts: 37
Nickname: tony32
Registered: May, 2007
|
|
Re: Can a boy scout be too eager?
|
Posted: May 23, 2009 2:48 AM
|
|
Like so many other aspects of computer programming the definition of "cleaner code" can mean different things to different people. Provided that the code is maintainable and efficient when it is executed then it should be left alone.
My style of OOP is often criticised not because it doesn't work (which it most certainly does) but because it does not follow the arbitrary rules that they have been taught. For example, I use a separate class for each database table, which means that my class structure is always totally synchronised with my database structure, which means that I do not suffer from Object-Relational impedence mismatch, which means that I do not have to employ that abomnination called an Object-Realtional Mapper (ORM). Now just suppose some bright spark decides that my code would be "cleaner" if it followed the rules and had a "proper" class structure which was out of step with the database structure so that it could use an ORM. Would it in fact be "cleaner" or just "different"?
As another example, some programmers have a separate Data Access Object (DAO) for each individual database table whereas I use a single DAO for an entire database engine (MySQL, PostgreSQL, Oracle). Now just suppose some bright spark decides that my code would be "cleaner" if it was rewritten to use a separate DAO for each database table. Would it in fact be "cleaner" or just "different"?
I think that the biggest problem here is that it is impossible to come up with a definition of "cleaner code" that is acceptable to everybody, just like it is impossible to come up an answer for "what is OOP?" that is acceptable to everybody
|
|