Those omniscient users

Despite repeating it in my courses every year, I end up getting this error from at least 10 – 20% of the students at each exam session.

When drawing the class diagram of a software application, they invariably add a User class (call it the role you want: customer, admin, professor, director, clerk and so on) and then they add the list of actions that the user can perform in that class, instead of putting them in the classes they pertain to.

So, for instance if you want a method for paying a ticket of a flight, the payTicket() method ends up in the user class!

If you have any doubt that this is correct just think that then:

  • you should put all the method triggered by user choices, in user classes
  • to invoke that action from a caller method you should do it through the user class. Something like: ¬†JohnDoe.buyTicket()
    While the right approach should be:

Attribution of actions / objectives to users is something you do at requirement specification level (e.g., when defining goal diagrams, use cases or scenarios), not at design level.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s