`
fauvism
  • 浏览: 13471 次
  • 性别: Icon_minigender_1
  • 来自: 火星
最近访客 更多访客>>
社区版块
存档分类
最新评论

The Principles of OOD by Uncle Bob

    博客分类:
  • OO
阅读更多
What is object oriented design? What is it all about? What are it's benefits? What are it's costs? It may seem silly to ask these questions in a day and age when virtually every software developer is using an object oriented language of some kind. Yet the question is important because, it seems to me, that most of us use those languages without knowing why, and without knowing how to get the the most benefit out of them.

Of all the revolutions that have occurred in our industry, two have been so successful that they have permeated our mentality to the extent that we take them for granted. Structured Programming and Object Oriented Programming. All of our mainstream modern languages are strongly influenced by these two disciplines. Indeed, it has become difficult to write a program that does not have the external appearance of both structured programming and object oriented programming. Our mainstream languages do not have goto, and therefore appear to obey the most famous proscription of structured programming. Most of our mainstream languages are class based and do not support functions or variables that are not within a class, therefore they appear to obey the most obvious trappings of object oriented programming.

Programs written in these languages may look structured and object oriented, but looks can be decieving. All too often today's programmers are unaware of the principles that are the foundation of the disciplines that their languages were derived around. In another blog I'll discuss the principles of structured programming. In this blog I want to talk about the principles of object oriented programming.

In March of 1995, in comp.object, I wrote an article that was the first glimmer of a set of principles for OOD that I have written about many times since. You'll see them documented in my PPP book, and in many articles on the objectmentor website, including a well known summary.

These principles expose the dependency management aspects of OOD as opposed to the conceptualization and modeling aspects. This is not to say that OO is a poor tool for conceptualization of the problem space, or that it is not a good venue for creating models. Certainly many people get value out of these aspects of OO. The principles, however, focus very tightly on dependency management.

Dependency Management is an issue that most of us have faced. Whenever we bring up on our screens a nasty batch of tangled legacy code, we are experiencing the results of poor dependency management. Poor dependency managment leads to code that is hard to change, fragile, and non-reusable. Indeed, I talk about several different design smells in the PPP book, all relating to dependency management. On the other hand, when dependencies are well managed, the code remains flexible, robust, and reusable. So dependency management, and therefore these principles, are at the foudation of the -ilities that software developers desire.

The first five principles are principles of class design. They are:
SRP The Single Responsibility Principle A class should have one, and only one, reason to change.
OCP The Open Closed Principle You should be able to extend a classes behavior, without modifying it.
LSP The Liskov Substitution Principle Derived classes must be substitutable for their base classes.
DIP The Dependency Inversion Principle Depend on abstractions, not on concretions.
ISP The Interface Segregation Principle Make fine grained interfaces that are client specific.

The next six principles are about packages. In this context a package is a binary deliverable like a .jar file, or a dll as opposed to a namespace like a java package or a C++ namespace.

The first three package principles are about package cohesion, they tell us what to put inside packages:

REP The Release Reuse Equivalency Principle The granule of reuse is the granule of release.
CCP The Common Closure Principle Classes that change together are packaged together.
CRP The Common Reuse Principle Classes that are used together are packaged together.

The last three principles are about the couplings between packages, and talk about metrics that evaluate the package structure of a system.

ADP The Acyclic Dependencies Principle The dependency graph of packages must have no cycles.
SDP The Stable Dependencies Principle Depend in the direction of stability.
SAP The Stable Abstractions Principle Abstractness increases with stability.
分享到:
评论

相关推荐

    Uncle Bob OOD Principles

    本文将深入探讨Uncle Bob提出的OOD原则,以及这些原则在C++编程中的应用。** 1. **单一职责原则(Single Responsibility Principle, SRP)**:每个类或模块应该只有一个改变的原因。这意味着一个类应专注于一个特定...

    The Principles of Quantum Mechanics_4th_Dirac

    The Principles of Quantum Mechanics_4th_Dirac 狄拉克原子物理原理经典书籍

    The Principles of Object-Oriented JavaScript 1st Edition

    The Principles of Object-Oriented JavaScript 1st Edition If you've used a more traditional object-oriented language, such as C++ or Java, JavaScript probably doesn't seem object-oriented at all. It ...

    The Principles Of Quantum Mechanics

    The Principles Of Quantum Mechanics 被称为量子力学圣经

    The Principles of Mathematics

    《数学原理》是英国数学家伯特兰·罗素(Bertrand Russell)与逻辑学家阿尔弗雷德·诺斯·怀特黑德(Alfred North Whitehead)共同撰写的著作,这部作品对数学基础进行了深入的哲学探讨。该书的核心在于试图通过逻辑...

    Principles of Lithography, Third Edition (SPIE Press Monograph, Vol. PM198)

    The publication of Principles of Lithography, Third Edition just five years after the previous edition is evidence of the quickly changing and exciting nature of lithography as applied to the ...

    Principles Of Nonlinear Optics

    Principles Of Nonlinear Optics Y. R. Shen

    The principles of ofdm

    ### 正交频分复用(OFDM)原理详解 #### 引言 正交频分复用(Orthogonal Frequency Division Multiplexing,简称OFDM)作为一种多载波调制技术,已经在通信领域中占据重要地位。从最初的理论研究到现今广泛应用于...

    Principles of Magnetic Resonance Imaging by Nishimura

    《Principles of Magnetic Resonance Imaging by Nishimura》是斯坦福大学教授Nishimura所著的一本关于磁共振成像(Magnetic Resonance Imaging, MRI)原理的书籍。磁共振成像是一种重要的医学成像技术,能够为医生...

    Principles of Quantum Mechanics(Dirac).pdf

    这份文档是P.A.M. Dirac所著的《量子力学原理》一书的PDF版本。Paul Adrien Maurice Dirac是著名的理论物理学家,他在量子力学、量子电动力学以及相对论性量子力学领域做出了开创性的贡献,尤其是Dirac方程的提出,...

    The Principles of Object Oriented.JavaScript

    ### 面向对象的JavaScript原则 #### 一、引言 面向对象编程(Object-Oriented Programming,简称OOP)是一种广泛应用于软件开发的方法论,它通过将数据和处理这些数据的方法组织在一起,形成“对象”,从而实现对...

    The Principles of Beautiful Web Design 2nd

    《美丽的网页设计原则》第二版是一本深入探讨网页美学与设计的著作,旨在帮助读者理解并掌握创造引人入胜且功能完善的网页设计的核心概念。这本书涵盖了从布局、色彩理论到交互性等多方面的设计原则,是提升网页设计...

    Principles of Instrumental Analysis, 7th Edition

    根据提供的文件信息,我们可以推断文件是关于《Principles of Instrumental Analysis》这本书的第七版。这本书似乎被作者描述为“很不错应用资料,值得学习,分享给大家,希望你们有收获”。这表明了该书在分析仪器...

    Principles of Economics 7th Edition N.Gregory.Mankiw

    Principles of Economics 7th Edition N.Gregory.Mankiw 经济学原理新书7 版本,高清

    Principles of transaction processing

    根据提供的文件信息,可以提炼出以下与“Principles of transaction processing”相关的知识点: 1. 事务处理的原理 事务处理系统是计算机系统的一个重要组成部分,它涉及到如何高效、安全地处理各种事务。事务处理...

    Principles of Modern Radar Advanced Techniques.pdf

    本书《Principles of Modern Radar Advanced Techniques》是《Principles of Modern Radar》系列的第二卷,为雷达工程师提供了一部重要的专业参考。该系列共三卷,本书专注于为雷达设计中使用的最常见技术提供高级...

    Principles of Modern Radar Basic Principles

    ### 现代雷达原理基本概念 #### 雷达定义与作用 雷达(Radar)一词源自“Radio Detection and Ranging”的首字母缩写,意为“无线电探测和测距”,是一种利用无线电波来探测物体并测量其位置的技术。...

Global site tag (gtag.js) - Google Analytics