Splitting Classes

I l @ ve RuBoard

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 was modeled as an attribute of the Course class. Further analysis showed that it was necessary to capture the number of students taking classes in each department, the number of professors that teach department courses, and the number of courses offered by each department. Hence, a Department class was created. The initial attribute of Department for a Course was replaced with an association between Course and Department.

I l @ ve RuBoard

Visual Modeling with Rational Rose 2002 and UML
Visual Modeling with Rational Rose 2002 and UML (3rd Edition)
ISBN: 0201729326
EAN: 2147483647
Year: 2002
Pages: 134

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net