Structured and object-oriented programming, Object-Oriented Programming
Bytes
The software development method refers to a variety of software development strategies proposed based on the characteristics of software development to design and implement high-quality software that meets user needs within the project investment scale and time limit. With the unbalanced development of computer software and hardware in 1960s, the development of large-scale software encountered three major challenges: high complexity, long development cycle, and hard to guarantee correctness, this caused a "software crisis ". In order to improve both software efficiency and quality, software development methods are constantly being innovated. After decades of research and application, two software development methods, structured methods and object-oriented methods, based on the corresponding programming ideas and languages, have become one of the mainstream development methods, it is widely used in software engineering.
Structured methods include three parts: Structured Analysis (SA), Structured Design (SD), and Structured programming (SP. Correspondingly, the object-oriented methods include Object-Oriented Analysis (OOA) and Object-Oriented Design (OOD) and object-oriented programming language (OOP ). There are many connections and differences between the two software development methods from origin, thought, analysis, design, program design, extension reuse, and application, next, I will make a comparative analysis of the two. The two methods have their own advantages and disadvantages for different work environments and application scenarios. I will also discuss the combination of the two methods in software engineering in order to produce better results.
(1) from the perspective of origin
Both structured and object-oriented methods originate from the corresponding programming ideas and languages. In the late 1960s S, the proposal of "procedural structure theory" and "GOTO statement harmful Theory" proved that the logic structure of any program can be expressed by sequential structure, selection structure, and cyclic structure, it has established the concept of structured programming and has produced languages such as FORTRAN, PASCAL, and C. Structured Methods extend the analysis and design of the program to the analysis and design of the project, and combine the technical support of the programming language to generate and develop the program.
In 1980s, with the increasingly complex and huge application systems, structured development methods encountered some problems in engineering applications. During the same period, after 20 years of research and development, the idea of object-oriented programming gradually became mature. A large number of object-oriented languages emerged one after another, and object-oriented methods were widely favored. In the middle of 1990s, with the rise of the Internet, JAVA language was booming due to cross-platform features. At the beginning of the 21st century, joint development was not limited by time and space. Today, the mobile APP market is booming and Andriod development has become a hot topic. Object-oriented methods have become the backbone of software development methods.
The origin and development of structured and facial object methods are pattern consistent:
Figure 1: development model of software development methods
(2) ideologically
Structured Methods inherit the idea of structured program design, regard the problem to be solved as a system, and analyze and solve the problem using systematic scientific ideas and methods. Structured methods follow the principles of abstraction, decomposition, and modularization. They focus on data and functions, take modules as the basic unit, and take algorithms as the program core. They emphasize gradual refinement and information hiding.
The idea of the object-oriented method is to simulate the relationship between things in the objective world and things. Object-oriented uses classes to replace modules as the basic unit. Through encapsulation, inheritance, and polymorphism mechanisms, the data and functions, connections, and communication of objects are characterized; through object management and communication between objects, information processing and information management are computed and stored to implement software functions.
For structured methods, modules are implemented by functions to process and compute input data. Data and functions are separated. Object-oriented Data and functions are encapsulated in objects, form a whole. The difference between the two methods in data and functions is the essential difference in their thinking.
Figure 2: structured and object-oriented ideas
(3) Analysis
Modeling is to better understand the real world to be simulated and is the core issue of software development methods. In the structured method, SA is used to construct the environment model and logic model of the system. The main tools used to implement the model include data dictionary (DD), erdiagram, and data flow diagram (DFD ). A data dictionary is a warehouse defined by all system data elements. An erdiagram describes the attributes and links between data, and a data flow diagram describes the conversion of information flows and data from input to output, it also displays system and external interfaces, data input and output, and data storage application graphics technology [1]. The prerequisite for SA is requirement analysis. the modeling process is the process of iterative decomposition requirements and continuous application refinement. That is, the Data Flow Graph Decomposition starts from the top layer graph, based on the decomposition principle of a subgraph corresponding to each processing, the subgraphs are divided into 0-layer graphs and 1-layer graphs.
The object-oriented method uses OOA to define classes and models the real world. The main task of OOA is to build an OOA model with the topic layer, Object layer, structure layer, attribute layer, and service layer on the problem domain, the main tools for model implementation are Use-Case and Class digrams ). The use case diagram describes the system functions from the user's perspective, and points out that the operators of each function organize the requirement analysis. The class diagram defines the composition of the class (attributes and services), class structure and the relationship between classes, determine and divide the classes in the system. After OOA, the static model of the system is established.
Compared with structured methods, DD, ERTU, and DFD are used to describe data and functions respectively (although there are mutual references between them). In object-oriented methods, both use case charts and class diagrams are used, data and function descriptions are always parallel.
Figure 3: Data Flow Diagram
Figure 4: use case diagram 5: class diagram
(4) from the design perspective
In the structured method, SD is used to construct the behavior and function model of the system. The main tools used to implement the model include the module structure diagram (SC) and the program flowchart. The module structure diagram illustrates the system module division, module functions, data transmission between modules, and call relationships. Based on the data flow diagram, we can map the upper-layer module structure of the corresponding software. Combined with the data flow diagram, we can gradually break down the upper-layer module and design the middle and lower-layer modules. For all the modules, we need to design the basic internal structure and external interfaces of the module and optimize the module structure. Furthermore, it is to design the program flowchart for each module, sort out the optimization, and summarize the algorithm. SD is still the process of further decomposing the project system, refining the model from the logic level to the module level, and then to the program level.
OOD not only refines OOA, but also builds a dynamic model of the system. The main tools used to implement the model include the Sequence divisor and the State divisor) activity digraphs ). The biggest difference between an object and a module is that the object is "active", which means that the object can communicate between States and objects. The interaction diagram describes the interaction between objects, displays the dynamic cooperation between objects, and emphasizes the time sequence of message sending between objects. The state diagram describes all possible states of objects, and the Transfer Condition of the status when an event occurs. The activity diagram describes the activities that meet the requirements of the use case and the constraints between the activities. It is used to identify parallel activities to improve system efficiency [2].
From the aspect of design, we can clearly see the differences between structured and object-oriented. The core of a structured method is a program. from analysis to design, it is actually a process from abstraction to detail, from fuzzy to clear implementation of the program. The core of an object-oriented method is a function, it analyzes objects, designs behaviors, and separates Program Design from system design.
Figure 6: module structure
Figure 7: Interaction Diagram 8: Status Diagram 9: activity diagram
(5) from the perspective of Program Design
For example ):
int main () { int count; int money; int type; scanf ("%d %d %d", &count, &money, &type); if (type) printf ("%d", count - money); else printf ("%d", count + money);}
Structured Program Design
class Count { int count; Count (int count) { this.count = count; } int save (int money) { count += money; } int take (int money) { if(count >= money) count -= money; }}
Object-Oriented Programming
As shown in the preceding example, structured program design is a procedural "problem-solving" approach. The program only focuses on the input data and outputs the correct results. The code is a direct embodiment of the algorithm, high code efficiency; Surface object programming is an integral "modeling" approach. programs focus on real objects, rather than some data. Code is a direct embodiment of functionality, complex algorithms are often processed by one or two database functions with low code efficiency.
(6) from the perspective of extended Reuse
The structured method is the analysis and design oriented to the entire application. The program design is also a process-oriented fixed input domain, and the code orientation is obvious. Therefore, the scalability of the structured method is poor, and functional changes may compromise the entire system; the reusability is poor. If there is a nested relationship between systems, the main system can reuse subsystems; it is difficult to combine and splice, the Design and Implementation of the system are tightly coupled, and the connection is usually closed.
On the contrary, although the object-oriented method is based on applications, it is oriented to real objects. objects are highly independent and the function is the interaction of objects. Therefore, the object orientation is highly scalable. You only need to expand or modify a class, or adjust a certain communication. The reusability is good, the Object-oriented Inheritance and polymorphism mechanism greatly improves the layers and granularity of code reuse. It is easy to combine and splice. objects are the smallest unit of data and functions, and create new communication relationships for objects, A new software system can be combined.
(7) from the application perspective
The essence of the structured method is problem solving. The structured program is determined by the algorithm. The algorithm is analyzed and designed by the programmer. the execution process of the program is mainly controlled by the programmer rather than the user; in object-oriented methods, programmers design object attributes and operation methods. However, when and how objects are operated is completely controlled by user interaction.
Modeling Tools of structured methods are difficult to express highly interactive software systems. program design is integrated into system analysis and design, which is too complex or even difficult to control when dealing with large systems; the abstract mechanism of object-oriented methods provides natural modeling methods, especially to grasp the complex relationships between objects.
Structured methods are suitable for engineering computing, tracking and processing of real-time data, and various automatic control systems. object-oriented analysis is more suitable for complex application software with user-controlled program execution processes, for example, large game software and various management information system software [3].
(8) combination of the two
After the above analysis, we can see that the structured method and the object-oriented method have different advantages and disadvantages for different software systems. The structured method divides the solution space into two parts: Data and functions, so that the demand analysis and function breakdown can be performed more clearly. The data flow diagram can carefully describe the flow and change of data between different functional modules, it is more suitable for the preliminary stages of system design. After the designer has a clear understanding of the data and system requirements, the object-oriented method can encapsulate data and functions in an object as a whole, it intuitively expresses the State Changes of objects and the interaction between objects, analyzes the implementation process of functions more accurately, and is more suitable for refining the specific behaviors of the system later in the software. Based on this, the hybrid software development method is as follows:
1) Use SA for requirement analysis, build a data dictionary, and build a data flow diagram of the total and layer.
2) use the module structure diagram to design independent functional blocks of the system and create a program flow diagram within the module.
3) combine data flow diagrams, aggregate similar modules, and define classes. design class attributes and class methods based on program flow diagrams.
4) use OOD to establish a dynamic model of the system and analyze the behavior and collaboration of objects.
5) Overall object-oriented programming, detailed structured programming optimization, and code layer.
Using the hybrid method, we can make full use of the advantages of the two methods to improve the development effect and efficiency.
Both structured and object-oriented methods are system methods used to solve the increasingly conflicting software crisis. From Direct development, to structured methods, to object-oriented methods, software components become more independent and reusable, and development is carried out at a higher level, the correlation between the analysis layer, design layer, and code layer is reduced. These benefits system developers to pay more attention to functions and improve software quality. The improvement of hardware performance will make the computer more widely used, the software work environment more complex, the software functions more rich, and the software performance needs to be improved, there are more requirements for software development methods, and more high-level new methods will emerge. No matter which development method or mixed development method we use, we must make the best choice or combination based on the demand analysis and system requirements.
References:
[1] Wang hanhao, Xie jiasheng, Yan Yue, software development methods-Comparison of structured and object-oriented methods, School of mathematics and computer science, Mianyang Normal University, 2011, China, issue 1.
[2] Zhang Li, comparative analysis of structured and object-oriented methods, School of Computer Science, Shaanxi Normal University, Journal of Shaanxi Normal University (Natural Science Edition), vol. 29th, issue 2nd, 2001.6.
[3] Xu xiulin, an analysis of structured methods and object-oriented methods, Nantong Vocational University, Nantong Vocational University Journal, vol. 18th, issue 4th, 2004.12.