Book a Demo

Author Topic: generating interface methods in realizing classes  (Read 4416 times)

macdaddy

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
generating interface methods in realizing classes
« on: September 22, 2003, 10:49:14 am »
I'm currently evaluating EA for possible use in our .NET production stream and I have a question that seems pretty simple.

When I create a class that realizes one or more interfaces with methods that need to be overridden is there a way of having those inherited methods generated in the realizing class?

Also - the C# code generation templates generate a lot of garbage and C++ artifacts (pointer dereferencing operators etc.) , am I correct in assuming that they are still under development and if so where are they on the list of priorities, as I don't really see anything specific about them in the literature?

Rob_M

  • EA User
  • **
  • Posts: 58
  • Karma: +0/-0
    • View Profile
Re: generating interface methods in realizing clas
« Reply #1 on: September 23, 2003, 11:56:39 am »
The 'shortcut' I use for this is:
expand the interface in the project view
drag the function from  the interface onto the class in the class diagram.

This creates the same function with the same signature in the new class.

Rinse and repeat for each of the functions implemented by the class.

Its less than ideal, but much faster than retyping each of the functions.

benc

  • EA Administrator
  • EA User
  • *****
  • Posts: 200
  • Karma: +0/-0
    • View Profile
Re: generating interface methods in realizing clas
« Reply #2 on: September 23, 2003, 08:02:31 pm »
Hi macdaddy and Rob_M,

* To override interface methods in the model you might like this option:
1. Select the derived class in a diagram.
2. Click on menu item: Element | Override Implementation
3. Check the interface methods you wish to override in the derived class
4. These methods will be automatically duplicated in the derived (concrete) class.

* To generate the interface method stubs in the derived class's code, regardless of whether they were explicitely
overriden in the model:
1. Select the derived class
2. Go to Tools | Options | Generation | Attributes/Operations
3. Check the option "Generate method for implemented interfaces"
4. Generate

Note: a recent bug has caused this option not to work properly.  This bug has been fixed and will be available in the next release or the one following.

* Regarding the C# code generation, there have been some updates to the default code templates- the latest build should have these updates.  

macdaddy

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: generating interface methods in realizing clas
« Reply #3 on: September 24, 2003, 05:51:58 am »
Thanks, that's exactly what I was looking for! I suspect the issue's probably come up before but the Override Implementation would probably be ideally suited for the right-click context menu of the selected element - it's kind of hidden up in the main menu and it gets a lot of use.

Cheers,
Macdaddy


Quote
Hi macdaddy and Rob_M,

* To override interface methods in the model you might like this option:
 1. Select the derived class in a diagram.
 2. Click on menu item: Element | Override Implementation
 3. Check the interface methods you wish to override in the derived class
 4. These methods will be automatically duplicated in the derived (concrete) class.

* To generate the interface method stubs in the derived class's code, regardless of whether they were explicitely
overriden in the model:
 1. Select the derived class
 2. Go to Tools | Options | Generation | Attributes/Operations
 3. Check the option "Generate method for implemented interfaces"
 4. Generate

Note: a recent bug has caused this option not to work properly.  This bug has been fixed and will be available in the next release or the one following.

* Regarding the C# code generation, there have been some updates to the default code templates- the latest build should have these updates.