Do we need to add interface Runnable in our UML class diagram? [closed]

Tags: , , , ,



I have created a simple FlappyBird clone game with socket programming and now I am doing the UML diagram. My classes implements Runnable

Like:

static class Flappy implements Runnable{....}

and:

public class Client extends Application implements Runnable{.....}

Here what i have tried

Answer

UML is methodology agnostic. So, it all depends on the purpose of your class diagram:

  • If it is an analysis or a domain model, the Runnable is not relevant (as the other answer rightly pointed out)
  • If it is a design model, i.e. a model that explains how your solution works, it depends how relevant Runnable is for your design:
    • if nothing in your solution requires a Runnable, you don’t need to show it.
    • if one class expects to use a Runnable or if the class is expected to provide this interface in the larger view of the component design, then you should show it.
  • If it is an implementation model, i.e a model that aims to document precisely how your solution is implemented, the Runnable should be documented. Be aware that the use of such detailed implementation models is good for school-work but is not an interesting option for real world projects because it’s difficult to maintain and somewhat redundant with the code, unless you have reverse-engineering tools that can generate the diagram for you.

If you decide to show the relation, you’ll have to rework your graphical layout:

  • the arrow head must be replaced with the blank triangle of generalization. A plain arrow head is ambiguous and could mislead the reader to think that it’s a navigable association (in principle shown with an open arrow head, but an arrow head nevertheless)
  • but since Runnable is an interface, and your classes implement it and do not extend it, you should use a dashed line to show that it’s the realization of an interface (which is a dependency, with a slightly different meaning that the inheritance/generalization).


Source: stackoverflow