Book a Demo

Author Topic: How to add a property to an interface?  (Read 4282 times)

PaulH

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
How to add a property to an interface?
« on: October 12, 2006, 05:50:24 am »
Hi,

Just starting what appears a very steep learning curve to learning EA.  My code base will be C# and I'm currently trying to create an interface (called IHeader), that exposes a get; property called ID (int).  This is to be realised by the class Header, which not only implements the ID get parameter, but defines the private attribute id.  I'm running into a problem where the only way that I can define a property in the interface is by giving the interface an attribute.  Whilst this then allows the class (Header) to implement the property ID, I'm left with the attribute in the interface rather than the class.  Any ideas how I can get around this?

Thanks,

- Paul.

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to add a property to an interface?
« Reply #1 on: October 12, 2006, 06:04:51 am »
Quote
Hi,

Just starting what appears a very steep learning curve to learning EA.  My code base will be C# and I'm currently trying to create an interface (called IHeader), that exposes a get; property called ID (int).  This is to be realised by the class Header, which not only implements the ID get parameter, but defines the private attribute id.  I'm running into a problem where the only way that I can define a property in the interface is by giving the interface an attribute.  Whilst this then allows the class (Header) to implement the property ID, I'm left with the attribute in the interface rather than the class.  Any ideas how I can get around this?

Thanks,

 - Paul.
Hi Paul,

I don't understand, where did the private attribute id come from?  I created a property ID with only a getter method, marked abstract.  No additional private attribute was created.

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

PaulH

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to add a property to an interface?
« Reply #2 on: October 12, 2006, 06:11:00 am »
I guess I'm doing something wrong, the only way I've found of creating a property is to create an attribute (and check the property check box that is on the attribute dialog box).  So I've not found the way of creating the getter method without first creating the attribute (and doing it my way, you can't then delete the attribute as that also gets rid of the property).

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to add a property to an interface?
« Reply #3 on: October 12, 2006, 06:17:59 am »
Quote
I guess I'm doing something wrong, the only way I've found of creating a property is to create an attribute (and check the property check box that is on the attribute dialog box).  So I've not found the way of creating the getter method without first creating the attribute (and doing it my way, you can't then delete the attribute as that also gets rid of the property).
The attribute IS the Property... Search for "Property Redux" in the UML forum (I think).  I wrote up some stuff on Properties.  The methods you see are the implementation of the Property.  You can suppress their rendering on the diagram via a checkbox on the Diagram properties dialog.

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

PaulH

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: How to add a property to an interface?
« Reply #4 on: October 12, 2006, 06:35:05 am »
Thanks for the assistance, I read through the links you copied, and made a note later to try and understand them  :-[  In the mean time I did notice that I was using an EA build from Jan 06, I've just grabbed the latest version.  Straight away I noticed that in the class Properties are no longer flagged as "Property", rather "<<Property>>", so they've become a stereotype.  I followed your example of creating a getter with the correct sterotype and it's worked.  So a mixture of my lack of knowledge and an older version.


Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: How to add a property to an interface?
« Reply #5 on: October 12, 2006, 02:41:47 pm »
Quote
Thanks for the assistance, I read through the links you copied, and made a note later to try and understand them  :-[
No sweat.  If there's anything I wrote that isn't as clear as it should be let me know and I'll try to improve it.

Glad to have been of assistance...  Properties are really cool!

When you have a problem, search the forums.  We have a lively community here and we're all interested in improving EA.

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