views:

672

answers:

7

I am a huge fan of software design principles such as SOLID and DRY. What other principles exist for OO software design?

Note. I’m not looking for answers like "comment your code" but instead looking for OO design principles like the ones discussed by Uncle Bob.

+1  A: 

YAGNI

M4N
+2  A: 

KISS

William Brendel
+1  A: 

Chose composition over inheritance, is one.

Many people, especially those new to OO will start extending classes when all they really need to is to use composition. Really if you should ask your self, is the new class B a Class A? If not then you shouldn't extend.

For example, let's say I have a Person Class, a Car Class, and I would like to make a new class called a DrivenCar class. A naive implementation would be to say (let's pretend we got multiple inheritance)

class DrivenCar extends Person, Car  { ... }

Is the DrivenCar a type of Person? No so it shouldn't be extending Person. Is the DrivenCar a Car? yes so it makes sense to extend

Using composition the implmentation would look like

class DrivenCar extends Car {
    private Person driver;
}
hhafez
@hhafez I would say that "composition over inheritance" is already part of the SOLID principle
Kane
It could very well be, but composition over inheritance is a principal still :)
hhafez
+3  A: 

High Cohesion - How focused are the responsibilities of the modules you are designing.

Low Coupling - The degree to which modules rely on other modules.

JasCav
@Jason I would have thought High Cohesion and Low Coupling are inferred by the SOLID principle
Kane
@Kane - Yeah, you may be right. S and D. May be different names to the same thing. (I had never heard of SOLID until now and learned cohesion and coupling which is why I posted it.) Thanks for pointing this out.
JasCav
+5  A: 

A fairly comprehensive list from Wikipedia:

http://en.wikipedia.org/wiki/List_of_software_development_philosophies

  • Agile software development
  • Agile Unified Process (AUP)
  • Behavior Driven Development (BDD)
  • Big Design Up Front (BDUF)
  • Brooks's law
  • Cathedral and the Bazaar
  • Code and fix
  • Constructionist design methodology (CDM)
  • Cowboy coding
  • Crystal Clear
  • Design-driven development (D3)
  • Don't repeat yourself (DRY) or Once and Only Once (OAOO), Single Point of Truth (SPoT)
  • Dynamic Systems Development Method (DSDM)
  • Extreme Programming (XP)
  • Feature Driven Development
  • Hollywood Principle
  • Iterative and incremental development
  • Joint application design, aka JAD or "Joint Application Development"
  • Kaizen
  • Kanban
  • KISS principle (Keep It Simple, Stupid)
  • Lean software development
  • Microsoft Solutions Framework (MSF)
  • Model-driven architecture (MDA)
  • Open source
  • Open Unified Process
  • Quick-and-dirty
  • Rational Unified Process (RUP)
  • Scrum
  • Smart (agile development)
  • Separation of concerns (SoC)
  • Service-oriented modeling
  • Software Craftsmanship
  • Software System Safety
  • Spiral model
  • Test-driven development (TDD)
  • Unified Process (UP)
  • V-Model
  • Waterfall model
  • Wheel and spoke model
  • Worse is better (New Jersey style, as contrasted with the MIT approach)
  • Xtreme
  • You Ain't Gonna Need It (YAGNI)
  • Zero One Infinity
Neil N
Thanks Neil but only some of those are actual principles. I.E., "Cowboy coding" and "Code and fix" aren't principles IMHO (but I'm happy to be wrong on this)
Kane
you are right, and I am/was considering chopping this list down. I might actually link all of them as well.. if I get a few minutes.
Neil N
A: 

Interface. Most design patterns are based on separation of interface & implementation.

janetsmith
I would say that "Interface" is already covered in the SOLID principle?
Kane
A: 

When your API are expected to grow, use Abstract class instead of Interface. Adding a new method in Interface requires to change ALL the classes which implement it.

janetsmith