Grokking the Object Oriented Design Interview
Vote

0% completed

What is UML?

What UML gives you in this interview

Fourteen diagrams, four that matter

Where the symbols come from

What an interviewer is not checking

How much to draw

Key Takeaways

UML stands for Unified Modeling Language. It is a standard set of symbols for drawing a software design. Because the symbols are standard, a design drawn by one engineer can be read by another without explanation.

That is the whole of it. UML is not a programming language, it does not run, and it does not generate anything. It is an agreement about what a line with a filled diamond on one end means.

The agreement matters because the alternative is worse. Before UML, competing notations meant every diagram came with a legend. Two engineers could draw the same design in two unreadable ways.

UML replaced them decades ago. It won because it can express the ideas of object oriented design.

What UML gives you in this interview

Three things, in the order you will meet them.

It makes a design visible. Twelve classes described in sentences are hard to keep in mind. The same twelve as boxes with lines between them can be read in seconds. That is why an interviewer asks you to draw rather than describe.

It makes a decision explicit. Whether one class owns another, or only points at it, is a real design decision with real consequences. In a sentence it is easy to leave vague. In a diagram you have to pick a symbol, so you cannot stay vague.

It makes disagreement cheap. An interviewer who thinks a relationship is wrong can point at the line. That conversation is the interview going well.

Fourteen diagrams, four that matter

The current standard defines fourteen diagram types, split into two groups. Structural diagrams describe what a system is made of: class, object, package, component, composite structure, deployment and profile. Behavioural diagrams describe what it does: use case, activity, sequence, state, communication, interaction overview and timing.

You will not draw fourteen. This course uses four.

Image
  • Use case diagram. Who uses the system, and what can each of them do. Drawn early, before any class exists.
  • Class diagram. What the classes are, what each holds, and how they connect. This is the answer to the question, and the one diagram every interview expects.
  • Activity diagram. The steps of one flow, and where it branches. Drawn for the one or two flows that carry the design.
  • Sequence diagram. Which object calls which, and in what order. Drawn when the order is the interesting part.

The class diagram is the only one of the four that maps directly onto code. That is why it carries the most weight. The other three exist to get you to it, or to explain it once it is drawn.

Where the symbols come from

One piece of history is worth knowing, because it explains why the notation feels the way it does.

UML was assembled decades ago from three competing methods, each with its own symbols for the same ideas. That is why it is large: it had to satisfy three sets of users. It is also why nobody uses all of it.

Every team that draws UML picks the subset it needs. This course picks the four diagrams an interviewer expects.

What an interviewer is not checking

This is worth saying plainly, because it saves you worry.

Nobody is grading your notation. Suppose you draw an aggregation diamond where composition belongs, then say which you meant. That is a conversation, not a mark against you.

If you forget the exact arrowhead for realization, say "this one implements that one" and draw something. The model is the answer; the notation is only how you show it.

What is checked is whether the diagram and your words agree. A line you cannot explain is worse than a line you did not draw.

How much to draw

A whiteboard answer usually ends up with one class diagram and one activity diagram. The use case diagram is often spoken rather than drawn, as a list of actors and what each does. The sequence diagram usually appears only if the interviewer asks for it.

If time is short, draw the class diagram and describe the rest. If you have only one picture, it should be that one.

Key Takeaways

  • UML is a standard set of symbols for drawing a design, not a language that runs.
  • Its value is that a design becomes visible, its decisions become explicit, and disagreeing with it becomes cheap.
  • The standard defines fourteen diagram types. This course uses four: use case, class, activity and sequence.
  • The class diagram carries the most weight, because it is the one that maps directly onto code.
  • Nobody is grading your notation. A line you can explain beats a line drawn perfectly and left unexplained.

The rest of this chapter takes those four diagrams one at a time. The next lesson starts with the one you draw first, before any class exists. A use case diagram names who uses the system and what each of them can do.

Rohit Bhanot

Rohit Bhanot

· a month ago

Just thinking out loud here, was wondering about practicality of UML. I haven't experienced myself or heard anybody who was asked to LLD via UML in interviews. Infact I myself never had to use UML for designing classes and specs., we would just document the class specs in plain text, then maybe have a data flow diagram to depict the flow.

While UML is technically 100% correct, so nothing wrong with it but it feel bit outdated and so it is taking the focus away from the actual problem statement to UML semantics.

Do you think there is a better or more modern, practical alternative to using UML?

Just sharing my opinion here.

Show 1 reply

Reading Progress

0%


Vote for new content

On This Page

What UML gives you in this interview

Fourteen diagrams, four that matter

Where the symbols come from

What an interviewer is not checking

How much to draw

Key Takeaways