aspose file tools*
The moose likes OO, Patterns, UML and Refactoring and the fly likes dynamic classification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "dynamic classification" Watch "dynamic classification" New topic
Author

dynamic classification

Jayadev Pulaparty
Ranch Hand

Joined: Mar 25, 2002
Posts: 662
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

Joined: Mar 25, 2002
Posts: 662
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

Joined: Mar 25, 2002
Posts: 662
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

Joined: Mar 25, 2002
Posts: 662
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

Joined: Mar 25, 2002
Posts: 662
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.
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Learn patience, grasshopper...
I will take a look at my copy of UML distilled tomorrow and come back with what I learned...


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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

Joined: Mar 25, 2002
Posts: 662
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
Sheriff

Joined: Jul 11, 2001
Posts: 14112
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: dynamic classification