|
|
|
Re: Default value of an inherited string attribute [message #418976 is a reply to message #418973] |
Tue, 06 May 2008 14:42 |
Ed Merks Messages: 33141 Registered: July 2009 |
Senior Member |
|
|
Vincent,
I'm not a big fan of redefinition for several reasons. Even your
examples below point out odd inconsistencies. I have a MyClassA
instance and I cannot change the myStringAttribute, only it turns out
that the instance isn't just a MyClassA, it's a MyClassB, which I
wouldn't know without an instanceof test, and hence I can actually set it.
If these are ways in which you want to constrain the behavior in the
editor or to initialize new instances created in the editor, it's much
better to do that in the item providers than to try to define things in
the metamodel where assumptions in a base class turn out to be wrong in
a derived class...
Vincent L. wrote:
> Hi.
>
> Thanks for your answer... but i'm not sure it will help me.
>
> My problem is more general than the default value problem. It applies
> to any setting of model element that we could want to override when
> you derive a class from another one.
>
> Suppose that I have the same classes (myClassA, myClassB, myClassC)
> with the same attribute myStringAttribute but now instead of a
> different default initial value, I want to have a different
> "changeable" setting
>
> 1- myStringAttribute is read-only in myClassA (changeable = false)
> 2- myStringAttribute is read-write in myClassB (changeable = true)
> 3- myStringAttribute is read-only in myClassC (changeable = false)
>
> I know that I can change the code of the ItemProvider of each subclass
> to make the attribute changeable or not but it could be boring to do
> this for all setting that I want to override in subclass...
>
> Any idea? Is my question well formulate?
>
> Thanks.
>
> Vincent
>
Ed Merks
Professional Support: https://www.macromodeling.com/
|
|
|
Powered by
FUDForum. Page generated in 0.03000 seconds