Introduction to Object-Oriented Programming (OOP) Part 1 SE-1010 Dr. Mark L. Hornick 1 Objectives Name the basic components of object-oriented programming. Differentiate classes and objects.
Define class methods and attributes. Draw UML diagrams for classes and objects. SE-1010 Dr. Mark L. Hornick 2 OOP is about classes and objects These
are two very basic concepts in OOP but what are they? Java is an OOP language SE-1010 Dr. Mark L. Hornick 3 Alan Kay, who was instrumental in the creation of the first Apple Macintosh, was also the creator of the first OOP language called Smalltalk. He defined OOP as follows:
SE-1010 Dr. Mark L. Hornick 4 1. Everything is an object An object is a thing, both tangible Objects often represent physical entities SE-1010 Dr. Mark L. Hornick 5 1. Everything is an object and intangible, like
Time Date Bank Account Grocery List Or, objects can just represent ideas or concepts SE-1010 Dr. Mark L. Hornick 6 2. Every object has a type of class Classes are more difficult to describe: A Class is an abstraction (a blueprint, or template) that defines the attributes and behavior of Objects that belong to the Class
Objects assume the characteristics of a class We say an Object is an Instance of a Class, kind of how a cake is an instance of a recipe for a cake. We can also say that a Class Instance is an Object. SE-1010 Dr. Mark L. Hornick 7 3. An object is comprised of attributes and methods defined by its class attributes are data that define an objects properties Each object has its own variables where it can store the values of its attributes methods are behaviors
Methods are executed when an object receives a message to execute it. Methods often manipulate attributes Alan Kays OOP definitions, continued SE-1010 Dr. Mark L. Hornick 8 Exercise 1 List some attributes and behaviors for a BankAccount class Pretend its used within the software of an ATM machine (or within a personal finance app)
What does it represent? What can it do? What are its properties? SE-1010 Dr. Mark L. Hornick 9 Exercise 2 List some attributes and behaviors for a Printer class
What does a printer do? What properties does it have? SE-1010 Dr. Mark L. Hornick 10 Unified Modeling Language (UML) A notation for objects and classes. Can be applied to any OOP language (not just Java). cd Data M odel - : int : int
+ + () : voi d () : voi d UML class diagram SE-1010 Dr. Mark L. Hornick 11 Were not done with Alan Kays definitions
yet SE-1010 Dr. Mark L. Hornick 12 4. Object-oriented programs use objects An object-oriented program is a bunch of objects telling each other what to do by sending and receiving messages to and from one another A message instructs an object to execute one of its methods Alan Kays OOP definitions, continued
SE-1010 Dr. Mark L. Hornick 13 The Relationship between Messages and Methods To instruct an object to do something, we send a message to it. We dont usually send messages to classes, although there are exceptions well learn about later You can send a message only to the objects that understand the message you send to them.
In Java (and other OO languages like C++, C#, or VB), messages are sent by calling a method defined within the objects class we also say execute a method or invoke a method and sometimes we use function instead of method SE-1010 Dr. Mark L. Hornick 14 UML again A UML Sequence Diagram illustrating
messages being sent to an instance of a The objects class. The objects name hp1 class Printer The message purge purge hp1:Printer print(report.txt) SE-1010 Dr. Mark L. Hornick
15 Passing values in messages A value we pass to an object when sending a message is called an argument of the message. The objects The objects name hp1 class Printer The message print with the argument report.txt hp1:Printer print(report.txt)
SE-1010 Dr. Mark L. Hornick 16 Two-way communication Many times, a method will return a message The objects The objects back to the sender. name class No argument The method hp11:Plotter
getPaperLevel() 27 The return value SE-1010 Dr. Mark L. Hornick 17 Many arguments can be sent in an originating message, but only one return value can be sent back The objects name The objects class
Two arguments The method hp11:Plotter setFont(Arial, italic) ok The return value SE-1010 Dr. Mark L. Hornick 18 Object-oriented programming The object-oriented (OO) approach provides tools for the programmer to represent elements in the problem, or domain space
Elements in the problem space, and their representation in the solution space, are referred to as objects OO allows a programmer to define a class (the type of an object) to fit the problem, rather than being forced into existing data types representing units of storage in a machine Object-orientation allows you to describe the problem in terms of the problem, rather than in terms of the solution SE-1010 Dr. Mark L. Hornick 19
benevolence www.HebronChurchOfChrist.com benevolence "They hate orphans" Said of us Because we don't believe the church is authorized to build or maintain human benevolent organizations Believe church's benevolence is limited And whatever you do in word or deed, do all in...
Classique contre Baroque. Le courant classique s'oppose au courant baroque qui a commencé un peu plus tôt. Par la rigueur de ses valeurs, il s'impose comme une remise en ordre, qui s'articule avec la reprise en main du pays par...
Finite clause is . more resistant to gap. ... Islands result from accumulation of several independent processing difficulties (filler-gap dependency, complex syntactic structure, etc.) ... Latin square design, randomized. Acceptability judgment task, 7-point scale.
Get Your Community To Collaborate On The Same Portal Page Jim Powell Product Manager Oracle Corporation Agenda Collaboration Problems Bringing it all together in OracleAS Portal Pre-Built Portlets Oracle Collaboration Suite Partner and Integration Solutions Building Collaboration Portlets Some Collaboration...
John M. Cioffi EE Dept, Stanford Univ [email protected] Vectored EFM 4 lines in quad are coordinated at one end, or possibly all 50 are coordinated in telco network Allows use of vectored transmitter and receiver Higher rates Lower power/cost as...
Biographism's loss of territory - the concrete author in the shadow - One of the first distinctions between the everyday man and the auctorial "I" was made by Proust, in Contre Sainte-Beuve (written around 1908, published in 1954), and therefore...
The Ashcombe School Other titles: Times New Roman Blank Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint Presentation PowerPoint ...
Ready to download the document? Go ahead and hit continue!