Book a Demo

Author Topic: renaming a realized interface's method...  (Read 4126 times)

Kopi

  • EA Novice
  • *
  • Posts: 9
  • Karma: +0/-0
    • View Profile
renaming a realized interface's method...
« on: June 08, 2004, 06:28:53 am »
Hi!

Create an interface, and add some operations to it: foo, bar mark them pure and virtual.
Add a class, which implements this interface and all the two methods.

After this point there are NO relationship exists between the interface's foo, bar method and the class's overridden foo, bar method, and if I rename the foo method in the interface it will not get reflected in the classes which ones already implemented this interface.


Is it a bug or by design?

This is a thing which needs some correction, is this possible?

Thanks,
Attila

Andreas_G

  • EA User
  • **
  • Posts: 125
  • Karma: +0/-0
  • And that's the way the cookie crumbles.
    • View Profile
Re: renaming a realized interface's method...
« Reply #1 on: June 08, 2004, 07:00:44 am »
Hi Attila,

I think it's not a bug, but rather a "missing feature" or like u said: by design.

I hope this feature will be added anytime.
bye
Andreas

sargasso

  • EA Practitioner
  • ***
  • Posts: 1406
  • Karma: +1/-2
  • 10 COMFROM 30; 20 HALT; 30 ONSUB(50,90,10)
    • View Profile
Re: renaming a realized interface's method...
« Reply #2 on: June 09, 2004, 05:16:27 pm »
I keep finding myself thinking this over.  Forgetting about EA (or any specific tool) at the moment, the issue you two have raised is quite deep.

Without any background on how you arrived at the position to make the post I will assume that your are in the "early" stages of implementation design and that you have good reasons for modelling both the interface and the realizing classes at the same time.  Perhaps you are prototyping the interfaces?  Whatever the reason, I keep stumbling over the thought "Once an interface has been published, it should not be changed".

The key word here is "published".  Consider the havoc that would arise if a theoretical software seller "M", having issued a theoretical set of standard libraries, say ".N" decided offhand to change the name and/or return type of a method in a theoretical interface called, say, "ICollectionBase".  Every realizing class would have to be rewritten to make it re-conform.  Extrapolating backwards, the cost of having mutatable interfaces is still high at any project with more than one developer... and possibly quite high even with single developer projects.

On the other hand, what we need is some way to develop interface specifications in an iterative manner - accepting the cost of changing the realization classes every time a change is made to the interface specification.  During this time, we could say that the interface specification is "unpublished".  

What happens when a change is made to an interface specification is still open to question.  Pushing the interface out to code level in a project without altering the realizations should render any following build invalid.  This is a problem for the IDE to handle and is what should happen now with EA.

Automatically cascading the change to the interface specification down the design chain, seems to me to "have fur on it".  The cascade needs to be controlled and reversible.  Controlled and reversible in the sense of "I want to see the effect of changing the interface spec in this way"  and to do that "I want to change a selected set of realizations and test the impact on that subset of the system... and if its good then I want to propogate the change through the rest of the system ...  but if its not I want to reverse the change forthwith."   Whether or not the cascaded changes are manual or automatic, you can see that the impact on a project with wide use of the interface could be severe.

Secondly, there is the question of how far the cascade could/should go.  Consider adding a new method to the interface.  Realization classes would need to have the method added, how about specializations of those?  Now consider a specialization class that has inadvertantly already got a method of the same name as the method added to the interface.  What are the implications here (in terms of what should the modelling tool do)?

Finally, I am unsure as to whether these ideas are limited to interface classes, any modelling elements that impose some control over related elements may also need to be investigated before any automatic propagation of change is implemented.

IOW I see some type of state mechanism - other than simply locking an element from change - would be necessary to do this properly.  The modelling tool would be exhibiting different behaviour depending on whether the element was published or unpublished.  Both sets of behaviours are quite complex.

I'd love to see an MDA implementation of this  :)

So, what I'm saying is, this is bigger than just propagating changes in interface elements to the first level of realizing classes.  The very idea of "interfaces as a contract" means the type of functionality you are desiring in a modelling tool would have to be very carefully thought out.

rgrds
Bruce

"It is not so expressed, but what of that?
'Twere good you do so much for charity."

Oh I forgot, we aren't doing him are we.

angel-o-sphere

  • EA User
  • **
  • Posts: 112
  • Karma: +0/-0
    • View Profile
Re: renaming a realized interface's method...
« Reply #3 on: June 15, 2004, 08:31:58 am »
While your post is well thought out you IMHO make to many thoughts :D

Secondly, there is the question of how far the cascade could/should go.  Consider adding a new method to the interface.  Realization classes would need to have the method added, how about specializations of those?  Now consider a specialization class that has inadvertantly already got a method of the same name as the method added to the interface.  What are the implications here (in terms of what should the modelling tool do)?

The fact that a class down in the inheritance tree has exactly that method allready was very likely the reason to place that method into the interface :-D

Of course you then want the introduced method to cascade down through the inheritance hierachy.

Lets look at the topic from the oposite site.

Reverse engineer a bunsh of Java classes. Some are interfaces. Now add a method to an arbitrary interface. Suppose EA does not cascade that down the inheritance tree (like it behaves now).

Regenerate the source code.

NOW? The source code won't even compile!!

Well, IMHO an automatic cascading is needed and its 99% of the time exactly what I want.

Furthermore regarding your thoughts about "publishing": 90% of the source code I'm involved with somehow never gets published. (Because its only used in house). Even the interfaces which are deployed get changed every 3rd or 5th release. Well, when we are in developing we use the IDE for that ... Refactoring: "push method up" to get the abstraction into the interface and refactoring: "implement inherited abstract methods" to get the method cascaded down into the tree.

While EA is not a refactoring but a modelling tool ... and a model is only a "simplification" of the real world, I do not expect that every automatic action has a "perfect" model as result. However some support like "rename method" and cascade interface changes would be really helpfull.

angel'o'sphere