java object-oriented

What is object-oriented:

   Is the transaction into classes, properties, and methods described using the characteristic of him;

Object-oriented three characteristics:

1, packaging
property and realize hidden object details, just outside the provision of public access, isolate change, easy to use, improve reusability and security.
2, inherited
improve code reusability; polymorphism is a prerequisite succession.
3, polymorphic
parent class or interface defined reference variable can point to a subclass or instance of an object implementation class definition. Increase the expansion of the program.

Five basic principles:

1, single responsibility principle SRP (Single Responsibility Principle)
class of functions to be single, not all-inclusive, like with grocery store.
2. Open Closed Principle OCP (Open-Close Principle)
a module for the expansion is open for modification is closed, you want to add features warm welcome, you want to modify, oh, ten thousand is not happy.
3, the replacement in principle LSP (the Liskov Substitution Principle LSP)
Sub parent class may alternatively appear anywhere in the parent class can occur. For example, you can represent your dad go to your grandma house work. Haha ~ ~
4, Dependency Inversion Principle DIP (the Dependency Inversion Principle DIP)
high-level modules should not depend on low-level modules, they should depend on abstractions. Abstract should not depend on the specific implementation, the specific implementation should depend on the abstract. What you say you are Chinese people go abroad, but you can not say which of the village. For example, Chinese people are abstract, following a specific province xx, xx city, county xx. You have to rely on abstract Chinese people, are not you xx village.
5, the interface separation principle ISP (the Interface Segregation Principle ISP)
using a plurality of clients associated with a particular class interface than using a common interface better design. For example, you have a phone call, watch videos, play games and other functions, these functions split into several different interfaces, much better than in an interface where.


At last

1, will make the abstract more complex issues simple.
2, from the previous process-oriented executive, became commander Zhang mouth.
3, object-oriented and more in line with human thinking, the thought process-oriented machine



Guess you like

Origin www.cnblogs.com/wzq-xf/p/11775057.html