The typical object-oriented principles can be divided into two categories: class-oriented and package-oriented.Class-oriented includes: srp--single responsibility principle.ocp--Open closure principle.LSP--The principle of the Richter replacement.dip--dependency Inversion principle.isp--interface Isolation principle.Package-oriented include: The emphasis is on the cohesion of the package design requirements->rep--reuse publishing equivalence principle
Http://www.cnblogs.com/seacryfly/archive/2011/12/29/2305965.htmlOnly changes to the (unique) responsibility (requirement) of the class will cause the refactoring of the code.The single responsibility principle states that every module or class should has responsibility over a single PA RT of the functionality provided by the software, and that responsibility should is entirely encapsulated by the class.All its services should is narrowly aligned with the that responsibility. Robert C. Martin exp
obtaining time from a file or database.2. Violation of the single principle of responsibility (Responsibility Principle)SRP means that each class or method should have a single function. And this method has several responsibilities: 1. Gets the time from a data source. 2. Judge whether the time is morning or evening. An important feature of the SRP is that a class or a module should have and only one reaso
in the past, the class in the program has been used to encapsulate the inheritance polymorphism is object-oriented design, but it is notencapsulation, inheritance, polymorphism is only the three main object-oriented features, but in the design of the program is not to say that the structure of the class used (or reflected) these three properties are object-oriented,In fact, the real object-oriented design is to meet the following five principles, Five basic principles of object-orientedSingle Re
in the past, the class in the program has been used to encapsulate the inheritance polymorphism is object-oriented design, but it is notencapsulation, inheritance, polymorphism is only the three main object-oriented features, but in the design of the program is not to say that the structure of the class used (or reflected) these three properties are object-oriented,In fact, the real object-oriented design is to meet the following five principles,five basic principles of object-orientedSingle res
What is design mode? Design patterns are a set of reusable, most known, categorized purposes, code design experience Summary. Use designPatterns are designed to reuse code, make code easier for others to understand, and ensure code reliability. There is no doubt that design patterns are more in the system than othersWin; Design patterns make code compilation truly engineering; Design patterns are the cornerstone of software engineering, like the structure of a building. Two Why should I use desi
class, meaning to do too many "things" class. When developing an WebForms-based application, the page's post code includes access to the database, processing of business logic, binding page data, page event handling, and so on, which is a proof of God's class (which many people may have done).Advantages and disadvantages of the God class"Existence is reasonable"-God-like comparisons apply to smaller, stable application development scenarios where the business logic is not complex and does not r
terminology."Real World"the object of concernWhat to Do ( How),implement functional specifications through the model. OOPbased on the design, use a programming language such asJava) encoding. ThroughOOA,OODand theOOPThe main line is abstract. OodGraphical Modeling Language for modelingUML(Unified Modeling Language), UMLis a generic modeling language that we use in our experimentsUmbrello is modeled,Windowsrecommended for everyone to useStarUML.The result of a process abstraction is a function,
do it well. They should do it only. "(a function should do only one thing, do one thing well, and do it only), sounds simple but it's not easy to practice this principle, so there's a lot of bad taste in our code (see chapter III of Refactoring: improving the design of existing code). In fact, the rise of a level, we are in the design of the class should also be the case, this is the principle of object-oriented design of the single principle of responsibility (
, may also import resource waste.
1. Interface Isolation
The interface isolation principle (Interface segregation Principle, ISP) indicates that the client should not be forced to implement some interfaces that they will not use, should group the methods in the Fat interface, and then replace it with multiple interfaces, each serving a submodule. To put it simply, it is much better to use multiple specialized interfaces than to use a single interface.
The main points of view of ISP are as follow
This article describes how to obtain the mac address of all hosts in the LAN using python scapy. For more information, see obtain the mac address of all hosts in the LAN using python scapy.
The code is as follows:
#! /Usr/bin/env python#-*-Coding: UTF-8 -*-From scapy. all import srp, Ether, ARP, confIpscan = '1970. 168.1.1/24'Try:Ans, unans = srp (Ether (dst = "FF: FF")/ARP (pdst = ipscan), timeout =
they will not use, should group the methods in the Fat interface, and then replace it with multiple interfaces, each serving a submodule. To put it simply, it is much better to use multiple specialized interfaces than to use a single interface.
The main points of view of ISP are as follows:
1) The dependency of a class on another class should be based on the smallest interface.
ISPs can achieve the ability to not force customers (using methods of interfaces) to rely on methods that they do not
types. The so-called Operation name Polymorphism refers to the ability to pass different messages to the operation in order for the object to produce certain behavior based on the corresponding message.two or seven major principles7 Basic principles: the single-duty principle SRP (unitary Responsibility Principle), the open-closure principle OCP (Open-close Principle), the principle of substitution, the principle of dependence (the Dependency Inversi
Today, I have posted all the five object-oriented design principles (SRP, OCP, LSP, dip, and ISP) that I have organized some time ago. I hope they will help you, I also hope to have more exchanges with you.
General principles (from: Design Patterns explained ):
1. design to interfaces.
2. Favor composition over inheritance.
3. Find what varies and encapsulate it.
1. Single Responsibility Principle-SRP
elegant SOLID design principle to prevent someone from modifying the tested code. Ideally, if you have added new features, your code needs to be tested, which is the goal of enabling/disabling design principles. By the way, the "O" letter in SOLID refers to the principle of opening/closing the design.Single Responsibility Principle
Single Responsibility Principle (SRP)
The single responsibility principle is another SOLID design principle. The SOLID l
1. SDR descriptionSpring Data Redis (SDR), a set of simplified access to Redis APIs provided by Springframework, is another layer of encapsulation for Jedis.The SDR integrates the four open-source Redis Connector of Jedis,jredis,srp,lettuce, all of which are open source Java libraries for Redis. Among them, Jredis and SRP start from spring-data-redis1.7, it is not supported.2, Redistemplate descriptionRedis
programs load class program files under the app directory
One application is easy to handle. What should we do with a bunch of applications? The following describes the directory structure of multiple applications.
3. directory structure (anti-aging is important)
The design concept of PHP is rare, and there is no concept of a package. We had to use the directory to package the concept. Describes the functions of the directory structure from the access structure, development structure, and deplo
substitution principle, interface isolation principle and dependency inversion principle. These principles are mutually supportive and are one of the best common design methods you can use for your code. Let's take a look at each one of them.The single Responsibility principle (SRP) is the most important principle of the organization. It points out that each module should have only one responsibility and reason to change. The
/closing the design principles. By the way, the letter "O" in solid refers to the principle of open/close design. Single principle of responsibility Single Responsibility Principle (SRP) The single principle of responsibility is another solid design principle, and the letter "S" in solid refers to it. According to the SRP, the reason for a class modification should be one or the other, or a class should alw
The Spring-data-redis Project (SDR) provides a higher level of abstraction for Redis's Key-value data store operations, similar to the spring framework for JDBC support.Project home: http://projects.spring.io/spring-data-redis/Project Document: http://docs.spring.io/spring-data/redis/docs/1.5.0.RELEASE/reference/html/This article mainly introduces the actual use of spring Data Redis.New features of 1.Spring Data Redis 1.5Added the Redis hyperloglog command pfadd,pfcount,pfmergeYou can use Jackso
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.