CS 342 - 1/14/16 Programming Paradyms - Generic/Imperative/Procedural (C, BASIC, FORTRAN...) - Functional (LISP, SCHEME, F#) - Logical (Prolog) - Object Oriented PL Commuications of the ACM, 1972 Parnas Article Traditional Languages - Straight foreward Decomposition - Modules sharing large data structures through global variables - Difficulties is understanding and maintaining software Data-Oriented Decomposition - soon renamed to "Object-Oriented" - High Module independence through small interfaces - clear separation of module specifiactions - better reuse and ease of maintenance Criteria for decomposition - Information Hiding - hide implementation and representation details - reduced the size of modules "Parnas' Law - Only what is hidden can be changed without risk." - Data Abstraction combining the storage structure and the operations Instead of asking "What steps are needed to execute to solve the problem?" ask: "What is the best way to organize our data to solve the problem?" 2D Point data Data? x, y: int Operations? distanceFromOrigin setters/getters Constructors distanceFromOtherPoint Access modifiers: - public - can be accessed from anywhere - protected - can be access from inside the class and inside of any class that inherits the original class - (default) - JAVA-special access modifier that allows for access from any point in the package that contains the class - private - can only be accessed from inside the class Because of the interaction between packages in JAVA and the default access modifier, when packages are not used, JAVA really only have two access modifiers: - private - everything else (which appear to act like public) // code would be placed in a file called Point2D.java public class Point2D { // Instance Variables or Data Members private int x; private int y; // Methods or Class Operations public double distanceFromOrigin ( ) { ... } }