Combination of Starcraft php design patterns-PHP development

Source: Internet
Author: User
Tags map class
In the interstellar space, we can download maps made by others or create maps by ourselves. When selecting which map to play, we can see that the game lists the map or map package name in the current map package. Although map and map packages are distinguished by files and folders, we always hope to use objects for abstraction during development. Can we simplify the differences between map and map packages? In the interstellar space, we can download maps made by others or create maps by ourselves.

When selecting which map to play, we can see that the game lists the map or map package name in the current map package.

Although map and map packages are distinguished by files and folders, we always hope to use objects for abstraction during development.

Can we simplify the differences between map and map packages?

The problem to be solved: the code for calling these two objects should be the same, that is, in many cases, there is no need to distinguish between map and map packages.

Idea: Let's make an abstract class so that the map class and the map package class inherit from it. Many methods of this class have the same name.

Composite mode example:

 

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.