5 Alternative Solution New Yorker, June 1992 "Most software today is very much like an Egyptian pyramid with millions of bricks piled on top of each other, with no structural integrity, but just done by brute force and thousands of slaves". – Alan Kay. Pioneering work on object-oriented programming ACM Queue. Vol. 2, No. 9 - Dec/Jan 2004-2005
9 public class A extends B { C c1, c2; public A() { c1 = new C(); } public void method() { D d = new D(); d.working(); } } public class X { public void m() { B var = new A(); double x = Math.sqrt(5); } } public class B implements E { public B() { C c1 = new C(); } public void method() { B b = new B(); b.sleep(); } } public class Y { A [] a = new A[5]; } Lab
11 § Keep it Simple - over-designing the system is as bad as their absence when needed. § A design that is more than what we need smells. § Design principles are not a perfume to be liberally scattered all over the system. Key idea
16 There are five key design principles to consider in Object-Oriented: § Single Responsibility Principle (SRP) § Open-Closed Principle (OCP) § Liskov Substitution Principle (LSP) a child should always be better than its parent. § Interface Segregation Principle (ISP) broke up interfaces § Dependency Inversion Principle (DIP) do not call us, we will call you Design Principles
33 § These are singletons, to access the instances use § XXXPackage.eINSTANCE § XXXFactory.eINSTANCE § Use the Factory to create instances of your model classes, e.g: TaskList t = ExampleFactory.eINSTANCE.createTaskList(); § Use the Package to access the meta-model definition, e.g: EClass c = ExamplePackage.eINSTANCE.getTaskList(); List attrs = c.getEAttributes(); Patterns