首页 > 其他分享 >Principles of Object Oriented Class Design

Principles of Object Oriented Class Design

时间:2024-04-21 22:55:48浏览次数:17  
标签:Object Principles Oriented Design Martin com Mr

Principles of Object Oriented Class Design

https://staff.cs.utu.fi/~jounsmed/doos_06/material/DesignPrinciplesAndPatterns.pdf

The Open Closed Principle (OCP)1
A module should be open for extension but closed for modification.
Of all the principles of object oriented design, this is the most important. It originated
from the work of Bertrand Meyer2. It means simply this: We should write our mod-
ules so that they can be extended, without requiring them to be modified. In other
words, we want to be able to change what the modules do, without changing the
source code of the modules.

 

The Liskov Substitution Principle (LSP)1
Subclasses should be substitutable for their base classes.
This principle was coined by Barbar Liskov2 in her work regarding data abstraction
and type theory. It also derives from the concept of Design by Contract (DBC) by
Bertrand Meyer3.

 

The Dependency Inversion Principle (DIP)1
Depend upon Abstractions. Do not depend upon concretions.
If the OCP states the goal of OO architecture, the DIP states the primary mechanism.
Dependency Inversion is the strategy of depending upon interfaces or abstract func-
tions and classes, rather than upon concrete functions and classes. This principle is the
enabling force behind component design, COM, CORBA, EJB, etc.

 

The Interface Segregation Principle (ISP)2
Many client specific interfaces are better than one general purpose interface
The ISP is another one of the enabling technologies supporting component substrates
such as COM. Without it, components and classes would be much less useful and por-
table.

 

Robert C. Martin

http://cleancoder.com/files/about.md

Robert C. Martin

(Uncle Bob)

Mr. Martin has been a programmer since 1970.

He is a co-founder of cleancoders.com, offering on-line video training for software developers.

He is the founder of Uncle Bob Consulting LLC, offering software consulting, training, and skill development services to major corporations worldwide. He served as the Master Craftsman at 8th Light inc, a Chicago based Software Consulting firm.

Mr. Martin has published dozens of articles in various trade journals, and is a regular speaker at international conferences and trade shows.

He is also the creator of the acclaimed educational Clean Code video series at cleancoders.com.

Mr. Martin has authored and edited many books including:

  • Designing Object Oriented C++ Applications using the Booch Method
  • Patterns Languages of Program Design 3
  • More C++ Gems
  • Extreme Programming in Practice
  • Agile Software Development: Principles, Patterns, and Practices.
  • Agile Principles, Patterns, and Practices in C#
  • UML for Java Programmers
  • Clean Code
  • The Clean Coder
  • Clean Architecture

A leader in the industry of software development, Mr. Martin served three years as the editor-in-chief of the C++ Report, and he served as the first chairman of the Agile Alliance.

http://www.tup.tsinghua.edu.cn/booksCenter/book_08196801.html

罗伯特·C.马丁(Robert C. Martin)

业内人士尊称的 “鲍勃大叔”(Uncle Bob),是国际知名的软件工程师和导师,一位有五十多年健康编码经验的程序员。cleancoders.com联合创始人和Uncle Bob咨询公司创始人,主要提供软件咨询、技能培训和视频教学服务。他在专业技术领域具有较深的造诣。除了担任C++ Report杂志的总编辑,他还发表了大量有影响力的文章,受邀在许多国际性软件大会上发表演讲。他是SOLID五大原则的奠基人,是《敏捷宣言》联合签署人并担任过敏捷联盟第一届主席。他擅长的主题有软件匠艺、敏捷软件开发和测试驱动开发等。马丁是个终生学习者,52年出生的他,还在学习飞行驾驶员。

 

第8 章 单一职责原则(SRP) 121

第9 章 开放- 关闭原则(OCP) 127

第10 章 里氏替换原则(LSP) 141

第11 章 依赖倒置原则(DIP) 161

第12 章 接口隔离原则(ISP) 171

Code Example

https://github.com/unclebob/PPP/tree/master

 

标签:Object,Principles,Oriented,Design,Martin,com,Mr
From: https://www.cnblogs.com/lightsong/p/18149688

相关文章

  • error while loading shared libraries: libgsl.so.27: cannot open shared object
     001、问题(base)[root@pc1src]#treemixtreemix:errorwhileloadingsharedlibraries:libgsl.so.27:cannotopensharedobjectfile:Nosuchfileordirectory 002、查找该共享库(base)[root@pc1src]#find/-name"libgsl.so.27"##说明已经安......
  • 【VMware vSphere】使用Managed Object Browser(MOB)浏览vSphere相关对象。
    ManagedObjectBrowser(MOB)是一个和vSphere(ESXi和vCenter)捆绑在一起的工具,可以直观的浏览或查询vSphere当中各种对象的信息,比如集群、主机以及虚拟机等。这些对象包含多个属性,我们可以通过这些属性了解相关对象的详细信息,比如对象的状态、配置以及结构等。同时,在不同的对象里,还可......
  • 转载Using Domain-Driven Design(DDD)in Golang
    转载自:https://dev.to/stevensunflash/using-domain-driven-design-ddd-in-golang-3ee5UsingDomain-DrivenDesign(DDD)inGolang#go#ddd#redis#postgresDomain-DrivenDesignpatternisthetalkofthetowntoday.Domain-DrivenDesign(DDD)isanapproachtosoft......
  • json反序列化 JsonConvert.DeserializeObject 报错 One or more errors occurred. (U
    接口返回的字符串肉眼看起来正常,也是标准json,反序列化时候报错,字符串添加了UTF8-BOM头(windows记事本默认编码),可以通过以下代码移除标头//模拟json字符串对象varjsonStr="{}";byte[]buffer=Encoding.UTF8.GetBytes(jsonStr);varsResult=Encoding.UTF8.GetString......
  • .net 通过特性及继承IValidatableObject完成自定义表单验证
    Model:publicclassPartAItem:IValidatableObject{[Required]publicstringTOKEN{get;set;}[Required]publicstringPROJECT_ID{get;set;}publicstringPART{get;set;}[Required]publicstringFORM_ID{get;set;......
  • ES6对象object
    <!DOCTYPEhtml><html><head> <metacharset="utf-8"> <metaname="viewport"content="width=device-width,initial-scale=1"> <title>ES6对象object</title></head><body> <......
  • System Design Interview
    1ProximityService1)requirements FunctionalRequirementsNon-FunctionalRequirements1Returnallbusinessesbasedonuser'slocation(latituteandlongitutepair)andradius(5km)Lowlatency.Usersseenearbybusinessquickly2B......
  • JDK 源码阅读:java.lang.Object 类
    记录下自己阅读过程的笔记,如有错误,欢迎指正!源码参考:https://github.com/kangjianwei/LearningJDK/tree/master1.基本介绍在Java中,Object类是类层次结构的根类几乎每个Java类都直接或间接继承自Object类,意味着每个类都继承了Object的方法类结构:2.源码分析2.......
  • java中的final和Object类
    Java中的final和Object类目录Java中的final和Object类修饰变量修饰方法修饰类(无后类)final可以防止指令重排序,保证线程安全Object类经典面试题修饰变量基本类型(值不能改变)引用类型(引用的地址不能改变)final修饰全局变量必须提前赋值final修饰局部变量可以不在声明的时候赋值,......
  • Vue3、AntDesignModal、useModal.js封装组件
    useModal.jsimport{nextTick,ref}from'vue'import{isFunction}from"lodash-es";exportfunctionuseModal(){ constvisible=ref(false) constloading=ref(false) constshowModal=()=>{ visible.value=true } con......