Three main features are:
Encapsulation
Inheritance
Polymorphism
Five basic principles:
Single Responsibility Principle SRP (single responsibility principle)
OCP (Open-Close principle)
The liskov substitution principle LSP)
The dependency inversion principle dip)
The interface segregation principle ISP)
Details:
The so-called encapsulation refers to encapsulating objective things into abstract classes, and classes can only allow trusted class
role to provide a wide range of interfaces, that is, custom services, personalized services. is simply to provide the behavior that the client needs, and the behavior that the client does not need is hidden.The client should be provided with as small a separate interface as possible, rather than providing a large total interface.This is also a limitation of communication between software entities. But it limits the width of the communication, which means the communication should be as narrow as
Ood design principles Overview:
Robert tcecilmartin,Bertrandmeyer,Barbaraliskov11 object-oriented design principles are put forward, which are regarded as the good bible by Object-Oriented designers. They can see their original text below:
Http://c2.com/cgi/wiki? Principlesofobjectorienteddesign
Http://www.objectmentor.com/
Class Design Principles ):
Single Responsibility Principle (SRP ):A class should have only one reason to change.(
1. If a class has too many responsibilities, these responsibilities are coupled. Changes in one role may weaken or suppress this class's ability to fulfill other responsibilities. This coupling will put the fragile (fragile) design upside down, and when changes occur, the design will suffer unexpected damages. P88
2. In SRP, we define the responsibility as a reson for change ). P89
3. The changed axis is meaningful only when the change actually oc
When learning and using OO design, we should understand that the emergence of OO enables software engineers to describe software systems in a way closer to the real world. However, software, after all, is built on an abstract level. how close it is to the truth cannot replace the truth or be replaced by the truth.
The five principles of OO design are not isolated from each other. There is a certain correlation between them. One can be the strengthening or foundation of another principle. Violati
best practices for object-oriented design. Term S. o. l. i. d. from Robert C. the first letter of the names of the five design principles collected in Agile principles, patterns, and practices in C # by Martin (Uncle Bob.
1. Single Responsibility Principle (SRP)The SRP principle is highly consistent with the SOC principle. It requires that each object be changed for only one element and has only one respon
Single Responsibility Principle (SRP.
Definition:
There shoshould never be more than one reason for a class to change.
There should be only one reason for the change.
Sometimes, developers may have some problems when designing interfaces. For example, user attributes and user behaviors are declared in an interface. This causes the Business Objects and business logic to be put together. As a result, this interface has two responsibilities and the inte
1. What does the title mean? 1.1 What is unit test?
Unit testing aims to ensure the quality of code;1.2 What is decoupling?
Decoupling aims to facilitate unit testing. Of course, another purpose is to keep the programScalability.
Idea tools: To achieve decoupling of unit test and code (or oo code with good design) at the same time, the idea of dependency injection is an essential tool.
The reason is thought. From the design point of view, this really requires ideological transcendence;
It is
fields of the model and also adds some extra stuff, look at the color label and married check box.Here is a simple chart, the field on the left of the model, and the field to the right of the UI. The middle is a description of the logic of the mapping and transformation.You can see the first 2 fields we don't have any conversion logic, they only have the mapping logic. The other 2 field mappings and transformations have logic.The logic of transformations and mappings is usually in the backgroun
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 =
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.