Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 13 Object-Oriented Programming I am surprised.

Slides:



Advertisements
Similar presentations
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 13 Object-Oriented Programming I am surprised.
Advertisements

Technieken van de Software Architectuur, VUB ‘98-’99, Part 11 Object Orientation Review.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
11. A bit of Smalltalk. © O. Nierstrasz P2 — A bit of Smalltalk 11.2 A bit of Smalltalk Overview  Some history  Smalltalk syntax & object model  The.
Principles of Object-Oriented Software Development The language Smalltalk.
2. Smalltalk Basics. © Oscar Nierstrasz ST — Smalltalk Basics 2.2 Roadmap  Everything is an Object  Syntax on a Postcard  Three Kinds of Messages 
Stéphane Ducasse«ChapterNr».1 Abstract Classes Should not be instantiated (abstract in Java) But can defined complete methods Defines a protocol common.
Stéphane Ducasse9.1 Inheritance Semantics and Lookup.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
Stéphane Ducasse 1 The Taste of Smalltalk.
13. A bit of Smalltalk. © Oscar Nierstrasz 2 Roadmap  The origins of Smalltalk  What is Smalltalk?  Syntax in a nutshell  Seaside — web development.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
PZ06BX Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ06BX - Introduction to Smalltalk Programming Language.
2. Smalltalk Basics. © Oscar Nierstrasz ST — Smalltalk Basics 2.2 Roadmap  Everything is an Object  Syntax on a Postcard  Three Kinds of Messages 
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 13 Object-Oriented Programming I am surprised.
Principles of Object-oriented Programming Programming Language Paradigms August 26, 2002.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 7 Semantics Ismael: “Surely all this is not.
03G-1 Everything is an Object Examining builtin classes All these are classes in Little Smalltalk:  Object  Class  Method  Block  Boolean True False.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 13 Object-Oriented Programming I am surprised.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming;
Object-oriented programming and design 1 Smalltalk in a Nutshell Objects & classes Messages & methods Inheritance & metaclasses.
Stéphane Ducasse5.1 Smalltalk in a Nutshell OO Model in a Nutshell Syntax in a Nutshell.
12. A bit of Smalltalk. © O. Nierstrasz P2 — A bit of Smalltalk 11.2 Roadmap  Some history  Smalltalk syntax & object model  The Smalltalk environment.
VB .NET Programming Fundamentals
Stéphane Ducasse 1 Smalltalk in a Nutshell.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 3 Lexical and Syntactic Analysis Syntactic.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 12 Imperative Programming I really hate this.
S.Ducasse Stéphane Ducasse 1 The Taste of Smalltalk.
Java Course Outline Kumar Harshit, USW. Course Description Teaches students to program using the Java programming language with the help of the Netbeans.
3A-1 1 Introduction to Smalltalk History of Smalltalk The philosophy of Smalltalk:  “...we have a universe of well-behaved objects that courteously ask.
Mark Dugopolski Elementary Algebra Edition 3 Chapter 4 Polynomials and Exponents Copyright © 2000 by the McGraw-Hill Companies, Inc.
CSE 3302 Programming Languages Chengkai Li Spring 2008 Object-Oriented Programming Lecture 13 – OO Programming, Spring CSE3302 Programming Languages,
Java Tutorial. Object-Oriented Programming Concepts Object –a representation of some item state  fields/members and should be encapsulated behavior 
CS 598 Scripting Languages Design and Implementation 7. Smalltalk 80.
1 COSC3557: Object-Oriented Programming Haibin Zhu, Ph. D. Associate Professor of CS, Nipissing University.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
Smalltalk for Unix & W i n d o w s Dennis Smith Cherniak Software Development Corporation.
Introduction to Polynomials
Smalltalk (and Squeak) Aida Dungan and Rick Shreve.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Squeak and Botkit-Port Jeff Forbes Joel Miller. Introduction ● Squeak is a pure OO language ● Based off of SmallTalk-80 – Designed at Xerox PARC by Alan.
CHAPTER OUTLINE 10 Exponents and Polynomials Slide 2 Copyright (c) The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 10.1Addition.
+ Ruby and other programming Languages Ronald L. Ramos.
Smalltalk in a.NET World How to write a Smalltalk compiler without writing a VM John Brant
Objective-C Drew Cheng CS420. Overview True superset of ANSI C Object-Oriented methods from SmallTalk There is no formal written standard for the language.
RUBY by Ryan Chase.
1 Copyright © 1998 by Addison Wesley Longman, Inc. Chapter 11 Categories of languages that support OOP: 1. OOP support is added to an existing language.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 1 Overview A good programming language is.
3C-1 Identifiers Variables Literal Objects  Numbers  Characters  Strings Control Structure  Blocks  Conditionals  Loops Messages Defining New Classes.
Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 2 Syntax A language that is simple to parse.
1 Advanced Object Oriented Systems (CM0318) Lecture 8 (Last updated 15th February 2002)
S.Ducasse Stéphane Ducasse 1 Smalltalk in a Nutshell.
S.Ducasse Stéphane Ducasse savoie.fr e/ e/ 1 Smalltalk in a Nutshell.
CSE 3302 Programming Languages Chengkai Li Fall 2007 Smalltalk Lecture 14 – Smalltalk, Fall CSE3302 Programming Languages, UT-Arlington ©Chengkai.
Stéphane Ducasse 1 A Little Journey in the Smalltalk Syntax.
Stéphane Ducasse 1 Abstract Classes.
Administrative Issues Lecture 22 – Prolog (III), Fall 2007 CSE3302 Programming Languages, UT-Arlington ©Chengkai Li, HW3 (due at March 18 th ) Essay.
CSCI/CMPE 4341 Topic: Programming in Python Chapter 7: Introduction to Object- Oriented Programming in Python – Exercises Xiang Lian The University of.
Let’s Play Objects.
7.1 What Is An Object Object-oriented program - Description or simulation of application Object-oriented programming is done by adopting or extending an.
Object-Oriented Programming
Introduction to Polynomials
CS 331 Principles of Programming Languages
Introduction to Smalltalk
Let’s Talk about… Smalltalk.
Introduction to Smalltalk
CSE 3302 Programming Languages
Smalltalk on a Dime.
Presentation transcript:

