Book a Demo

Author Topic: Changing Inherited class  (Read 11963 times)

Mamta

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Changing Inherited class
« on: June 11, 2009, 03:55:05 am »
Here is what I need to do :

   - Inherit a base class to a child class
   - Change the length of an attribute.

Please let me know.

Thx

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Changing Inherited class
« Reply #1 on: June 11, 2009, 09:26:51 am »
I am guessing, but...

Do you mean that in the child class you want to change a length defined in the parent? If so you probably need to redefine the attribute somehow. Depending on the language this might be a Shadows clause or something.

PS: If that is the case, EA uses tagged values for this kind of thing. In the EA help table of contents (not the index) look up Code Engineering | Modeling Conventions. You'll find a list of pages for various languages.

HTH, David
« Last Edit: June 11, 2009, 09:28:50 am by Midnight »
No, you can't have it!

Mamta

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
    • View Profile
Re: Changing Inherited class
« Reply #2 on: June 20, 2009, 09:01:51 am »
Hi,

  I didn't find tagged value useful in this case.
  
  Let me explain with example.

  Let us say I have a base class ' Service Location' with one of the attribute (Service Code with data type 'String').
  On  inheritance, I need the child class to restrict the length of attribute 'Service Code' to String(20).

Also I need to hide some of the attributes in child class.

PS: WE ARE USING EA IN CONTEXT OF IEC-CIM.  
  

Regards
Mamta

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: Changing Inherited class
« Reply #3 on: June 21, 2009, 07:52:56 am »
Leaving aside any implications of CIM - I have archived my documentation and am not in a position to dig it out now - I still think you need to redefine the attribute by 'hiding' the original. This might make it difficult to inherit, since such a redefinition tends to be all or nothing.

One option is to define a class for your attribute. You would then have something like a ServiceCode class. You could then specialize that class to provide (for example) a SubServiceCode class. You could then have the ServiceLocation class declare an attribute with a data type of ServiceCode. You might then specialize this class to SubServiceLocation and shadow this attribute to have a data type of SubServiceCode.

You might also achieve the above by placing constraints on the attribute of the subclass, by using generics (if your paradigm supports there) or templates, or perhaps by making the parent class virtual (in which case you'd probably have to use one of the other options too).

BTW, make sure you are not confusing issues of data base data type definition. These can be difficult to separate, particularly when dealing with something like CIM.
No, you can't have it!