Should I declare Get’s and Set’s at UML?

Asked

Viewed 1,817 times

6

Every time I create a class UML I have to declare get and set for all classes that come to use them or can leave without, as if it were standard and everyone knew that they must implement them even if not in UML?

3 answers

6


The most important thing is to always be consistent. This includes being consistent with what the team does.

If the team is still going to define what to do I would just indicate that there are access methods in a generic way just by a line indicating this.

Not everyone agrees with this especially if these methods include some relevant logic, which in a certain way makes it a method like any other.

  • and when the constructor performs setters operations, as declared by the constructor ?

  • 1

    It is usually created as the first methods of the class. But note that there are no fixed rules, no right or wrong, choose a form and be consistent.

0

I always kept the SET/GET implicitly in the Class Diagram, for example.

But I think it depends, the way the teacher wants it done, or even the development team. I have always had a fight with UML, since several people have different ideas, concepts and methods for attribute applications in Diagrams.

0

Friend would not be wrong but.... I consider that you must maintain a certain level of abstraction in uml, for a simple reason, almost ngm creates get set in hand (ide resource), and you already know that you need them, so it will be a waste of time, and space in uml, for something that is already impregnated in your subconscious, uml is so you don’t get lost in the project. but if you’re aware that you need the getset, you don’t need to.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.