Structured approach and object-oriented approach

Source: Internet
Author: User

Structured approach and object-oriented approach

First, Introduction

When it comes to structured methods and object-oriented approaches, it is estimated that before the junior year we will have a blank face, but experienced a third semester of study, in fact, these two methods have completely penetrated our various aspects of learning and homework, recalling its reasons, may be because of our previous study, Not very focused on the level of the system to look at the problem, only to focus on a part of the task to complete, so for these system development of the terminology is unfamiliar, this semester first put aside the software engineering learned not to say, a single look at other courses, such as databases, is a system development process, The development method used in our database is a typical structured method. In the process of discussing the structured development method, the author will take our database development as an example to illustrate the various benefits of structured development. And for the object-oriented approach, although in the course of this semester is not involved, but our software engineering project "Multilevel Elevator scheduling system" is actually a system based on the object-oriented development method, which is also an important example of our learning in object-oriented class, around the operation of the elevator, Elevators can be abstracted as a class, for our multi-level elevators, we only need to do a further generalization of the class we set. So in fact, before we talk about the two methods, we have a certain understanding of both methods, the following I will be from the design and implementation, methods and applications, two aspects to talk about the difference between the two and contact.

Second, design and implementation

The structured approach, as the name implies, is a structured approach to the system, one-step refinement for a whole system, split into subsystems, and more branches from subsystems.

There are three basic concepts in the structured approach: top-down, modular, and sentence structuring. [1]

In my understanding, the structure design and analysis is the top-down analysis, and realized, is a bottom-up recursive implementation process-the design process, we browse through global, from the top of the large system, the refinement of our design, to each small module, when implemented, from a sub-module subsystem to implement, The final synthesis of our entire system architecture.

Take the database design as an example: the database curriculum design is beginning in the system Design report, in this report, we will design the entire database from the topmost level, according to the user's function and the demand, the system stratification, refinement entity.

For example, our database data flow chart as follows, this is a top-down structured approach, of course, this is only a 0-layer streaming diagram, after that, we will be for each small module of the 1-level data flow diagram analysis, a difficult to achieve the implementation of the large system, and finally disassembled into a hierarchical small module.

Fig. 1 A schematic example of a 0-layer data flow graph based on database course design

In our implementation of the process, only need to control each data Flow Diagram sub-module, design the corresponding table items, complete the corresponding function and data stream relationship, can be the specification summary, bottom-up, and finally obtain the entire system.

  

  Fig. 2 The structural method of the multistage elevator dispatching as an example

And the object-oriented approach, derived from the real world of an abstraction, he is a closer to the human thinking mode, different from the systematic design implementation pattern, he focused on the whole system is broken down into the collection of objects, rather than the collection of functions, each object has its own responsibility, the object of mutual collaboration to complete the task entrusted to the user.

the three ideas of object-oriented approach: encapsulation, inheritance, polymorphic edges the core principle of object-oriented approach is well illustrated. [2]

In the design and implementation, the object-oriented approach can be summed up, design objects and implement objects. The object-oriented approach focuses on the collection of objects that participate in the system. Each object can exist independently, in a whole to form a system, so there is no structured method between the object of the parent-child relationship between the modules, strong dependencies, and not like structured design, top-down orderly design.

For example, the elevator system, our focus from how to achieve a system can control the elevator, to how to achieve an abstraction for the elevator, when you abstract good elevator, you are equivalent to build an elevator, this time, you can make it into a lot of elevators, in different requirements of the system to meet different requirements for use , which is the basic embodiment of the so-called seal inheritance and polymorphism. Unlike structured design methods, our focus is not on how each function of the elevator system should be implemented: how to open the elevator door, close the door, control the rise and fall, of course, these things finally in the system we will also achieve, but our basic goal is to make an elevator. And the rise and fall, is just a task that you give to the elevator. The focus of the design is different, the main points of implementation are also distinguished, as the implementation of the structured method is the sub-module aggregation protocol, the object-oriented implementation is the object and the relationship between the construction.

  Object-oriented method the UseCase instance and class diagram example in UML diagram are contrasted with the design implementation of the above structured method, and the focus of implementation method is not limited to the level and function, but the completeness of the object and the method of using the object.

Figure 3 Elevator Module class diagram

Figure 4 Elevator system use case diagram

Iii. Methods and Applications:

From the abstraction of the system level down, although we talk a lot about the structure of methods and object-oriented approach to the characteristics and ideas, but what is the structure of the method, what is the object-oriented approach? What are their current application scenarios? These may be the ones we care more about.

3.1 Workaround:

