The concepts of structured methods and object-oriented methods have existed for a long time, but they are still active in the first-line, very influential software engineering development methods. The core of the structured approach is the idea of modularity and top-down design, which breaks down a complex problem and splits it into smaller problems, then splits the problem in the same way until the problem is relatively independent in one step. Whereas the object-oriented approach is to decompose the transactions that make up the problem into individual objects, unlike before, each object is designed not to solve a problem, but to describe the behavior of something in the course of solving the problem. In this paper, we will introduce the two methods in detail, and then compare the advantages and disadvantages of the two methods in combination with some examples.
Structured Approach
Structured methods include structural analysis (SA), structured Design (SD), and structured programming (SP), which correspond to the analysis, design and coding phases of software development.
Structured analysis
The structural analysis Method (structured) is a software development method that emphasizes the rationality of the development method and the structure of the software developed, and it gives a set of principles and techniques to help the system analyst to produce the function specification. It generally uses graphics to express user needs, the use of the main means there are four kinds.
1. Streaming Diagram (dfd-data Flow Diagram)
The data Flow diagram is a tool to describe the processing process, a graphical representation of the logical model of demand understanding, which directly supports the function modeling of the system.
the main graphical elements in the streaming diagram are:
→: Data Flow-flow is the path in which data travels within the system, and therefore consists of data fixed by a set of components. If the booking is made by the passenger name, age, unit, ID number, date, destination and other data items. Since the data flow is a flow of data, there must be a flow, in addition to the data stored between the data flow is not named, the data stream should be named with a noun or noun phrase.
-: Data source (end point)-represents an entity outside the system, which can be a human, object, or other software system.
0: Processing of data (processing)-processing is a unit of data processing, it receives a certain amount of data input, processing, and produce output.
Data Storage-Represents the static storage of information, which can represent a file, a part of a file, the elements of a database, and so on.
The steps to establish a streaming diagram are:
(1) from the outside: Draw the system's input and output first, then draw the system's internal
(2) Top-down: Sequential completion of the top layer, middle layer, the underlying streaming diagram
(3) Decomposition by layer
2. Data dictionary (dd-data Dictionary)
data dictionaries are the core of structured analysis methods. A data dictionary is an organized list of all system-related data elements, along with precise and rigorous definitions that allow users and system analysts to have a common understanding of input, output, storage, and intermediate results.
The purpose of a data dictionary is to interpret the named graphical elements that appear in a data flow diagram (DFD), usually containing information such as name, alias, where to use/how to use, content description, supplemental information, and so on.
3. Decision Tree
When using decision tree to describe, it is necessary to distinguish the decision condition from the text description of the problem definition, which is the judgment conclusion, to find the subordinate relation, the side relation and the choice relation between the judging conditions according to the connection words in the descriptive material, and construct the decision tree according to them.
4. Judgment Table
The decision table and the decision tree function Similarly, when the processing of the flow chart depends on the value of multiple logical conditions, that is, the completion of the processing of a set of actions is due to a set of conditions of the combination of values, the use of the decision table description is more appropriate.
The decision consists of four parts: (1) basic condition, (2) condition item; (3) Basic action; (4) Action Item
The steps for structured analysis are as follows:
① analyzes the current situation and makes a DFD that reflects the current physical model;
② deduces the equivalent logical model of the DFD;
③ Design new logic system, generate data dictionary and primitive description;
④ establishes the human-machine interface and proposes a DFD for the physical model of the target system;
⑤ determine the cost and risk levels of the various programmes and analyze them accordingly;
⑥ Choose a scheme;
⑦ establish a complete requirements specification
Structured design
In the structured analysis phase, we generate a flow chart. The structured design can easily transform the streaming diagram into a software structure. A series of continuous transformations from the input data flow in the system to the output data stream of the system form a flow of information. According to different types of data flow, it can be divided into transformation type and transactional type 2, the design steps of transactional type and transformed data flow are basically similar, the main difference between them is the mapping method from flow chart to software structure. Therefore, in the software structure design, the data flow diagram is analyzed first, then determine which type, according to the different types of traffic, through a series of mappings, to transform the flow diagram into a software structure diagram. The specific process is shown in Figure I.
Figure a data flow diagram into the basic flow of software structure diagram
Structured design method is a systematic method of designing software architecture, and according to different mapping rules, the flow diagram can be transformed into a preliminary structure diagram of software. After drawing the initial structure of the software, it is necessary to carefully optimize the initial software structure drawing according to the basic principles of structural design and relevant heuristic rules, in order to design a satisfactory software architecture.
Structured coding
The core of structured coding is the idea of modularization and top-down program design, which are mutually reinforcing. One of the characteristics of modern software engineering is that the project size is so large that it is difficult for developers to grasp the quality of the code effectively. Thus, the idea of top-down coding is put forward, through the decomposition of the original problem, people do not need to face the large-scale complex system directly, but each time only need to care about a local problem. For such a local problem, you can design the module to solve (in practice, often use the function to implement the module).
Figure 2 Top-down decomposition task
Object-oriented approach
Like the structured approach, the object-oriented approach includes object-oriented analysis (OOA), Object-oriented design (OOD), and object-oriented programming (OOP) 3 parts.
Object-Oriented Analysis
is to analyze the problem according to the object-oriented thought after conducting the system business investigation in a system development process. There is a big difference between OOA and structural analysis. OOA emphasizes the analysis and collation of the material for the OO method based on the systematic investigation data, rather than the analysis of the management business status and methods.
The OOA model consists of 5 levels (the subject layer, the object class layer, the structure layer, the attribute layer, and the service layer) and 5 activities (identifying the object class, identifying the structure, defining the subject, defining the attributes, and defining the service). In this method, we define the structure between two kinds of object classes, which is called the classification structure, which is called the assembly structure. The classification structure is the so-called general and special relationship. The assembly structure reflects the relationship between the whole and the part of the object.
Ooa to identify the instance connection while defining the attribute. An instance connection is a mapping between an instance and another instance. OOA to identify the message connection while defining the service. When an object needs to send a message to another object, there is a message connection between them.
OOA's principles include the following:
(1) Abstraction: Discarding individual, non-essential features from many things, extracting common, essential features, called abstraction. Abstraction is the necessary means of forming a concept. The abstract principle has two meanings: first, although things in the problem domain are complex, analysts do not need to understand and describe everything about them, only to analyze the things that are related to system goals and their essential characteristics. Second, by abandoning individual things in the details of the differences, extracting their common characteristics and get a group of things abstract concept.
(2) Encapsulation: It is to combine the attributes and services of an object into an irreducible system unit, and to conceal the inner details of the object as much as possible.
(3) Inheritance: The object of a particular class possesses all the properties and services of its general class, called the inheritance of a special class to a generic class.
Object-oriented design
The object-oriented design (object-oriented Design,ood) method is an intermediate transition in the Oo method. Its main role is to further standardize the results of OOA analysis so that it can be directly accepted by OOP.
Object-oriented design (OOD) is a kind of software design method and an engineering norm. It mainly includes the following tasks:
- Decide what kind of class you want;
- Provide a complete set of operations for each class;
- Explicitly use inheritance to express common ground.
By this definition, we can see that Ood is "deciding on the requirements of the class, the operation of the class, and the process associated with the class."
The goal of Ood is to manage the interdependence of parts within the program. In order to achieve this goal, Ood requires that the program be partitioned into chunks, each of which should be small to manageable, and then hide each block behind the interface (interface), allowing them to communicate with each other only through interfaces.
Object-Oriented Programming
OOP is a programming method that emerges in the early 80 on the basis of structured programming, but its true display of power and importance to the industry is the last few years. Encapsulation is the basis of the entire OOP approach and is primarily used to construct a layer of protection around the perimeter of the data segment to limit the impact of external changes, and all data access is handled indirectly by the process within the layer. The application programmer no longer has to construct the entire software in the same way that the programming language is assembled, simply by combining and reusing software integration blocks developed by the system programmer and available for others to assemble.
OOP achieves the three main goals of software engineering: reusability, flexibility, and extensibility. To achieve the overall operation, each object can receive information, process data, and send information to other objects. OOP mainly has the following main concepts:
Components: Data and functions together in a running computer program formed in the unit, the component in the OOP computer program is a modular and structured basis.
1. Abstraction: The program has the ability to ignore certain aspects of the information being processed, namely the ability to focus on the main aspects of the information.
2. Encapsulation: Ensure that the component does not change the internal state of other components in an unpredictable manner; only those components that provide an internal state change method can access their internal state. Each type of component provides an interface that is associated with other components and specifies the method by which other components are called.
3. Polymorphism: A reference to a component and a class assembly involve many other components of different types, and the result of referencing a component depends on the type of actual invocation.
4. Inheritance: Allows the creation of subclass components based on existing components, which unifies and enhances polymorphism and encapsulation. Typically, a class is used to group components, and it is possible to define a new class as an extension of an existing class, so that the class can be organized into a tree or mesh structure, which embodies the versatility of the action.
Structured method V.s Object-oriented method
From the above introduction and analysis, we can conclude: in a structured approach, data and operations are loosely linked, data can often be accessed by multiple operations, which may be modified without the developer's knowledge (it can be imagined that this happens frequently in large multi-person development projects), This results in a running error that is difficult to debug. This situation will increase the complexity of the program understanding, and the cost of verifying the correctness of the program, and in contrast, the object-oriented approach, through the use of objects, the data and operations closely together, each object through data hiding, self-management of its state (i.e., data), which makes the correctness of the validation program is possible, At the same time, due to the localization of data processing, the understanding of the program is more simple.
In addition, in the structured method, the basic unit of the program is the module, and the process of processing the transaction, in the main function, only one call to each module can solve the problem, and the object-oriented method, the basic unit of the program is the object, each object is a description of the problem of one thing in the process.
For example, if we were to design a simple Gobang game. According to the structured method, it is the first step to analyze the problem: 1, start the game, 2, the sunspot go first, 3, draw the screen; 4, the judgment wins and loses, if Black wins jumps to 9, otherwise continues executes 5;5, turns the white son, 6, draws the picture, 7, the judgment wins and loses, if the Baek Seung is adjusted to ; 9, output the final result.
If you design in an object-oriented way, you first need to identify which classes are in the system. So after analysis, we found that the whole Gobang can be divided into 1, black and white both sides, the behavior of the two parties is exactly the same, 2, the Board system, responsible for drawing the screen, 3, the rule system, responsible for determining such as foul, winning and losing. The first Class object (Player object) is responsible for accepting user input, and informs the second class object (Checkerboard object) The change of the chess piece layout, the Checkerboard object receives the change of the chess piece to be responsible to show this change on the screen, and uses the third kind of object (rule system) to decide the chess game.
From this group of comparisons, we can find that although both methods are more intuitive and ultimately solve the problem, it is obvious that the object-oriented approach is more natural, because its basic elements and their functional division directly generated in the real world, and the structured method needs to analyze the entire process, in order to design the various steps. In addition, we can also find that the object-oriented approach directly considers the function, not the more detailed steps, which reduces the complexity of thinking, but also more convenient to meet the requirements of the actual requirements of the changes caused by the change in the corresponding function, and correspondingly, because the function is split into the various steps, Structured methods tend to be very painful when confronted with this situation.
Still take just the system as an example, if the demand side proposed, not only to do Gobang game, to do a board game set, that requires the game rules can have a variety of options (Gobang rules, go rules and so on). If it is a structured approach, because each module is more independent, and each module needs to involve game rules, rather than concentrating in the same object as the object-oriented approach, then it is conceivable that it would be very painful to change the rules of the game (let alone in this case to allow the user to freely choose the game rules), It's even better to push the redo. And if the object-oriented approach to design, only need to change the rules of the object, add a few selection of branches, so that it can be judged on the different conditions of victory, for the whole system, the rest of the few need to change.
However, the object-oriented approach is not without shortcomings, the most prominent point is that it is often in performance with the structure of the implementation of the system has a large gap, one reason is that its innate support for concurrency is very weak. Because the object is stateful, each time the same method is called, a different result (such as taking the value of a property) is returned. While this leads to concurrent execution, the order in which each thread executes is critical to the correctness of the program (so that we need a variety of locks to meet the needs of development), so we want to reduce the program's concurrency for thread safety, slowing down the program speed. Non-stateful functions do not experience these problems. Another reason is that the object-oriented approach is not designed to solve the problem of efficiency, but to simplify the process of software design, development, maintenance, as can be seen from the above example. And such simplification inevitably comes at the expense of efficiency. And the structured method, since the design phase directly involved in the underlying data structure and algorithms, it can be more convenient to optimize.
While recognizing the differences between the two, we also need to realize that structured methods and object-oriented methods are not antagonistic to each other. First, OOP is a superset of the SP. A typical structured program is as follows:
... Program startvar var var
The first is the variable definition, then the function definition, and the function is called in the last main function. and the corresponding object-oriented program code is as follows:
The class is defined first, the attribute is defined in the class (corresponding to the variable) and the method (corresponding to the function), and then the object is instantiated in the main function and its corresponding method is called. This feature also makes it possible for many beginners to process the reality of the object-oriented virtual line. We can even say that the object-oriented approach is a structured approach, as it inherits many of the successful experiences of structured methods: Data abstraction, top-down, modularity, high cohesion, low-coupling, and so on.
Summary
This paper first introduces the concept and basic realization steps of the structured method and the object-oriented method. The core of the structured approach lies in modularity, and the core of the object-oriented approach lies in the abstraction and encapsulation of data and operations. By comparing the examples, we find that the object-oriented approach is more realistic, the design, implementation and maintenance are simpler than the structured method, and the disadvantage is that the support intensity is insufficient for concurrency, which leads to lower code execution efficiency compared to the program implemented by the structured method. Often requires a combination of subsequent analysis and optimization. However, we also need to realize that object-oriented approaches are not antagonistic to structured methods, and in some ways we can even view object-oriented approaches as being developed from a structured approach. The object-oriented approach inherits many successful experiences in structured methods, such as data abstraction, top-down, modularization, high cohesion, low-coupling, and so on, which can be described as the integration of practical experience of the structured method. In real-world projects, structured methods are more suitable for small projects, but when the amount of data increases, the separation between data and the methods that process the data makes the program more and more difficult to understand. The more the demand for data processing ability is, the more significant the negative effect of this separation is, then the object-oriented method becomes more suitable.
The comparison between the structured method and the object-oriented method