• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

dynamic classification

 
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fowler in his "UML distilled" says that dynamic classification allows an object to change type within the subtyping structure (under the same type descriminator). How is this implemented in programming? I assume that the client just has an interface in his hand and has no idea of the implementation he is working with. How is the underneath implementation changed (i guess this is the meaning of "change type")and how is all this achieved?
Please correct me for any mis-conceptions.
Also, can someone throw some light on multiple classification. Is it used in implementation models also?
Thanks.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fowler says it is something like an object described by several types (implementing different interfaces, i guess so!!!) which are not necessarily connected by inheritance.
Also Fowler says -

Note that multiple classifiction is different from multiple inheritance. Multiple inheritance says that a type may have many supertypes, BUT THAT A SINGLE TYPE MUST BE DEFINED FOR EACH OBJECT. MULTIPLE CLASSIFICATION ALLOWS MULTIPLE TYPES FOR AN OBJECT WITHOUT DEFINING A SPECIFIC TYPE FOR THE PURPOSE


Can someone please elaborate on what he meant in the sentences hilited in upper-case above, if possible with simple example.
Thanks.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Friends. Little thoughts about multiple classification.....

Multiple classification of objects for conceptual models


What does this exactly mean? If i show the allowable combination of types using UML notation, who is going to ensure that i'm not violating this protocol when i implement the interfaces on my object ??
Am i missing something here? Anyone, any thoughts!!!
BTW, i've been replying to my own message in this thread trying to understand the concept little-by-little. Can someone please assist me.
Thanks.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Someone please clarify on the above items in this thread. Please go through them in sequence. They are about dynamic and multiple classification.
Thanks.
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can someone break this string of my own messages and give their opinion on multiple and dynamic classification please Waiting for anyone to help me out from the confusion.
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Learn patience, grasshopper...
I will take a look at my copy of UML distilled tomorrow and come back with what I learned...
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jayadev Pulaparty:
Fowler in his "UML distilled" says that dynamic classification allows an object to change type within the subtyping structure (under the same type descriminator). How is this implemented in programming? I assume that the client just has an interface in his hand and has no idea of the implementation he is working with. How is the underneath implementation changed (i guess this is the meaning of "change type")and how is all this achieved?


Well, most languages (like Java) don't allow an object to change its type - so you need to change its behaviour without changing the type. How could you do it?
The simplest way would probably be to set some kind of flag and change behaviour depending on it. For bigger differences, State/Strategy patterns are probably more appropriate. In fact, depending on the actual needs a myriad of different solutions are imaginable.

Also, can someone throw some light on multiple classification. Is it used in implementation models also?


That would only make sense if the implementation language directly supported it. Java doesn't.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jayadev Pulaparty:
Fowler says it is something like an object described by several types (implementing different interfaces, i guess so!!!) which are not necessarily connected by inheritance.


No, not by implementing different interfaces. Just by having different types at the same time. Remember, we are talking about the conceptual model here - there is nothing implied about the implementation at all.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jayadev Pulaparty:
What does this exactly mean? If i show the allowable combination of types using UML notation, who is going to ensure that i'm not violating this protocol when i implement the interfaces on my object ??


I am somewhat confused by the question. The purpose of UML is to communicate. Of course if you don't understand the requirements or don't care to implement them, if nobody is writing tests for the system, if nobody is reviewing your code - you will be doomed, wether you are using UML or not, with or without dynamic or multiple classification.
I must be missing something...
 
Jayadev Pulaparty
Ranch Hand
Posts: 662
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ilja,
First of all, Thank you for taking time to reply to all my questions. I have a few other concerns still lingering in my mind -

My stuff -
Also, can someone throw some light on multiple classification. Is it used in implementation models also?


Your reply -
That would only make sense if the implementation language directly supported it. Java doesn't.


I guess you mean to say that Java doesn't support a way to implement multiple classification. If so, can you be a little more elaborate as to "why it can't" I'm getting a little more specific here as i'm pretty sure that the concept is still a little murky for me.

Originally posted by Jayadev Pulaparty:
Fowler says it is something like an object described by several types (implementing different interfaces, i guess so!!!) which are not necessarily connected by inheritance.


Your reply -
No, not by implementing different interfaces. Just by having different types at the same time. Remember, we are talking about the conceptual model here - there is nothing implied about the implementation at all.


I agree with you not to think about implementation when we talk of conceptual models. But then, what do you exactly mean by "having different types at the same time". Can you be a little more elaborate here.

Originally posted by Jayadev Pulaparty:
What does this exactly mean? If i show the allowable combination of types using UML notation, who is going to ensure that i'm not violating this protocol when i implement the interfaces on my object ??


Your reply -
I am somewhat confused by the question. The purpose of UML is to communicate. Of course if you don't understand the requirements or don't care to implement them, if nobody is writing tests for the system, if nobody is reviewing your code - you will be doomed, wether you are using UML or not, with or without dynamic or multiple classification.


I got your point here. I was under the impression that in addition to communicating our design, UML will also provide some tools to ensure that we are sticking to the design. You are right! It is upto the designer to stick to what he is conveying through UML.
Regards,
Jayadev.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let's take a look at the example at page 83:
A Nurse "is a" Person (in the language of the users), so Nurse is a subtype of Person.
A Male *also* is a Person, so Male is a subtype of Person.
*But* - an instance of Person can be a Male *and* a Nurse *at the same time*. We could show this by creating a MaleNurse class - but that would be very burdensome as it would lead to an "explosion" of the number of classes. It probably also wouldn't communicate very well.
Fortunately, there is nothing wrong in simply saying "a Person can be a Male and a Nurse at the same time". That's all multiple classification is about.
Of course this doesn't work at the implementation level in Java - here an object is an instance of *exactly* one class (the one determined by the constructor you call). That's not a problem - there are other ways to implement this.
 
reply
    Bookmark Topic Watch Topic
  • New Topic