Book a Demo

Author Topic: Show Get-only Property in C# Class Diagram?  (Read 5172 times)

DMT

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Show Get-only Property in C# Class Diagram?
« on: July 16, 2003, 03:37:03 pm »
Does anyone know of any way to denote that a property is read-only in a class diagram for a C# class?  

It's great that I only need one operation for a property, but the problem is that I can't see what properties are read-only by looking at the diagram.  I have to remember to go to the Tags tab to figure it out, which sometimes results in problems that are only found once the code is generated.

Javier

  • EA User
  • **
  • Posts: 67
  • Karma: +0/-0
  • Necessity is the mother of email
    • View Profile
Re: Show Get-only Property in C# Class Diagram?
« Reply #1 on: July 16, 2003, 04:58:06 pm »
This is a good place to use a stereotype.  There are a couple of options that you have here:

- Use a <<propertyget>> and a <<propertyset>> for the properties.  If you want shorter stereotypes, use <<get>> and <<set>>

- If you're going to generate code, reverse-engineer a simple C# class, inspect what EA does and use that instead.

I personally do not like using UML tools to generate code.  The reason is that I cannot be both the designer and the implementer--conflicting roles.  So I concentrate on making the model clear so that developers won't have to come back asking me all kinds of questions.

Regards,

Javier
We must become the change we want to see.
- Ghandi

DMT

  • EA User
  • **
  • Posts: 93
  • Karma: +0/-0
    • View Profile
Re: Show Get-only Property in C# Class Diagram?
« Reply #2 on: July 17, 2003, 04:54:51 am »
Javier:

Thanks for the suggestions. We rely heavily on code generation, so unfortunately, those suggestions do not work. EA depends upon "property" being the stereotype to know to generate the property getter and/or setter.

Code generation saves us hours and hours of time, so I don't think it's a viable option to stop using this feature. Perhaps the custom code generation templates will allow us to specify a set of stereotypes that trigger the property code generation.