Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of object-oriented knowledge in UML

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces the UML object-oriented knowledge example analysis, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

1. What is the object

Object (Object) is the basic object-oriented construction unit. Is a collection of variables and methods used to simulate the implementation of some things in the world model. Such as a computer, a person, a house, etc. Of course, you can also simulate some virtual things, such as a student number, a number, a department and so on.

2. The difference between object-oriented and process-oriented.

The difference between object-oriented "what to do" and process-oriented "what to do" is that object-oriented focuses on who issues what command, while process-oriented only cares about one command.

Object-oriented is based on object and executes processing by event or message-driven object. Unlike the process-oriented design, which takes the function as the unit, it needs to use a main function at the beginning to generalize the whole program, such as building the whole program in part to the object. The object-oriented takes the data as the center, uses the class as the carrier to represent the data, and the process-oriented takes the function as the center to describe the program. Object-oriented program control processes are driven by events or messages, while process-oriented programs are executed by predetermined programs. Therefore, when the requirements change greatly, process-oriented programs often need to ReFactor most or even all of the code, while object-oriented programs can be easily constructed.

3. Objects and classes

A class is a re-abstraction of a collection of objects, and an object is an instance of a class. It can be illustrated by a simple example. Treat the Chinese as a class, then you and I are both an instance of this class. The collection of you and me, such as Chinese, has become the category of Chinese. The Chinese is an empty concept, while you and I are a real individual.

4. Messages and events

Messages are the way objects interact with each other. The message generally includes five parts: the sending object of the message, the receiving object of the message, the delivery mode of the message, the content of the message and the return of the message.

For example, Zhang San said to Li Si, "Let's have a drink today."

An event is an action predefined by the system and triggered by a specified condition.

For example, if I hit you on the head, you have a headache. Here I sent a message to you through the act of beating, and you touched the pain event.

5. The basic characteristics of object-oriented

Abstract: simplify the things to be described, summarize the characteristics of things, and organize the model according to the hierarchical structure of things.

For example: a dog. It is impossible for us to describe all the information about a dog in the software, we simplify it to have four legs, a head, a tail, and a body pole. In this way, we draw an abstract model like a picture. Then summarize its characteristics, such as it can bark, eat and walk. Then dogs are divided into pugs, wolves and many other kinds. So here again divides the dog level.

Encapsulation: tie the state and behavior of the object together and hide the internal details of the object as much as possible.

For example: a TV set, all its features and internal structure are encapsulated, we do not need to know its internal principle, we just need to know how to open it, how to change the channel is enough.

Inheritance: inheritance reflects the hierarchical relationship of objects in the objective world. As in the dog example above, our wolf dog and pug inherit from the concept of a virtual dog. Inheritance simplifies our work to a great extent and clearly shows the hierarchical relationship of objects.

Polymorphism: polymorphism refers to the ability of two or more objects belonging to different classes to respond differently to the same message or method call.

For example, when we have a blue ball in our hand, we say: let's go and play ball. The other side can clearly understand that we mean playing basketball or not football or table tennis.

Thank you for reading this article carefully. I hope the article "sample Analysis of UML object-oriented knowledge" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report