Designing OOP Solutions — UML and Relationships

Designing OOP Solutions — UML and Relationships

Writing good object-oriented software begins before any code is typed, in the design of the classes and their relationships. This lesson covers how to identify classes from a problem description, how to model them and their connections using UML class diagrams, and how to distinguish the different kinds of relationships that objects can have with one another.

Identifying classes from a problem

A practical first step in design is to read a problem statement and pick out candidate classes and their members using a simple heuristic: nouns often suggest classes or attributes, and verbs often suggest methods. Suppose a problem describes a library where "members borrow books, each book has a title and author, and a librarian can add new books." The nouns member, book, and librarian are strong ca