Re: OO is not that great: many repeated codes
- From: "Phlip" <phlipcpp@xxxxxxxxx>
- Date: Fri, 22 Sep 2006 15:20:00 GMT
Shawn wrote:
I think OO is not great, compared to procedural languages. Each method has
to be hosted in one class. So the identical method code could be
repeatedly in several classes.
There are those who say the heart of software design is removing
duplication, and replacing it with abstractions.
For example, the book /Design Patterns/ says to abstract the thing that
varies. This is the inverse way to say "merge all duplications".
void driveCarWell()
has to be in both classes.
HouseWife and Professor know how to cook. So the method
void cookDeliciousFood()
has to be in both classes.
Both can have a cook object member, and a driver object member, and these
can delegate to unique instances of those methods.
Look up "Don't repeat yourself".
By and large, the most common construction technique is simply delegation.
(The same as it was in "structural programming" before the rise of all this
OO nonsense.)
As you see, methods are repeated in many classes. It is hard to use
inheritance to solve the issue.
Only use OO if you need smart indirection to find your delegates.
In procedural language, you only need to write the method once and put
them in the global place. Then you can grab them anytime you want. Because
a method don't need to be buried inside a class.
Java is hardly a good role model here. Forcing everything to be a member of
a class is not the same thing as enabling elegant code.
--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
.
- Follow-Ups:
- Re: OO is not that great: many repeated codes
- From: topmind
- Re: OO is not that great: many repeated codes
- References:
- OO is not that great: many repeated codes
- From: Shawn
- OO is not that great: many repeated codes
- Prev by Date: Re: OO is not that great: many repeated codes
- Next by Date: Re: OO is not that great: many repeated codes
- Previous by thread: Re: OO is not that great: many repeated codes
- Next by thread: Re: OO is not that great: many repeated codes
- Index(es):