Friday, November 23, 2012

10 Object Oriented Design principles Java programmer should know


10 Object Oriented Design principles Java programmer should know

Object oriented design principle 1 -  DRY (Don't repeat yourself)
Object oriented design principle 2 - Encapsulate what varies
Object oriented design principle 3 - Open Closed principle
Object oriented design principle 4 - Single Responsibility Principle (SRP)
Object oriented design principle 5 - Dependency Injection or Inversion principle
Object oriented design principle 6 - Favour Composition over Inheritance
Object oriented design principle 7 - Liskov Substitution Principle (LSP)
Object oriented design principle 8 - Interface Segregation principle (ISP)
Object oriented design principle 9 - Programming for Interface not implementation
Object oriented design principle 10 - Delegation principle

http://javarevisited.blogspot.com/2012/03/10-object-oriented-design-principles.html#ixzz2D4RM6ys7


  • In software engineering, don't repeat yourself (DRY) is a principle of software development aimed at reducing repetition of information of all kinds, especially useful in multi-tier architectures. The DRY principle is stated as "Every piece of knowledge must have a single, unambiguous, authoritative representation within a system.

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

The ? : operator in Java


if (a > b) {
  max = a;
}
else {
  max = b;
}

or shortly

max = (a > b) ? a : b;

http://www.cafeaulait.org/course/week2/43.html