. Object-oriented programming
. Primary object-oriented language concepts
. Dynamic lookup
. encapsulation
. inheritance
. subtyping
. Program organization
. Work queue, geometry program, design patterns
. Comparison
. Objects as closures?
. Objects
. An object consists of
. hidden data
. instance variables, also called member data
. hidden functions also possible
. public operations
. methods or member functions can also have public variables in some languages
. Object-oriented program
. send messages to objects
. What's interesing about this?
. Universal encapsulation construct
. Data structure
. File system
. Database
. window
. Integer
. Metaphor usefully ambiguous
. sequential or concurrent computation
. distributed, sync. or async. communication
. Object-Orientation
. Programming methodology
. orginize concepts into objects and classes
. build extensible systems
. Language concepts
. Dynamic lookup
. Encapsulation
. Subtyping allows extensions of concepts
. Inheritance allows reuse of implementation
. Dynamic Lookup
. In object-oriented programming, object message(arguments)
code depends on object and message
. In conventional programming, operation (operands)
meaning of operation is always the same
. Fundamental difference between abstract data types and objects
. Example
. Add two numbers
. different add if x is integer, complex
. Conventional programming add(x,y)
. function add has fixed meaning
. Very important distinction:
. Overloading is resolved at compile time, Dynamic lookup at run time.
. Encapsulation
. Builder of a concept has detailed view
. User of a concept has abstract view
. Encapsulation separates these two views
. Impelmentation code : operate on representation
. Client code : operate by applying fixed set of operations provided by implementer of abstraction
. Languge concepts
. "Dynamic lookup"
. Different code for different object
. Integer "+" different from real "+"
. Encapsulation
. subtyping
. Inheritance
. Subtyping and Inheritance
. Interface : The external view of an object
. Subtyping : Relation between interfaces
. Implementation : The internal representation of an object
. Inheritance : Relation between implementations
. Object Interfaces
. Interface : The messages understood by an object
. The interface of an object is its type
. Subtyping
. If interface A contains all of interface B, then
A objects can also be used B objects.
. Colored_point interface contains Point
. Colored_point is a subtype of Point
. Inheritance
. Implementation mechanism
. New objects may be defined by reusing implementations of other objects
. Subtyping
. Colored points can be used in place of points
. Property used by client program
. Inheritance
. Colored points can be implementated by reusing point implementation
. Technique used by implementer of classes
. OO Program Structure
. Group data and functions
. Class : Defines behavior of all objects that are instances of the class
. Subtyping : Place similar data in related classes
. Inheritance : Avoid reimplementing functions that are already defined
. Subtyping differs from inheritance
. Design Patterns
. Classes and objects are useful organizing concepts
. Culture of design patterns has developed around object-oriented programming
. Shows value of OOP for program organization and problem solving
. What is a design pattern?
. General solution that has developed from repeatedly addressing similar problems
. ex) singleton
. restrict programs so that only one instance of a class can be created
. signleton desing pattern provides standard solution
. Not a class template
. Using most patterns will require some thought
. Pattern is meant to capture experience in useful form
. Varieties of OO languages
. class-based languages (C++, Java, ...)
. behavior of object determined by its class
. object-based (Self)
. objects defined directly
. multi-methods (CLOS)
. operation depends on all operands
. History
. Simula : Object concept used in simulation (1960's)
. Smalltalk : Object-oriented design, systems (1970's)
. C++ : Adapted Simula ideas to C (1980's)
. Java : Distributed programming, internet
. Summary
. Object-oriented design
. Primary object-oriented language concepts
. dynamic lookup
. encapsulation
. inheritance
. subtyping
. Program organization
. Work queue, geometry program, design patterns
. Comparison
. Objects as closures
댓글 없음:
댓글 쓰기