12. Objects I

50 %
50 %
Information about 12. Objects I
Education
dry

Published on February 24, 2014

Author: JosephHenryMurphy

Source: slideshare.net

From last time… • We discussed Iteration 1 expectations! • Functions:! ! - DRY: Don’t Repeat Yourself! ! - How to “read” a function definition! ! - Type & number of arguments must match! ! - Arguments are passed by copy into functions! • Reviewed Quiz 2: Variables, Conditionals, Loops

“All programming languages ! are exactly the same.” Prof. Angelos Barmpoutis! University of Florida

Programming Languages vs. Natural Languages Variables, Operations, Logical Operators Sounds, Words Functions Sentences Conditional Statements Paragraphs Objects Chapters, Entire Books

Objects I CAP

Object-Oriented Programming • OOP is a programming paradigm! • It a mental model for thinking about code! • It informs the organization & structure of code! • Object-oriented code is organized into “objects” that interact with each other

c++ c# smalltalk ruby php java objective-c python perl

What do we know so far… Data! variables – store data: int, boolean, float, etc.! operations – manipulate data: + - / *! logical operators – compare data: > < >= <= ==! Functionality! functions – simple behavior: size(), fill() loops – repeated behavior: for (int i = 0; i < 100; i++)! conditionals – flow control: if (conditional) {} else {}

Objects • It makes sense to organize related data and functionality into one thing! • We call this thing an ‘object’! • Any thing in the world could be viewed as an object—as a grouping of data and functionality

Object-Oriented Thinking • An Animal! • A Human! • A Vehicle! • A Celestial Body… and Gravity! • An Email… An Inbox… and An Email Application! • In programming, objects are defined by classes

Class Anatomy Name Class! Blueprint! Cookie Cutter! Mould Data What is the class called? What are its attributes?! What state is currently it in? Constructor When I create a new one,! what do I need to do? Functionality What actions can it take?! What does it do?

Class Anatomy Name Class! Blueprint! Cookie Cutter! Mould Data Constructor Functionality Vehicle String type; // e.g.,“Car” float price; // e.g., 7825 Vehicle(type, price) moveForward(); moveBackward(); honk(); Notice that a class is a generic blueprint–a container.! It has placeholders for data, and defines functionality.

Classes make Objects Class! Object! Object! Object! Vehicle! Vehicle! Vehicle! Vehicle! ! ! ! ! ! String type! float price “Car”! 2374.72 “Car”! 4255.95 “Airplane”! 400000 These are instances of the Vehicle Class

Demo! A Star Class

Remember… A class must have 4 things:! 1. a name! 2. attributes (variables)! 3. a constructor (run once, when we use new)! 4. methods (functions)! Learn and memorize how to make code into classes!

“All programming languages ! are exactly the same.” Prof. Angelos Barmpoutis! University of Florida

Unified Modeling Language UML defines a consistent method for diagramming a class. This is what a “Class Diagram” looks like: Name! ! Variables! ! ! Methods

Class Diagram Example Email Inbox MailManager to from subject body name emails inboxes displayEmail orderEmailsByAlpha orderEmailsByDate displayInbox createEmail sendEmail checkEmail

For next time… • Read Shiffman, p. 130–137 (Objects II)! • Keep working on Iteration 1

Add a comment

Related presentations

Related pages

12 Objects

12 Objects . 01 The Guardian. 1900s . 1910s . 1920s . 1930s . 1940s . 1950s . 1960s . 1970s . 1980s . 1990s
Read more

Web Help - Website Design Software | NetObjects Fusion

Web Help - Website Design Software | NetObjects Fusion
Read more

Webdesign-Software: Einfach bessere Webseiten erstellen

Die NetObjects Fusion Webdesign-Software steht weltweit bei Kritikern und Anwendern hoch im Kurs als eines der schnellsten, einfachsten Tools zum Erstellen ...
Read more

Introduction to Objects I | Codecademy

Codecademy is the easiest way to learn how to code. It's interactive, fun, and you can do it with your friends.
Read more

iphone - Insert 12 objects into NSMutableArray - Stack ...

I wish to add 12 objects to a nsmutablearray, ready for the command InsertObject:atIndex: There must be a quicker way than [self.YoutubeArray addObject ...
Read more

12 objects in 3 weighings - Financial Markets and ...

We start with the case when w=3, and so there are 12 objects. ... This results in 12 double-objects, one of which is a different weight, ...
Read more

Introduction to Objects I Forum | Codecademy

Introduction to Objects I Forum. Log in. Sign up. This forum is now read-only. Please use our new forums at discuss.codecademy.com. Course Forum; Section 2;
Read more

12. Object-oriented Design - Research in Innovation ...

Object-oriented Design 1 ©Ian Sommerville 1999 12. Object-oriented Design Objectives The objective of this chapter is to introduce an approach to software ...
Read more

A History of Chris Christie in 12 Objects

Christie's political career began at age 14, when he heard Thomas H. Kean Sr., the future New Jersey governor, who was then an assemblyman, speak at his ...
Read more

Microsoft Access 12.0 Object Library - CodeProject

The same goes for Microsoft Excel 12.0 Object library. Yet however, if I try Microsoft Excel 5.0 Object library it works. What am I doing wrong?
Read more