Why do you need object graph
modeling?
An object diagram is a diagram
that describes objects and their relationships, and
to learn an object diagram, you must first understand
what an object is:
Here's
the dictionary in English as it explains:
Object:a
material thing that can be seen and touched。 |
Translated:
Object:
is a material thing that can be seen and touched. |
The world we see, so to speak,
is made up of objects. Because there are so many objects
in the real world, people use the way of classification,
abstracting objects into classes, so most of the words
in our vocabulary are not describing objects, but
describing classes (abstractions of a group of objects
with similar characteristics and behaviors). For example:
people, horses, tables, cars, airplanes.
To recap the previousUML
Diagram: Class Diagram, an introduction
to the relationship between objects and classes:
Object
diagram is the crystallization of object-oriented
thinking, which describes things in the objective
world from the perspective of objects:
- The object is the existence of the objective
world, which occupies space
- It has an internal composition
- External performance characteristics
- Have behavior
- It interacts with the outside
There are many real-world objects, abstracted
into classes:
- Give a class a name that reflects the instance
of the object it represents
- Describe the characteristics of an object with
attributes
- Methods describe the behavior of an object
The relationships between objects are abstracted
into the relationships of classes: association,
aggregation, composition, generalization, implementation,
and so on. |
As you can see, objects are the
basis of abstract classes, but most of the time, we
see class diagrams, and we rarely see people drawing
object diagrams. So, are object graphs useful? Let's
look at the following examples:
As can be seen from the above
legend::
The
relationship between the object graph and the
class diagram:
The object graph is closer to the graph of the
objective world, and it is best to model the object
graph before abstracting the class diagram, so
that the class diagram can be landed. It's like
the philosophical view that "theory comes
from practice". |
Objects exist objectively, and
no two objects are exactly the same, so how do we
understand the vast and complex world? How do you
describe so many objects? The objects we describe
are actually mappings of objective objects from a
certain perspective, and these objects seem to be
different, but may be composed of the same smaller
objects. Just like in the example above, we first
find the objects from a macro perspective: the map,
the snake, and the food, and then analyze their internal
connections - the map, the snake, and the food need
to be able to correspond to atomic units, so that
we can determine that the snake has eaten the food,
and the food is somewhere on the map. In this way,
we find the basic object of "node", the
map is located according to the coordinates of the
node, the snake is composed of nodes, and the food
is also a special node (which can be eaten), and this
process of finding the basic object is like the material
world finds atoms, organisms find cells and genes.
At this time, we will have a thorough understanding
and may have the ability to manipulate things. This
is also the key to the analysis and design of the
game of Snake.
The
key to object modeling:
Finding the basic objects that make up them among
the many surface objects is the key to discovering
patterns and commonalities, and the only way to
simplify and solve problems. |
What is there in the object
diagram
Any UML diagram has semantics,
elements, relationships, and uses, and the following
is a list of object diagrams:
Semanteme |
Describes the state
and relationship of an object at a certain point
in time |
Element |
Object |
Relationship |
Links
between objects |
Use |
You
can describe the relationship between objects
when analyzing a class; It can be used to describe
the current snapshot of the object at runtime |
Legend: Snake game object diagram
In order to make the reader see
more vividly, the usage of the object diagram is introduced
in the form of a legend, and the following is the
object diagram of the snake game:
Description of the object diagram:
The following is a description
dictionary of the class generated based on the object
graph:
Serial
number |
Element |
Illustrate |
1. |
tail:Node |
The
tail of the snake is a node object |
2. |
body:Node[
] |
The
body of a snake is a set of node objects |
3. |
head:Node
|
The
head of the snake is a node object |
4. |
food:Food |
Food,
there is only one food on the map The properties
of the
food object are currently:
PointX=8
PointY=8
Width=1 |
5. |
snake:Snake |
Snake
object, composed of multiple objects: head, body,
tail The properties of the snake object are currently
as follows:
Direction=up
Score=10
Longth=11 |
6. |
map:Map |
Map
object with a food object and a snake object
on it The map object's properties are currently:
Width=100
Color=white
Height=100 |
Note: The model in this paper
uses the modeling tool EA to model, generate code,
and generate database.
UML Diagram Series:
Postscript
I hope you have benefited from reading this.
If you are willing to share your experience, please submit it to us.
If you are interested in our training, consulting and tools:
|