Rules of the analysis class

Source: Internet
Author: User

1)Each category has three to five responsibilities..

In general, classes should be kept as simple as possible. This usually limits the number of 3-5 roles that a class can support.

2)No independent class exists.

The essence of good OO analysis and design is that the mutual collaboration between classes will benefit users. similarly, each class should collaborate with a small number of classes to provide all the expected functions. classes can delegate some of their responsibilities to other auxiliary classes that focus on specific functions.

3)Be careful with some very small classes.

Sometimes it is difficult to strike a correct balance. if the model seems to have a large number of very small classes and each class has only one or two responsibilities, you should take a closer look to integrate these small classes into a larger class.

4) Beware of several very large classes

? The opposite is that the model has very few classes, but each class has a large number of (more than five) responsibilities. the policy for solving the problem is to view these classes at a time. check whether each class can be divided into two or more smaller classes that can take appropriate responsibilities.

5) Be careful with "pseudo classes"

A pseudo-class is actually a function of a general process. It is disguised as a class. grady Booch tells an anecdote that a very simple system has thousands of classes. after careful review, each class has an operation named Dolt () (dumb). When analysts are used to top-down functional decomposition techniques, the first time they were dealing with OO analysis design, the pseudo class is always dangerous to him.

6) Be careful about "omnipotent"

There seems to be a class capable of undertaking any work. let's look at the classes named "System" and "Controller". The strategy to solve this problem is to look at the responsibilities of the omnipotent classes to break down the uncohesive subset. if possible, each set of these cohesion responsibilities can be separated into independent classes. these smaller classes collaborate to implement the behavior provided by the original omnipotent class.

7) Avoid the deep inheritance tree

The essence of a well-designed hierarchy is that each level in the hierarchy should have a well-defined purpose. it is easy to add many levels that actually do not serve any purpose. in fact, a common mistake is to use inheritance to implement a Function Decomposition. Each abstraction layer has a responsibility. in any aspect, this is meaningless and will lead to complicated and difficult-to-understand models. In analysis, inheritance is only used to exist in the problematic domain and is clear, this is an obvious inheritance level scenario.

From <UML and Unified Process use read-oriented analysis and design> > P108 pages

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.