Book a Demo

Author Topic: UML and partial inheritance  (Read 13300 times)

Paul W

  • EA User
  • **
  • Posts: 34
  • Karma: +0/-0
    • View Profile
UML and partial inheritance
« on: March 17, 2009, 09:57:35 pm »
I've forgotten part of my modelling.

We have a situation where there are a number of classes that derive their behaviour. The Parent class has a set of operations that the child class needs. However they do not necessarily need all of the operations.

If I use inheritance and show inherited operations, all operations are inherited.

How do I model what is really required?

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: UML and partial inheritance
« Reply #1 on: March 17, 2009, 10:56:55 pm »
Well, biologically speaking, as far as I know, its pretty difficult to excise the genes you got from your parents and I think UML is pretty much the same.  However, you can disguise things or even surgically change things in your own instance so that future generations won't know about them (even though they may indirectly inherit them).

 :)

IOW,  you need to override the behaviors and/or privatise the attributes of the current classifier so that clients or subsequent inheritors have no visibility.

hth
bruce


(p.s.  less jocular than usual folks?)  
"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

Oliver F.

  • EA User
  • **
  • Posts: 573
  • Karma: +2/-1
  • Aren´t we all in the model business ?
    • View Profile
    • Karl Storz homepage
Re: UML and partial inheritance
« Reply #2 on: March 17, 2009, 11:02:53 pm »
Quote

(p.s.  less jocular than usual folks?)  

<threadhijackmode> What is wrong with you?  On vacation? ;) </threadhijackmode>

Oliver
« Last Edit: March 17, 2009, 11:03:11 pm by ofels »

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13523
  • Karma: +574/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: UML and partial inheritance
« Reply #3 on: March 18, 2009, 12:26:16 am »
If you are troubled with that kind of questions your design is flawed.
If a class is a subclass of another class then it inherits all, not just a part of it.
Privatising (is that even a word?) will only make things worse as it violates the open/closed principle. You can only extend the functionality of the superclass, not modifiy it, and certainly not cripple it by making some of the operations private. I'm not even sure which programming languages will allow you to override a public operation with a private.

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: UML and partial inheritance
« Reply #4 on: March 18, 2009, 01:21:14 am »
Yet some languages and paradigms allow this. Take for instance the Shadows keyword in VB.Net. [There is an analogous convention in C#.]

EA handles this via some tagged values. Look up Modeling Conventions in the EA help. I have not tested this myself, so you are on your own as far as any limitations apply.
No, you can't have it!