Second, Java object-oriented (2) _ software development method

2018-04-29

existence must be reasonable 

 

software development method

 

1. Process-oriented

  " Procedure Oriented " (Procedure Oriented) is a process-centric programming idea. These are programmed with what is happening as the main goal.

  Process-oriented is to analyze the steps required to solve the problem, and then use functions to implement these steps step by step, and call them one by one when they are used.

  For example, Gobang, the process-oriented design idea is the first step to analyze the problem:

   1. Start the game, 2. Heizi goes first, 3. Draw the picture, 4. Judge whether you win or lose, 5. It is Baizi's turn, 6. Draw the picture, 7. Judge whether you win or lose, 8. Return to steps 2, 9, and output the final result.

   Implement each of the above steps in a different way.

 

   

  

 

  

  The smallest procedure-oriented program unit is a method.

 

  Advantages: The performance is higher than object-oriented, because the class call needs to be instantiated, the overhead is relatively large, and it consumes more resources. For example, single-chip microcomputer, embedded development, Linux/Unix, etc. generally adopt process-oriented development, and performance is the most important factor. 
  Disadvantages: no object-oriented, easy to maintain, easy to reuse, easy to extend

 

 

2. Object-oriented

   Object-oriented is to decompose the transaction that constitutes the problem into various objects. The purpose of creating an object is not to complete a step, but to describe the behavior of a certain thing in the entire problem-solving step.

  For example, Gobang, object-oriented design is to solve problems from another way of thinking.

    The whole Gobang can be divided into:

    1. Black and white, the behavior of the two parties is exactly the same, 2. The chessboard system is responsible for drawing pictures, 3. The rule system is responsible for determining fouls, winning or losing, etc. The first type of object (player object) is responsible for accepting user input and informs the second type of object (chessboard object) about the change of the chess piece layout. The chessboard object receives the change of the piece and is responsible for displaying the change on the screen. Three types of objects (rule system) are used to judge the chess position.

  It is obvious that object orientation divides the problem in terms of functions, not steps.

  The smallest object-oriented program unit is a class.

 

    

 

  Advantages: easy to maintain, easy to reuse, easy to expand, because object-oriented has the characteristics of encapsulation, inheritance, and polymorphism, it is possible to design a low-coupling system, making the system more flexible and easier to maintain.
  Disadvantage: Lower performance than process-oriented.

 

  Three major features:

  1. package
  2. inherit
  3. polymorphism

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325019068&siteId=291194637