Search code examples
umlsocial-networkingmodelingdiagramclass-diagram

Should notifications be a class in the class diagram?


Suppose I make a class diagram for a social network system such as facebook. Should the notifications and discussion messages have their own classes?

I do really think they should. I made a full class diagram for such a system, with notifications and messages as classes, but my teacher told me to exclude them. Now I am confused.


Solution

  • This is a very interesting question for three reasons.

    1. What’s the scope?

    This is a core question for any work that you’ll do in your developer career: what’s the scope of the system?

    • is it just core social networking functionality of one to many communication, like you had on Facebook in its early days?
    • or is it a full clone of facebook, including its messaging features, but also its advertising and moderating features?

    If it’s the first, you’ve done too much. If it’s the second, you forgot important parts.

    Rule 1: Whenever there is a doubt about the scope, clarify it with your coach/manager/stakeholder before thinking you know what there is to do.

    This will avoid you the frustration of doing work that is not valued. It will avoid your future customers the frustration of not getting what they’ve expected, or paying too much for something they didn’t ask for.

    2. What’s the approach?

    Whenever you model some software, there’s a purpose. Class diagrams can be used for different purposes. For example:

    • is it for analyzing the requirements? In this domain, you will certainly have a class for Post, Comment and UserAccounts as well as associations between them. But you’d limit yourself to the “problem space” and not address the software solution and its UI.
    • is for the design of the system? then it probably should address how the system will work, and give some more details about how the UI will interact with the domain object. This kind of diagram might be more detailed and show the “solution space”.

    Rule 2: if asked to do some modeling, always clarify the purpose. In the real world, if not asked explicitly to model, clarify the agreed approach within your team.

    3. Always clarify with the person the closest to the source

    (the subtitle is already the rule).

    Now, is the notification a part of the UI, because they shows posts that changed and it’s part of the solution design? Or is it part of the domain, because the need for notification is independently of the chosen software solution? And because moreover notifications need to be tracked and delivered, and the they will work differently on mobile apps (push) and on web pages (pull)? As you see there is some room for interpretation, and depending on his/her arguments, the teacher is not necessarily wrong.

    Conclusion

    As you see, it’s not right or wrong: there are a lot of nuances between the two. There are plenty of reasons that could justify your teacher’s position. I see at least two other unrelated ones:

    • to adapt the time of the exercise to the average capability of your class (which would be a good sign for you)
    • because the teacher already know the next questions and he/she already know that notifications will make it much more difficult (which would show that the teacher was nice).

    My advice: trust your teacher, and in any case engage a discussion to understand the arguments, before jumping to quickly on unproven conclusions.

    Key takeaway: requirement analysis and modelling are a communication activity more than a technical activity. Whenever there’s a doubt, engage discussion with your stakeholders before seeking advice from strangers on the net ;-)