Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
March 17, 2006 More power than needed ... OOP to Don Clugston | ||||
---|---|---|---|---|
| ||||
Hi Don, Don C. wrote : <<In OOP, you spend your time trying to find Is-A relationships, but they don't exist. Unsurprisingly, hardly anyone is "really" doing OOP. It seems to be unimplementable.>> Oops, what is the matter? . A Is-relation between two classes is just inheritance. f.i. cB inherits cA, ergo cB is a special case of cA. I think you talk about the problem to decide : Do we have a Has-Relationship or do we have a Uses-Relationship. ?! I agree, it is often difficult to figure out the difference between Has- and Uses- Relationship. But when you keep in mind that a Has-Relationship only exist when we can say instead of : cA has 2(n) cB objects , cA consists of 2 cB objects. ------------------------- In other words : cA consists of 2(n) cB objects means Has-Relationship. Bjoern |
March 17, 2006 Re: More power than needed ... OOP to Don Clugston | ||||
---|---|---|---|---|
| ||||
Posted in reply to BLS | BLS wrote:
> Hi Don,
>
> Don C. wrote :
> <<In OOP, you spend your time trying to find Is-A relationships, but they
> don't exist. Unsurprisingly, hardly anyone is "really" doing OOP. It
> seems to be unimplementable.>>
>
> Oops, what is the matter? . A Is-relation between two classes is just
> inheritance. f.i. cB inherits cA, ergo cB is a special case of cA.
Yes, that's exactly right. I'm saying that inheritance is rarely appropriate. If you read the Design Patterns GoF book, you'll see that the #1 rule of OO design is, "Prefer encapsulation to inheritance".
But the defining feature of OO design is inheritance. Without inheritance, OOP doesn't have polymorphism.
What I find extremely common in practice is "Can-be-treated-as-A" polymorphic relationships. Most of the time, "is-A" relationships are an approximation to "Can-be-treated-as-A" relationships. I think that polymorphism is very important, but inheritance-based polymorphism has many problems.
|
March 18, 2006 Re: More power than needed ... OOP to Don Clugston | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Hi Don, okay, now I understand what you mean. Takes a while. You may have noticed <g> that english is not my favourite language. GoF. Yes of course, I know about it. I read Bruce Eckel s Thinking in Pattern and Prof. Moessenboek OOP in Oberon 2 instead because I have heard that GoF Design Patterns is a bit too theoretical. Can you confirm ? Or will you say it is a "You need it" book ? Thanks, Bjoern "Don Clugston" <dac@nospam.com.au> schreef in bericht news:dveppu$1im5$1@digitaldaemon.com... > BLS wrote: > > Hi Don, > > > > Don C. wrote : > > <<In OOP, you spend your time trying to find Is-A relationships, but they > > don't exist. Unsurprisingly, hardly anyone is "really" doing OOP. It seems to be unimplementable.>> > > > > Oops, what is the matter? . A Is-relation between two classes is just inheritance. f.i. cB inherits cA, ergo cB is a special case of cA. > > Yes, that's exactly right. I'm saying that inheritance is rarely appropriate. If you read the Design Patterns GoF book, you'll see that the #1 rule of OO design is, "Prefer encapsulation to inheritance". But the defining feature of OO design is inheritance. Without inheritance, OOP doesn't have polymorphism. > > What I find extremely common in practice is "Can-be-treated-as-A" polymorphic relationships. Most of the time, "is-A" relationships are an approximation to "Can-be-treated-as-A" relationships. I think that polymorphism is very important, but inheritance-based polymorphism has many problems. > |
March 18, 2006 Re: More power than needed ... OOP to Don Clugston | ||||
---|---|---|---|---|
| ||||
Posted in reply to BLS | BLS wrote: > Hi Don, > okay, now I understand what you mean. Takes a while. You may have noticed > <g> that english is not my favourite language. I know the feeling. I'm an expat myself, and don't speak the local language (German) as well as I'd like... Your English is about 100 times better than my German. > GoF. > Yes of course, I know about it. I read Bruce Eckel s Thinking in Pattern and > Prof. Moessenboek OOP in Oberon 2 instead because I have heard that GoF > Design Patterns is a bit too theoretical. Can you confirm ? Or will you say > it is a "You need it" book ? Well, GoF was the book that launched the Patterns movement, everyone quotes it all the term and uses terminology from it. A lot of the code in it isn't spectacularly good, and parts of the book seem a bit clumsy, but it was certainly groundbreaking. So, it's true that it's too theoretical, but I think it's still probably a 'you need it on your shelf' book. At least, you need a good idea of what's in it. |
March 18, 2006 Re: More power than needed ... OOP to Don Clugston | ||||
---|---|---|---|---|
| ||||
Posted in reply to Don Clugston | Thanks Don ! |
Copyright © 1999-2021 by the D Language Foundation