[ZT] When using UML, you must transfer from Functional thinking to Object thinking, how should you practice?

xiaoxiao2021-03-06  24

Function Thinking is also known as a modular thinking. Object thinking is also known as components. The transfer of these two thinking is a change of thinking habits (PARADIGM SHIFT).

Any habit of change is mostly practiced, and new habits will gradually replace the old habits.

From traditional Module thinking to Component thinking, the practice of transition is the basis for developing N-Tier systems. First talk from the traditional module structure. For example, many people familiar with:

Figure 2-1, the example of traditional program modules

The big function module is divided into two small functional modules. Due to the small functional module of the Function Call, the relationship is formed on Fig. 2-1. Change your daily life experience to make a metaphor! As shown below:

Figure 2-2, module concept in everyday life

The work of "Cooking" includes two fine works - "washing" and "cooking". Today we have to practice:

See module or function

-----> Lenovo WHO Performs IT

If you are doing vegetables, three jobs in the washing and cooking are all as "big", as well as: Daxie is the executor of these three work (Performer), or called Worker. Then you can imagine as follows:

Figure 2-3, trying to imagine the worker behind the module

In Figure 2-3, workers seem to be stealth behind the module. Next, it is necessary to highlight the worker, the module is hidden behind. This worker or executor is a component or object (Object). Then indicate the call of these modules in an arrow.

Figure 2-4, highlighting the components

The components have been highled on Figures 2-4, but the concept of "call" (call) is still too functional. Then you can further refer to "Message Passing", indicating that the component passes the message to the component, as shown below:

Figure 2-5, message communication between the highlighting components

Although it is necessary to find out the appropriate Performer, some experience may also be changed, and this PeFormer may also change with the time and space environment, but I hope you don't worry. More important and fundamentally: Are you accustomed to finding each Function's Performer. This is the key. Because I am not used to, I am not easy to quickly find the ideal Function's Performer. This is the key. Because I am not used to, I don't easily find the ideal performer, even if I find it, it is not easy to judge appropriate or inappropriate. So practice is very important. After practicing, you will be able to drive. Let's continue practicing! If you analyze two Performer as follows:

Figure 2-6, there are two Performers

You can imagine as follows:

Figure 2-7, there are two components

The responsibility of the big man is to be cooking and washing vegetables, but not cooking. So, look at the picture 2-7 and imagine: "Daxie" object in the process of "cooking", will send a message to "two" objects, request "two" help "cooking".

If one day, the distribution of work changes to:

Figure 2-8, the assignment of the responsibility changed

The practice imagination is as follows:

Figure 2-9, two-year-old work

Looking at the picture 2-9 and imagined: Daxie in the process of "cooking", please send a message first, please "toilet, then send the message to two, please" cook the dish ".

If one day, the distribution of work changes to:

Figure 2-10, the assignment of responsibility has changed

The practice imagination is as follows:

Figure 2-11, three components cooperate with each other

Looking at the picture 2-11 and imagined: Daxie in the process of "cooking", please send a message first, "Washing the dish, then send the message to three, please" cook the dish ".

After familiar with component thinking, you should also enjoy the benefits of the component. It is: These Performer is a dispersed location (location or site). That is to say: The component may be dispersed at various locations.

Distributed components (Distributed Component)

E.g:

Figure 2-12, more complex responsibility assignment

If each of the three components fall in different computers, the message they passed must be passed through networks such as WAN / LAN or Internet. Then I would like to be as follows:

Figure 2-13, distributed components

In this way, the program code of an application (AP) is dispersed into different components in different computers, and when the AP is executed, the three computers are jointly completed, and the AP should be provided ---- "Cooking . This AP is composed of three components, of which Dagu serves as the master, and the second and three-year-old assistance is completed. Such a program is called a Distributed Application.

Since it is composed of several components, it is called a component-based application. Component program

The advantage is that it is easy to disperse, and the modular program is not easy to disperse.

Finally, summarize the above practice:

※ The intercounting calls (CALL) between the traditional function, and the Mutage Passing.

※ Simple rules are -----

See "See" Cooking () Call Washing () "

------> Lenovo:

"When PERFORM is cooking (), when

Will pass the message ----- "Washing" to the second,

I will go to the wash dish () "

Reference

[Allen98] P. Allen & S. Frost, Component-Based Development for Enterprise Systems, Sigs, 1998. P. Allen & S. Frost, Component-Based Development for Enterprise Systems, Sigs, 1998.

Pasted from Mr. Gao Huan Tang's Body Guide Magazine

转载请注明原文地址:https://www.9cbs.com/read-40261.html

New Post(0)