Book a Demo

Author Topic: Dynamic Reclassification  (Read 6142 times)

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Dynamic Reclassification
« on: January 23, 2007, 06:52:35 am »
A few days ago, I got to wondering if UML provided (or should provide) an action which would result in a run-time change in the class to which an object belongs.  There used to be at least one programming language that allowed this action.  

The example I fancied was the specialization of an individual in to the sub-classes of infant, teen ager, adult, and senior citizen.  Clearly, these sub-classes exhibited different behaviors over time.  But then I realized that these sub-classes were nothing more than states of the individual, not truly specializations of individual.

So now I'm wondering if anyone can provide an example that would correctly provide a need for dynamic reclassification of an object (i.e.; one that could not be expressed as state changes)?

Thoughts anyone?
Jim

Verbal Use Cases aren't worth the paper they are written upon.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: Dynamic Reclassification
« Reply #1 on: January 23, 2007, 09:55:48 am »
Quote
[size=13][SNIP][/size]  
The example I fancied was the specialization of an individual in to the sub-classes of infant, teenager, adult, and senior citizen.  Clearly, these sub-classes exhibited different behaviors over time.  But then I realized that these sub-classes were nothing more than states of the individual, not truly specializations of individual.
[size=13][SNIP][/size]
Good call Jim on these not being (prima facie) true specializations.

It got me thinking that true specialization probably involves structural differences.  So how about individual into male and female?

Which then provides the example of an individual undergoing gender reassignment...

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Dynamic Reclassification
« Reply #2 on: January 23, 2007, 10:04:02 am »
How about caterpillar to butterfly. Somewhat more than a state change here.

Subtly different from egg to chicken, which seems somewhat out of scope.
No, you can't have it!

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: Dynamic Reclassification
« Reply #3 on: January 23, 2007, 10:15:26 am »
Interesting thought Paolo!  I'm still mulling that one over.

Brings us into the realm of Dependency Injection [IoC] doesn't it? ;D
Verbal Use Cases aren't worth the paper they are written upon.

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: Dynamic Reclassification
« Reply #4 on: January 24, 2007, 04:56:54 am »
The examples of gender, butterfly, and chicken are good, but not sufficient to mandate a specific UML operation to deal with them.  I think they may be modeled with currently available UML features and design patterns.  Here is my reasoning on how gender reassignment may be modeled--the technique can be applied to the other examples too, I think.
  • Within the O-O paradigm, objects are built in one of two ways:  Inheritance and Composition.
  • Composition is preferred over Inheritance.
  • When modeling an individual, we abstract out the essence of gender and encapsulate it in an abstract class of its own.
  • Gender, then, is modeled as a component of Individual.
  • We specify that Individual owns its end of the composition relationship.
  • Because Individual now consists of an abstract component (Gender), it may not be directly instantiated, so an object factory pattern is applied to construct Individuals as needed.
  • The essence of being male or female are factored out to form the concrete Gender specializations of Male and Female.  The factory pattern selects the appropriate gender specialization and links it to the Individual.
  • We implement an object surgeon pattern which, by way of dependency injection, can operate on an Individual replacing one gender for another.  The surgeon accomplishes this by instantiating a replacement gender object (Male or Female as needed) and reestablishing the gender link within the Individual
I don't think implementation of a Male and Female interface to Individual would be the way to go because that would rely too much on inheritance, require inclusion of both male and female essences within the same individual, and distract the object's design too far from the essence of being an individual--objects should simple and focused.

Have I got this right?
Thoughts?
More examples?

Jim
Verbal Use Cases aren't worth the paper they are written upon.

mikewhit

  • EA User
  • **
  • Posts: 608
  • Karma: +0/-0
  • Accessing ....
    • View Profile
Re: Dynamic Reclassification
« Reply #5 on: January 24, 2007, 05:45:13 am »
Is this a case of a problem in search of a problem ;)

jeshaw2

  • EA User
  • **
  • Posts: 701
  • Karma: +0/-0
  • I'm a Singleton, what pattern are you?
    • View Profile
Re: Dynamic Reclassification
« Reply #6 on: January 24, 2007, 01:03:01 pm »
Its a case of trying to stay ahead of my students.  I'm also doing some out of the box thinking for a monograph I'm writing.  :D
Verbal Use Cases aren't worth the paper they are written upon.