Copyright © 2006 The McGraw-Hill Companies, Inc. Programming Languages 2nd edition Tucker and Noonan Chapter 13 Object-Oriented Programming I am surprised that ancient and Modern writers have not attributed greater importance to the laws of inheritance... Alexis de Tocqueville

Copyright © 2006 The McGraw-Hill Companies, Inc. Contents 13.1 Prelude: Abstract Data Types 13.2 The Object Model 13.3 Smalltalk 13.4 Java 13.5 Python

Copyright © 2006 The McGraw-Hill Companies, Inc Smalltalk the original object-oriented language developed in 1970s at Xerox PARC Xerox Alto –Smalltalk system –OS –IDE –mouse based GUI –Steve Jobs visit

Copyright © 2006 The McGraw-Hill Companies, Inc. General Characteristics Simple language Most of the class libraries written in Smalltalk Everything is an object, even control structures Excluding lexical productions, grammar has 21 productions (3 pages)

Copyright © 2006 The McGraw-Hill Companies, Inc. The value of every variable is an object; every object is an instance of some class. A method is triggered by sending a message to an object. –The object responds by evaluating the method of the same name, if it has one. –Otherwise the message is sent to the parent object. –The process continues until the method is found; otherwise an error is raised. All methods return a value (object).

Copyright © 2006 The McGraw-Hill Companies, Inc. Precedence Unary messages, as in: x negated Binary messages, as in: x + y Keyword messages, as in: Turtle go: length In the absence of parentheses, code is evaluated from left to right.

Copyright © 2006 The McGraw-Hill Companies, Inc. Examples: x + y * z squared a max: b - c anArray at: i put: (anArray at: i + 1) By default, Smalltalk uses infinite precision, fractional arithmetic. 1/3 + 2/6 + 3/9 evaluates to 1.

Copyright © 2006 The McGraw-Hill Companies, Inc. (a > b) ifTrue: [ max := a ] ifFalse: [ max := b ]. [ ] - uninterpreted block Boolean method Distinct from: ifFalse:ifTrue:

Copyright © 2006 The McGraw-Hill Companies, Inc. sum := 0. 1 to: n do: [ :i | sum := sum + (a at: i) ]. sum := 0. a do: [ :x | sum := sum + x ]. sum := 0. i := 1. [ i <= n ] whileTrue: [ sum := sum + (a at: i). i := i + 1].

Copyright © 2006 The McGraw-Hill Companies, Inc. "True methods" ifTrue: trueBlock ifFalse: falseBlock ^ trueBlock value ifTrue: aBlock ^ aBlock value ifFalse: aBlock ^ nil ifFalse: falseBlock ifTrue: trueBlock ^ trueBlock value

Copyright © 2006 The McGraw-Hill Companies, Inc. Examle: Polynomials Represent Polynomials: 3 x 2 + 5x - 7 Representation: #(-7 5 3) Subclass of Magnitude

Copyright © 2006 The McGraw-Hill Companies, Inc. Magnitude subclass: #Polynomial instanceVariableNames: 'coefficient' classVariableNames:: '' poolDictionaries: '' new "Unary class constructor: return 0*x^0" ^ self new: #( 0 ) new: array "Keyword class constructor" ^ (super new) init: array

Copyright © 2006 The McGraw-Hill Companies, Inc. init: array "Private: initialize coefficient" coefficient := array deepCopy degree "Highest non-zero power" ^ coefficient size - 1 coefficient: power "Coefficient of given power" (power >= coefficient size) ifTrue: [ ^ 0 ]. ^ coefficient at: power + 1

Copyright © 2006 The McGraw-Hill Companies, Inc. asArray ^ coefficient deepCopy = aPoly ^ coefficient = aPoly asArray != aPoly ^ (self = aPoly) not < aPoly "not defined" ^ self shouldNotImplement