structured method, also is a process-oriented programming embodiment, program code with a function aggregation to solve the actual problem, in this type of program, the programmer can always give him the most direct solution to a practical problem. This straight-to-straight code style brings efficient code handling: we don't need to focus on the model architecture of the whole problem, we just need to focus on the core of the problem and how to solve it. Structured program, more like we do the solution of the problem, each step of the formula is to solve the problems. [3]

such as an application problem, go to the market to buy things, give us a shopping list, let us ask for the money we need to spend.

In this problem, the structural approach concerns the sub-problem is that each fruit corresponding to the unit price is the number of shopping list, the aggregation of the system is the sum of all these fruit prices. All we need to do is to find the unit price of the corresponding item according to the list, make the calculation, and then sum up all the calculation results.

Figure 5 Structured approach to the problem of buying fruit

Obviously, this kind of program is a completely programmer-controlled program, after getting a specific project task, the programmer can use its code and procedures to solve the task the fastest, you need to provide to the outside world is a window of input and output, the rest of the structure is a black box is summed up, No extra user interaction is required.

The object-oriented method is an object-oriented programming embodiment. Many classes are abstracted from the code, and we implement our programs by using the classes we design. Can understand an object-oriented problem solving process, but also an application problem, and we do not go directly to the formula to solve the application problem, but to build a model about the problem, from the model to generalize to our application of the problem to solve, because its design function has redundant situation, So its code efficiency is certainly not as efficient and straightforward as the structured approach. But this style is user-friendly, control the entire problem architecture is no longer a programmer, programmers give a general model of the solution, this method, the programmer is not a solution, but a number of tools to the solution. [3]

Then use the above example to do an example of the problem.

In the use of object-oriented methods, the program is often not such a price summation formula, the program will start from the fruit this class as the origin, that is, the purchase of a fruit problem abstract known as the user of the fruit of a purchase action. From the fruit can be achieved on different fruit including oranges, bananas, apples, different definitions, which we are concerned about their respective unit price difference, the user's purchase list is the object of this, the whole process of implementation is closer to the real process of buying fruit: the object in front of the user is like a fruit, Users do just pick out what they want, and the price tag is naturally on top.

Figure 6 Object-oriented approach to fruit problem description

3.2 Application Scenarios

Applications from their respective solutions to the problem, we can understand their respective application of different scenarios.

For the structured method, it is more suitable to exist in all kinds of scientific calculation, analysis of the program-these problems are often black-box class problems, we are concerned about the input and output, of course, the most important is the efficiency of the operation. This coincides with the main features of structured programming. When calculating a fluid dynamics equation, of course, you will think of the construction and solution of the various mechanical equations, the popular division of Finite element analysis, and do not want to abstract a fluid into a class, describing the nature of the fluid to solve the problem. In mainstream scientific computing languages and tools such as: Fortran,matlab, the idea of structured programming remains at the core of their construction.

Of course, this also has a great relationship with the history of development, computer programs, in the early use, more is as a solution to solve the problem of computing problems are widely popular and development, with the computer in the social status of the improvement, the concept of interaction more and more people pay attention to, The object-oriented approach only leaped into the mainstream. [4]

Object-oriented methods in the current user interaction software is particularly frequent, programmers can not accurately predict the user all the behavior of the combination, so the system can not quickly and limited protocol to sub-problems to solve, even if the solution, the need for the amount of code and complexity is very large. On the contrary, the object-oriented approach with its unique advantages, can not focus on the specific set of functions and will look at the object, which is consistent with the user operation of the thinking, in this method, the user's behavior can easily be limited to the given object of the specified operation, and thus a good solution to such problems. The object-oriented approach is widely available in programs that require a lot of interaction, such as games.

Iv. Summary

Neither the structured method nor the object-oriented approach has its unique characteristics, it can not be "object-oriented to become the mainstream" this argument to negate the strong role of structured methods in specific areas, nor to the efficiency of supremacy to negate the strong compatibility of object-oriented. When we get a system, only when we fully understand and grasp the characteristics and characteristics of object-oriented and structured methods, we can integrate the two methods, use handy.

Reference documents:

[1] Baidu Encyclopedia--structured method baike.baidu.com/structured method

[2] Baidu Encyclopedia--object-oriented approach baike.baidu.com/object-oriented approach

[3] Comparative analysis of structured methods and object-oriented methods Zhangli, Qiu Journal of Shaanxi Normal University (self-scientific edition), 2001, 29 (2): 29-32

[4] The difference between the structured method and the object-oriented method http://blog.sina.com.cn/s/blog_59a104d20100a79o.html

Structured approach and object-oriented approach

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.