0

I have the Class Diagram (from my system that was coded in Java), where the Class Diagram consists of the Business Logic and it has classes like Student, Exam, Topic, Question, etc.

The thing is I want to know if I should add the getter and setter methods to each class of the Diagram (because they're in the code) as well as the constructors and toString methods.

... Or is it better to add only the methods in those classes that were coded by me?

I'm asking because this is a homework for college and maybe the professor doesn't like to see these "auto generated methods" in the Diagram. What's your recommendation?

Does it matter if any class stays "empty"? I mean, without methods or with no attributes in case the class extends them from the superclass.

John Smith
  • 65
  • 6
  • 1
    They're not autogenerated, you decided to generate them using the IDe (Eclipse, NetBeans or whatever). Note that in the end you could type the constructors and methods by yourself in a plain text editor. If these constructors/methods don't exist, then your classes can't use them. – Luiggi Mendoza May 21 '13 at 01:39
  • Additional note: an *empty* class is useless. Why would you design an empty class? What would be its meaning? If you have empty classes, then there's a huge problem in your design. – Luiggi Mendoza May 21 '13 at 01:39
  • @LuiggiMendoza For example, I have `OpenQuestion` which extends from `Question` and it uses the attributes from `Question` like the topic and the description and it has it's own constructor. – John Smith May 21 '13 at 01:45
  • If it does nothing that just extends the class, then what's its meaning? If it overrides a method (at least) then add the overridden methods in this `OpenQuestion`. – Luiggi Mendoza May 21 '13 at 01:46
  • @LuiggiMendoza Classes that extend, but add no functionality, may still have semantic meaning. A trivial example would be exceptions that do nothing more than define constructors. While I wouldn't say it's *common*, it's hardly unprecedented. – Dave Newton May 21 '13 at 01:48
  • I could think of a few valid reasons for an empty class, but I think in general @LuiggiMendoza is on the right track. Uh, see Dave's comment 10 seconds earlier :) – Maarten Bodewes May 21 '13 at 01:48
  • @LuiggiMendoza Ok, thank you. So back to the initial question, you say I should add all the methods in my diagram? – John Smith May 21 '13 at 01:50
  • @JohnSmith in short, yes. You should add all the methods in your classes and the overridden methods in subclasses. – Luiggi Mendoza May 21 '13 at 01:51
  • @DaveNewton Thanks, I meant something like that, a class that does only a few things but it gives a meaning to the program. – John Smith May 21 '13 at 01:56

0 Answers0