Splitting Classes

Classes should be examined to determine if they are following the golden rule of OO, which states that a class should do one thing and do it really well. They should be cohesive; for example, a StudentInformation class that contains information about the Student actor as well as information about what courses the student has successfully completed is doing too much. This is better modeled as two classes—StudentInformation and Transcript, with an association between them.

Often, what appears to be only an attribute ends up having structure and behavior unto itself and should be split off into its own class. For example, we'll look at Departments in the university. Each Course is sponsored by a Department. Initially, this information ...

Get Visual Modeling with Rational Rose 2002 and UML now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.