The last time I introduced how to abstract objects in the software system from objects in the real world, this article introduced how to abstract objects in the software system to the types that need to be created in the software system. The program uses objects during running. Therefore, you need to create (new) Objects Based on the type during running.
Abstract types from objects in Software SystemsThere are many 10 buses in the 10 bus system. Do you need to simulate every object in the 10 bus virtual system? It is unrealistic to create a number of vehicles in a simulation system. When the number of vehicles is large, there is no way to achieve this, or, if you increase or decrease the number of cars, you need to modify the system again. Since every object in reality cannot be simulated into the system, how can we simulate the real world? The common practice is to construct a type that represents a set of objects. When an object needs to be used, an object can be created using this type. Table 1 lists the attributes of the four vehicles. Table 1 automobile example
| Automobile/attribute |
No. |
Direction |
Location |
| Vehicle 1 |
Liao B-31274 |
Lily villa-shahekou Railway Station |
300 metres from Huanghe Road |
| Vehicle 2 |
Liao B-31288 |
Lily villa-shahekou Railway Station |
50 meters of Software Park Road |
| Auto 3 |
Liao B-32293 |
Shahekou Railway Station-Lily Villa |
200 metres from Southwest China Road |
| Vehicle 4 |
Liao B-31287 |
Shahekou Railway Station-Lily Villa |
Xi'an road 150 meters |
The process of creating a car type is to delete the specific value of the object to form an abstract object. Then, the objects without attribute values are the same. This object is the abstract type. After deleting the property value, all the above car objects are changed to: a car has a serial number with a direction and a position. In this way, you can create a type in the software system: Car: has a serial number with a direction, there are locations. This abstract process is to delete the specific attributes of an object.
Create object based on typeAfter abstracting the type, if you need to describe Vehicle 1, you can create
AutomobileType object, and then assign the license plate number to "Liao B-31274", the direction assigned to "Lily villa-shahekou Railway Station", the location assigned to "Yellow River Road 300 ". In this way, an object in the software system is formed, and it represents a car in the real world. Next introduction to how to implement it in Java. Last time:
Lecture 2 Relationship Between Software System Objects and real-world objectsNext time:
27th class definitionLi xucheng csdn blog: Why? U= 124362 & C = 7be8ba2b6f3b6cc5