OBJECT BASICS

OBJECT BASICS
Slide Note
Embed
Share

This document delves into the fundamentals of object-oriented programming, covering object basics, properties, and methods. Explore the essence of objects in programming with clear explanations and insights. Understand the core concepts and practical applications of objects to enhance your programming skills. Dive into this comprehensive guide on object basics to elevate your understanding of OOP.

  • Object Basics
  • OOP
  • Programming
  • Methods (Total: 23 characters)

Uploaded on Feb 16, 2025 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. OBJECT BASICS

  2. OBJECTS Object means a combination of data and logic that represents some real world entity. Ex: automobile. Data can be car color, name, price, number of seats Logic can be the collection of programs like show mileage, change mileage, stop,go.

  3. A More Formal Definition : An object is an entity with a well-defined boundary and identity that encapsulates state and behavior. State is represented by attributes and relationships. Behavior is represented by operations, methods, and state machines.

  4. STATE State is a condition or situation during the life of an object, which satisfies some condition, performs some activity, or waits for some event. The state of an object normally changes over time. Ex: Object Name: J Clark States: Employee ID: 567138 Date Hired: July 25, 1991 Discipline: Finance Maximum Course Load: 3 classes

  5. BEHAVIOR Behavior determines the collection of methods that describes what an object is capable of doing. The visible behavior of an object is modeled by a set of messages it can respond to (operations that the object can perform). Object Clark s behaviors: Set Max Load() SubmitFinalGrades() AcceptCourseOffering() Professor Clark()

  6. CLASSES In the context of object-oriented systems, class is a set of objects that share a common structure and the common behavior. Class is a specification of structure (instance variables), behaviors (methods) and inheritance. Each object is an instance of the class.

  7. ATTRIBUTES An attribute is a named property of a class that describes the range of values that instances of the property may hold. A class may have any number of attributes or no attributes at all. Ex: Attributes of Student class: - name - address - studentID - dateOfBirth

  8. Example: Course (Class) Properties/Attributes: Properties/Attributes: Name Location Days offered Credit hours Start time End time Behaviors: Behaviors: Add a student Delete a student Get course roster Determine if it is full

  9. OBJECTS RESPOND TO MESSAGES To perform any operation a message is sent to an object. The object performs operation based on the message that receives. Different objects can respond to the same message in different ways. For example cars,cycle,bike will respond to STOP message but operations performed by those objects are different.

  10. METHODS AND MESSAGES The message is the instruction and method is the implementation (details of what operations need to be performed upon the received message). An object understands a message when it can match the message to a method, which has the same name as the message.

  11. ENCAPSULATION AND INFORMATION HIDING Encapsulation means the user cannot see the inside of the object but can use the object by calling the object s methods. The object- oriented languages provide encapsulation with public, private and protected.

  12. CLASS HIERARCHY Object-oriented system organizes classes into super class-subclass hierarchy. The top classes on the hierarchy are most generic classes. Bottom classes are most specific. Subclass inherits all of the properties and methods of the super class and also having some specific properties and behaviors.

  13. EXAMPLE Motor vehicle CAR BUS Personal car Govt bus Race Car School bus

  14. POLYMORPHISM Same operation may behave differently on different classes.

  15. OBJECT RELATIONSHIP AND ASSOCIATIONS Association represents the relationships between objects and classes. Example: a pilot can fly planes Associations are bidirectional. The direction implied by the name is forward direction; The opposite direction is the inverse direction. An important issue in association is cardinality, which specifies how many instances of one class relate to a single instance of an associated class. Often is described as "one" or "more". Faculty Course Teaches by taught

  16. CONSUMER-PRODUCER RELATIONSHIP Also known as client-server association or a use relationship. The consumer-producer relationship can be viewed a one-way interaction: one object requests the service of another object. The object that makes the request is the consumer or client, and the object that receives the request and provides the service is the producer or server. Request for Printing PrintServer Item

  17. AGGREGATION Objects are composed of /may contain other objects. Car Car Wheel Wheel Engine Engine Seat Seat

More Related Content