1
I have several classes that have several attributes and methods. When making the class diagram it is necessary to add all methods and attributes? Is there any rule or consensus on the creation of such?
1
I have several classes that have several attributes and methods. When making the class diagram it is necessary to add all methods and attributes? Is there any rule or consensus on the creation of such?
3
It depends. Do you want to do it right or do you want to do it anyway? If you want to do it right then you have to. You shouldn’t even have to think about it. The purpose of doing UML is to document everything. If it is to do it by half then why do it?
Actually, why are you doing UML? If you don’t know why and that reason isn’t very good, you can’t prove that you’re giving yourself any leverage, why do it? People are doing a lot of things automatically because they’ve seen others do it, they don’t even know why they’re doing it, if they have an advantage.
An example is in another answer. People use getters and setters without thinking. Almost always its use is wrong, but there are so many people doing wrong that it already seems that it is right. The more object-oriented radicals say that they should never be used because they are methods that do not have a specific purpose, it only serves to encapsulate state, and methods like this should not exist. The more pragmatic consider that they are only encapsulating state without any gain. Most people cannot answer because they create getters and setters, They are only doing what they saw others doing (and let it be clear, if it is to be in the code, it has to be in the UML, otherwise this representation is mistaken, the criticism here is to have in the code, not only in the UML). UML is to make you think about what you’re doing before you do it, to make sure you need it, if there’s nothing missing, if everything is going to fit right. When you do it automatically you don’t need UML.
UML is bureaucracy, if not to do it right, don’t do it. In another answer it says you should put everything or just part depending on people will need to know if the system will have that. But is it for someone not to know? Will you put one thing in the system and document another? What sense does it make? UML is already criticized because it is not usually DRY. Now it will make it clear that they must be independent?
People need to think about what they do, not follow silly rules that they don’t know because they were invented.
How did you use tag I have to say that the terms used are correct for UML, but for Java are not.
1
As far as I know, there’s no general rule for all cases. This will depend a lot on who will need your diagrams, because UML is a notation used in communication between developers. Developers both those who are collaborating with you now and also those who can continue the project in the future.
Therefore, it is necessary to analyze whether you or someone will need to know if the system has a certain method or attribute and what its function in the system is. That’s why many say that getters and setters do not need to be placed as they are not relevant to most people.
Browser other questions tagged java uml
You are not signed in. Login or sign up in order to post.
Did any of the answers solve your question? Do you think you can accept one of them? Check out the [tour] how to do this, if you haven’t already. You would help the community by identifying what was the best solution for you. You can accept only one of them. But you can vote on any question or answer you find useful on the entire site.
– Maniero