Lecture 2: The object model. The main contents of this chapter include all of the following: Objects and method calls, interfaces, UML notation, object relationships, process/algorithm –oriented vs. object, oriented approaches. | Ivan Marsic Rutgers University LECTURE 2: The Object Model Topics Objects and Method Calls Interfaces UML Notation Object Relationships Process/Algorithm –Oriented vs. Object Oriented Approaches Objects, Calling & Answering Calls Prime factorization of 905: 5 181 (2 distinct factors) Prime factorization of 1988: 2 2 7 71 (4 factors, 3 distinct) Two integers are said to be coprime or relatively prime if they have no common factor other than 1 or, equivalently, if their greatest common divisor is 1. Objects Don’t Accept Arbitrary Calls Acceptable calls are defined by object “methods” (. Operations, Procedures, Subroutines, Functions) method-1: Accept card method-2: Read code method-3: Take selection Object: ATM machine Object Interface Interface defines method “signatures” Method signature: name, parameters, parameter types, return type method-1 method-2 method-3 Interface Object hides its state (attributes). The attributes are . | Ivan Marsic Rutgers University LECTURE 2: The Object Model Topics Objects and Method Calls Interfaces UML Notation Object Relationships Process/Algorithm –Oriented vs. Object Oriented Approaches Objects, Calling & Answering Calls Prime factorization of 905: 5 181 (2 distinct factors) Prime factorization of 1988: 2 2 7 71 (4 factors, 3 distinct) Two integers are said to be coprime or relatively prime if they have no common factor other than 1 or, equivalently, if their greatest common divisor is 1. Objects Don’t Accept Arbitrary Calls Acceptable calls are defined by object “methods” (. Operations, Procedures, Subroutines, Functions) method-1: Accept card method-2: Read code method-3: Take selection Object: ATM machine Object Interface Interface defines method “signatures” Method signature: name, parameters, parameter types, return type method-1 method-2 method-3 Interface Object hides its state (attributes). The attributes are accessible only through the interface. Clients, Servers, Messages Objects send messages by calling methods Client object: sends message and asks for service Server object: provides service” and returns result Interfaces An interface is a set of functional properties (services) that a software object provides or requires. Methods define the “services” the server object implementing the interface will offer The methods (services) should be created and named based on the needs of client objects that will use the services “On-demand” design—we “pull” interfaces and their implementations into existence from the needs of the client, rather than “pushing” out the features that we think a class should provide Objects are Modules Software Module Modules versus Objects Objects encapsulate data Methods (behavior) Attributes /data (state) Software Object 1 Subprograms (behavior) Data (state) Modules are loose groupings of subprograms and data Software Module 2 Software Module 3 Software Module