What is process orientation

When we do not have the concept of object oriented when we write the program is generally oriented to the process, we are often in the program design is to analyze the steps needed to solve the problem, and then use the function to achieve these steps step by step, when using one by one can call; That’s process oriented,

Object orientation is to decompose the transaction that constitutes the problem into various objects. The purpose of establishing objects is not to complete a step, but to describe the behavior of something in the whole step of solving the problem.

For example, if we want to wash clothes, our process-oriented design is to turn on the washing machine, put water in, put the clothes in, and start washing.

And if we use object-oriented way to define, clothes and washing machine is an object, respectively, the washing machine to open the door, water storage, laundry, can serve as the behavior of the washing machine, washing machine is an object, a washing machine by his door, let the clothes, put in, the washing machine automatic filling, automatic laundry washing machine. This is simple object oriented versus process oriented.

When we develop large systems, if we use process-oriented operations, we will have a very complicated operation process, and we use object-oriented operations to get more work.

Object oriented concept

● Object-oriented way is actually composed of OOA (object-oriented analysis), OOD (object-oriented design) and OOP (object-oriented programming) three parts. Among them, the structure of OOA and OOD needs to be described and documented in a way. Currently, UML (Unified Modeling Language) is used to describe and document the results of OOA and OOD.

● Object is the most basic concept of object-oriented method, its basic characteristics are: identification uniqueness, classification, polymorphism, encapsulation, good module independence.

OOA: Consists of five layers (subject layer, object class layer, structure layer, attribute layer, and service layer) and five activities (Identify object class, identify structure, define subject, Define attribute, and define service). In this method, two kinds of structures between object classes are defined, one is called classification structure, the other is called assembly structure. The structure of classification is what is called the relationship between the general and the particular. The assembly structure reflects the whole and part relationship between objects

OOD:OOD is an intermediate link in the OO approach. Its main function is to further normalize the results of OOA analysis so that OOP can accept them directly.

OOD is a design paradigm for solving software problems, an abstract paradigm. Object oriented Design (OOD) allows entities in the problem domain to be represented by objects, each of which has a corresponding state and behavior

OOP: The main idea of OOP is to decompose the various transactions that constitute a problem into objects, the purpose of which is not to complete a step, but to describe the behavior of a thing in the whole step of solving a problem. The concepts in object-oriented programming mainly include: object, class, data abstraction, inheritance, dynamic binding, data encapsulation, polymorphism, message passing. Through these concepts, the idea of object-oriented has been concretely reflected

Our programming is usually done through OOA to build a hierarchical model, then through OOD to organize, and finally OOP, with OOA, OOP process we focus on business and data abstraction to build a finished application

① A class is a class of things with common properties and methods. Classes are abstractions of objects; An object is an instance of a class. The class is the smallest program unit of the whole software system, and the encapsulation of the class hides all kinds of information details, and exposes the external functions provided by the class through common methods, so as to improve the cohesion of the class and reduce the coupling between objects.

② This cooperation between objects requires a mechanism, called “message”. Messages are the mechanism by which one instance communicates with another.

③ In object-oriented methods, the mechanism by which properties and operations are shared between classes is called inheritance. Inheritance is transitive. Inheritance can be divided into single inheritance (an inheritance is allowed to have only one direct parent, i.e. the class hierarchy is a tree structure) and multiple inheritance (a class is allowed to have more than one direct parent).

Field (state data) + method (behavior) = class definition

Java everything is an object, in the Java programming mind:

  1. Everything is an object,
  2. Programs are collections of objects that send messages telling each other what to do,
  3. Each object has its type,
  4. Objects of a particular type can all receive the same message

Manipulating objects with references:

Although Java treats everything as an object, the identifier for an operation is actually a “reference” to the object. Such as the String s; Only a reference is created, but no object is created. We can create objects in the following ways:

  • The new keyword
  • Class.forName().newInstancce().
  • The newInstance() Constructor of the Constructor class is called
  • Clone () method
  • Deserialization Deserialization

Create an object:

New stores objects in the heap, so creating an object with new – a very small, simple variable – is often not very efficient. So instead of creating such a variable with new, Java creates an “automatic” variable that is not a reference. The value of this variable is stored directly on the stack.

Program creation, how are runtime objects allocated? How is memory allocated?

The object that comes out of new is stored in the heap, the reference to our object is stored in the stack, and the reference to the object is stored in the stack.

Stack: Located in RAM, the stack pointer can be directly supported from the processor, and the stack pointer moves up, freeing up memory. The stack pointer moves down to allocate new memory. Java must know the exact life cycle of all items in the stack when creating a program. To move the stack pointer up and down, where “object references” are stored.

Heap: A heap is usually a memory pool. For the existence of Java objects. A heap differs from a stack in that the compiler does not need to know how long the data in the heap will live, so it has great flexibility to allocate storage in the heap and simply new an object when it is needed. This comes at a cost in terms of when unused objects in the heap are reclaimed from memory.

Constant storage: Constant values are usually stored directly within program code because they never change.

Non-ram storage: If data exists completely outside of the program, it is not under any control of the program and can exist even when the program is not running, such as stream objects and persistent objects.

Structures in other JVMS will be covered in JVM learning. It’s not in use here.

Object-oriented characteristics:

(1) Object uniqueness. Each object has its own unique identity, by which the corresponding object can be found. The identity of an object does not change throughout its life. Different objects cannot have the same identity.

(2) Abstractness (encapsulation). Abstractness refers to the abstraction of objects with consistent data structures (attributes) and behaviors (operations) into classes. A class is such an abstraction that reflects important properties relevant to the application while ignoring other extraneous things. The division of any class is subjective, but must be relevant to the specific application.

(3) inheritance. Inheritance is the mechanism by which subclasses automatically share data structures and methods of their parent class, a relationship between classes. When defining and implementing a class, it can be carried out on the basis of an existing class, taking the content defined by the existing class as its own content, and adding some new content.

Inheritance is the most important feature of object-oriented programming language that is different from other languages, which is not found in other languages. In the class hierarchy, subclasses inherit only the data structures and methods of a parent class, which is called single inheritance. In the class hierarchy, subclasses that inherit data structures and methods from more than one parent class are called multiple inheritance. Java does not support multiple inheritance. In Java we need to use a phenomenon similar to multiple inheritance, where we need to use interfaces to simultaneously implement different methods in the J interface. In the development, the inheritance of class makes the established software open and extensible, which is an effective method of information organization and classification. It simplifies the work of object and class creation and increases the reusability of code. Inheritance provides a canonical hierarchy of classes. Through class inheritance, common features can be shared and software reuse can be improved.

(4) Polymorphism (polymorphism) Polymorphism refers to that the same operation or function or process can act on multiple types of objects and obtain different results. Different objects receiving the same message can produce different results, which is called polymorphism. Polymorphism allows each object to respond to a common message in a way that suits it. Polymorphism enhances software flexibility and reuse.

That’s what we need to know about object orientation. We should go to practice, only practice can truly understand the connotation.