C # PureMVC Learning notes

Source: Internet
Author: User

Reference: http://www.cnblogs.com/skynet/category/441705.html

Http://www.jianshu.com/p/904b36ad37e2

PureMVC

Gameobject: Basically the bottom level, except for unity's own components, not relying on PureMVC any class.

Mediator: Relies only on gameobject, and Gameobject one-to-two bindings, Gameobject input is passed through events (event) to the mediator call.

Command: The lowest level, through the message system and mediator communication, relying on proxy (because sometimes you need to get the entity through a proxy to perform some operations, proxy only do some data manipulation, so do not send messages through the message system to the proxy).

Proxy: At the bottom, there is no dependency on any class other than the corresponding data class.

View: Singleton, in addition to a message system with an observer pattern embedded in it, is only responsible for managing mediator

Controller: In a single instance, the message system's listener method is called internally, and its responsibility is to manage only the command

Model: Single case, responsibility only to manage proxy

Facade: Single case, responsibility management View,controller,model, because view has a message system, so it also has the ability to send messages indirectly

Notifier: A feature class that invokes a facade message system to notify other objects, so essentially sending a message in the message system (OBSERVER) that calls view

From the functions of these classes, it can be seen that the responsibilities of each class are very simple and the functions are separated very clearly. If unity could use the new C # features, it would be better to optimize.

Personal thoughts:

1.Controller is the type that is used to create an object, which invokes the method, and instantiates a class each time a command executes. Not very friendly to Unity's GC, you can use a cache-instantiated class to solve

The 2.Observer message system uses the method name (string) of the reflected object to invoke the method of observing the object, and can use a stored delegate or event to invoke the method of observing the object

It is important to note that at first it is easy to confuse and not know which logic to write. My personal understanding is that mediator class only write logic related to Gameobject, such as some animation, behavior, proxy only write and data manipulation logic, such as adding and deleting, command to write some verification logic, such as the use of regular expressions to determine whether compliance with the requirements, etc. Or first read some data from the cache, anyway, try not to access the proxy frequently, because proxy may want to remotely connect to the server to obtain data, slower.

C # PureMVC Learning notes

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.