Design Model 3 shooting UFOs-single Responsibility Principle

Source: Internet
Author: User

Single responsibility principle:

For a class, there should be only one reason for its change

What software design really needs to do is to discover responsibilities and separate them from each other.

How can we determine whether an algorithm should be isolated from a class?

If you can think of more than one motive to change a class, this class has more than one responsibility. At this time, you should consider the separation of duties of the class.

 

If a class has too many responsibilities, it is equivalent to coupling these responsibilities. A change in responsibilities may weaken or suppress the class's ability to fulfill other responsibilities. This coupling will lead to a fragile design. When a change occurs, the design will suffer unexpected damages.

 

In the design of square games, the logic of falling, rotating, collision judgment, moving, and stacking games will never change.

The code of the square game is not written. Mark it first and study it another day.


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.