Kinesia Online Course
Object Oriented Programming
Kinesia LLC, 2003
    1. A Little Taste of Java
    2. Abstraction and Modeling
    3. Objects and Classes
    4. Object Interactions
    5. UML and Relationships between Objects
    6. Collection of Objects
    7. Some Final Concepts
    8. Object Modeling and Use Cases
    9. Modeling of Dynamic Behavaior and Sequence Diagrams
    10. A Deeper Look at Java
    11. Java Layout
    12. Java Events
    
    Self-knowledge is best learned, not by contemplation,
    but by action.  Strive to do your duty and you will soon
    discover of what stuff you are made.
    
    					Johann Goethe
    
    
    Objects and Classes
    1. What is an Object?

      Merriam-Webster's dictionary:

      1. Something material that may be perceived by the senses
      2. something mental or physical toward which thought, feeling or action is directed

      1. refers to something physical.

      In the Student Registration System ( SRS ), examples of physical objects are:

    2. students who attend classes
    3. professors who teach them
    4. classrooms in which class meetings take place
    5. furniture in these classrooms
    6. buildings in which classrooms are located
    7. textbooks students use
    8. 2. refers to conceptual objects

    9. courses that students attend
    10. departments that faculty works for
    11. degrees that students receive
    12. formal definition of a software object:

      A ( software ) object is a software construct that bundles together data ( state ) and functions ( behavior ) which, taken together, represent an abstraction of a 'real-world' ( physical or conceptual ) object.

    13. Data/State/Attributes

      Data:

      Examples:

      Data of a student

    14. student's name
    15. students's address
    16. age
    17. gender
    18. courses taken
    19. advisor

      Data of a course:

    20. course number
    21. course name
    22. prerequites of course
    23. credit units
    24. professors teaching it
    25. In object nomenclature, the data elements used to describe an object are referred to as the object's attributes.

      An object's attribute values, when taken collectively, are said to define the state of the object.

      Example: examine the state of a student to see if she could graduate.

    26. Behavior/Operations/Methods

      An object's behaviors, also known as operations are both the things an object does to access its data ( attributes ), and the things that an object does to modify/maintain its data ( attributes ).

      A student's behavior might include:

    27. Enrolling in a course
    28. Dropping a course
    29. Selecting a facutly advisor
    30. Telling you her GPA when asked
    31. A course's behavior might include:

    32. Permitting a student to register
    33. Determining whether or not a given student is already registered
    34. Telling you what its prerequisite courses are
    35. Telling you how many credit hours it is worth
    36. When we actually get around to programming an object in a language like Java, we refer to the programming language representation of an operation as a method, whereas, the term 'operation' is typically used to refer to a behavior conceptually. But, often, these two terms are used interchangeably.

    37. Classes

      A class is an abstraction describing the common features of all members in a group of similar objects.

      A class defines:

    38. The data structures ( names and types of attributes ) needed to define an object belonging to that class.
    39. The operations ( methods ) to be performed by such objects.
    40. For example, the Student class might be defined to have the following nine attributes:

      Attribute Name  (Java) Data Type
      name   String
      studentId   String
      birthdate   Date
      address   String
      major   String
      gpa   Float
      advisor   ???
      courseLoad   ???
      transcript   ???

      In terms of operations ( methods ), the Student class might define five methods:

    41. registerForCourse
    42. dropCourse
    43. chooseMajor
    44. changeAdvisor
    45. printTranscript
    46. The term feature is used to refer interchangeably to either an attribute or a method of a class.

    47. Instantiation

      Instantiation is the process by which an object is created/constructed based upon a class definition.

      Difference between class and object:

    48. class -- specifications, defines attributes, like an empty template

    49. object -- filled in template, consumes resources
    50. Encapsulation

      Encapsulation -- the mechanism that bundles together the state information ( attributes ) and behavior ( methods ) of an object into a single unit.

      	Attributes:
      	  name
      	  ssn
      	  address
      	  <etc>
      	Methods:
      	  registerForCourse
      	  dropCourse
      	  chooseMajor
      	  <etc>
        

    51. Objects vs. Database Records

      Object-record analogy

    52. class ~ a table in a relational database
    53. each record, or row in a table ~ a different object instance
    54. each column in a table ~ a different attribute of the associated class

      studentid   name     major     gpa  
          
          
      123456 Arnold Smith P.E. 2.3
          
          
          

    55. Flaws of correlation between objects and records:

    56. Objects exhibit behavior, whereas records typically do not.

    57. Objects have unique identities; can have identical attributes.
      records do not, need primary key to distinguish them
    58. Classes as Abstract Data Types

      non-OO language

      int x;
    59. x is a symbolic link that represents an integer value
    60. can be operated on by int data type operators
    61. OO language

      Student s
    62. s is a symbolic name referring to a Student object/instance
    63. s can be operated on by the methods defined in Student class
    64. Just as int is referred to as a simple, or built-in data type in a language like C or Java, we can refer to a user-defined class Student as an Abstract Data Type ( ADT ), which is a user-defined data type that specifies structure as well as behavior.


      Problem
      Statment


      ADT
       

      Implemented
      Program
      ( depends on
      language
      )

    65. Closer Look at Instantiating Objects of Java

      C++ :
      	Student y;	//instantiation occurs, object created, default constructor used
      			// memory allocated, y is name of the object
      	

      Java :

      	Student y;	//instantiation has not occurred, 
      			//noobject created,
      			//y is a reference variable that has the potential
      			//to be a reference ( handel ) to a Student objec
      			//( you may also imagine that y is a pointer )
      
      
      	y = new Student();	//instantiation occurs
          
      y →
      Student
      Object

      ------------------------------------------------------------------------------------

        Student x = new Student();	//Object created
      
        Student y = x;		//y references the same object as x does
        
      y →

      x →

      Student
      Object

      ------------------------------------------------------------------------------------

        Student x = new Student();	//Object created
      
        Student y = x;		//y references the same object as x does
      
        Student z = new Student();	//Another object created
      
        
      y →

      x →

      Student
      Object #1
       
      z →
      Student
      Object #2

      ------------------------------------------------------------------------------------

        y = z;		//y references the same object as z does
        
      x →
      Student
      Object #1
       
      y →

      z →

      Student
      Object #2

      ------------------------------------------------------------------------------------

        x = z;		//x references the same object as z does
        
       
      Student
      Object #1
       
      x →

      y →

      z →

      Student
      Object #2

    66. Objects as Attributes

      Attribute Name  Data Type
      name   String
      studentId   String
      birthdate   Date
      address   String
      major   String
      gpa   Float
      advisor   Professor
      courseLoad   ???
      transcript   ???

      The Professor class, in turn, might be defined to have attributes as follows:

      Attribute Name  Data Type
      name   String
      studentId   String
      birthdate   Date
      address   String
      department   String
      studentAdvisee   Student
      teaching Assignments   ???

    67. Composite Classes

      Composite class -- a class in which one or more of the attributes are themselves references to other objects

      has-a relation

      We may encounter a situation where an object 'A' needs to refer to an object 'B', object 'B' needs to refer back to 'A' and both objects need to be able to respond to requests independently of each other.

      In this case, we cannot physically embed one object wholly inside the other. ( Why? )

      Resolved by using handles ( pointers ) ( C++ : forward declaration )
      We are not storing whole objects as attributes inside other objects, but rather references to objects. The two objects exist separately in memory

    68. OO Characteristics

    69. ( Programmer creation of ) Abstract Data Types ( ADTs )
    70. Inheritance
    71. Polymorphism