Guru 101 Grokking the Smalltalk system. Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group
|
|
- Gertrude Nelson
- 5 years ago
- Views:
Transcription
1 Guru 101 Grokking the Smalltalk system Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group
2 About this talk 10:00-12:00 AM Coffee break Beer afterwards Intermediate Assumes you know Smalltalk Not all answers are supplied
3 Introduction What is meta-level programming? Manipulating object state Manipulating object behavior Manipulating the environment Techniques & applications
4 My Goal I can t tell you all there is to know I can show you some basics, some structure, and some interesting things I can point you in the right direction, and let your curiosity lead you on
5 What Is Meta-level Programming? Meta-level programming is writing programs that manipulate not your objects, the way usual programs do, but the representations of your objects
6 The Good, the Bad, and the Ugly Smalltalk makes meta-level programming easy. Too easy, in fact When you meta program, you are no longer really programming in Smalltalk. The toolset doesn t support you that well. You can no longer read a line of code and guess what it does correctly
7 The First Rule of Meta-programming Save your image!
8 The Different Areas Manipulating object state Manipulating object behavior Manipulating the environment
9 Topic One - Manipulating Object State Object definitions Class definitions
10 Object Definitions and Instance Variables Objects tend to fall into two basic categories: Objects with indexed instance variables, such as arrays and strings Objects with named instance variables, such as person, with variables such as firstname, lastname and so on
11 Object Definitions and Instance Variables Or, looking at it in another way: Objects with pointer instance variables Objects with arrays of single bytes (or words, or longs)
12 Objects With Pointer Instance Variables Most instance variables are pointers, that is, they point to another object. The firstname instance variable of a person (normally) points to a string, the size variable of an orderedcollection points to an integer. The pointers do not need to be named. Indexed objects such as arrays can also store pointers
13 Objects With Arrays of Single Bytes Some objects store arrays of single bytes directly, like a string in C. Since arrays of bytes are needed frequently, this is much more efficient than storing an array of pointers, each pointing to a single byte
14 Class Types Indexed Pointers Creation method Examples No Yes #subclass Object, Behavior Yes Yes #variablesubclass Array,CompiledMethod Yes No #variablebytesubclass String, ByteArray No No (none) (none) The fourth combination of bytes/no index has no examples. Although possible, creating a class like this would mean that you want every byte to have its own name - a rather dubious benefit
15 Restrictions on Subclasses As you may have noticed, classes are sensitive to how their subclasses are defined
16 Classes Defined With #subclass These can have any kind of subclass
17 Classes Defined With #variablesubclass These can only have subclasses which are #variablesubclass or #variablebytesubclass Once you use indexes, all subclasses must also use indexes
18 Classes Defined With #variablebytesubclass You can only use #variablebytesubclass to create a class if the superclass has no defined instance variables Pointer classes and byte classes don t mix Byte classes can only have subclasses which are also #variablebytesubclass Once you use bytes, all subclasses must also use bytes
19 Methods Relating to Class Type Class>>isPointers Class>>isBits Class>>isBytes Class>>isFixed Class>>isVariable Class>>kindOfSubclass
20 Accessing Instance Variables Directly Object>>at:, object>>basicat: For indexed objects, both byte and pointer, you can use the famous #at: method. If a class has overridden #at: (e.g. Dictionary), you can use #basicat: to do direct access Object>>instVarAt: To access named instances, use #instvarat:, which takes an integer index. The index is the offset of the variable in #allinstvarnames. #instvarat: does not work for byte objects
21 Methods Relating to Instance Variables Object>>size Object>>basicSize Class>>instVarNames Class>>instanceVariableString Class>>allInstVarNames Class>>instSize
22 Topic Two - Manipulating Object Behavior State flags State object / strategy object Pluggable selector Pluggable block Pluggable method dictionary
23 State Flags Use a boolean flag to differentiate between cases display ishighlighted iftrue: [self displayhighlighted] iffalse: [self displayunhighlighted]
24 State Object / Strategy Object Your object has a number of different states or algorithms Reliance on state or strategy often extends to several methods, creating a maintenance headache Case statements are ugly anyway Create an object for each state or strategy Hold the state or strategy object in an instvar Delegate to the state or strategy object
25 Pluggable Selector The simplest way to implement pluggable behavior is to store a selector to be performed Add a variable which holds the selector Append message or selector to the variable name Create a composed method which simply performs the selector
26 #perform: #perform: sends the receiver the message given as the argument The argument must be a symbol, but it can be put together at run-time There are variations of #perform: perform: asymbol perform: with: perform: with: with: perform: with: with: with: perform: witharguments:
27 Pluggable Selector Example An example for displaying an object hierarchy createviews childrenmessage := #sortedsubclasses getchildren objectlist notnil iftrue: [ objectlist do: [ :object object perform: #childrenmessage]]. self updatelistbox
28 Pluggable Block How do you implement pluggable behavior that is not quite worth its own class? Add a variable which holds the block Append block to the variable name Create a composed method which simply evaluates the block
29 Pluggable Block Disadvantages Pluggable blocks come at a great cost You can t statically analyse the code to understand the flow of control Even inspecting the plugged object doesn t really help The only solution is to single step through the block invocation Blocks are difficult to store on external media Some object streams cannot store and retrieve blocks
30 Pluggable Block Example An example for displaying on a medium initialize displayblock := [ :amedium amedium black] displayon: amedium displayblock value: amedium
31 Pluggable Method Dictionary You have objects that need to change their logic (at runtime) You cannot anticipate all needed behavior You want an elegant solution. (Or you want to show off your Smalltalk skills ;-)
32 Solution Make each instance specializable. You or your users can change the meaning of any message without affecting any other instances You specialize an instance by giving it its own method dictionary
33 The Method Dictionary The method dictionary (really dictionaries) for a class is simply a dictionary with symbols (selectors) as the keys, and CompiledMethods (the actual code) as the values Behavior>>addSelector: asymbol withmethod: acompiledmethod Behavior>>removeSelector: asymbol
34 Method Names Note that the method names are just symbols - there are no absolute restrictions on method names. The only problem is getting the compiler to accept them. You could use an acceptable name for the compiler, but then rename the method when you add it to the method dictionary!
35 Accessing the Method Dictionary Behavior>>selectors Behavior>>includesSelector: asymbol Behavior>>canUnderstand: asymbol Behavior>>respondsTo: asymbol Behavior>>implementorsOf: asymbol Behavior>>compiledMethodAt: asymbol
36 #doesnotunderstand: If your class doesn t have a method in its dictionary, the VM looks in the method dictionary of the superclasses, all the way to object If object doesn t have the method in its dictionary, the VM sends #doesnotunderstand: amessage You can override # doesnotunderstand : to do what you want: doesnotunderstand: amessage ^self printstring perform: amessage selector witharguments: amessage arguments
37 Specialized Instances The way to keep changes from one instance from affecting the others of its class is simple: they don t all point to the same class object To be separately specializable, they need to point to different class objects, each of which inherits from the original class This way, methods installed for one instance are installed only in that instance s personal class, and not the common one
38 Essentially We insert an unnamed class in the hierarchy below the object s class, and make the object a member of this unnamed class How we do this depends on the dialect
39 VisualWorks In VisualWorks, every object has a hidden instance variable that holds its class The class has an instance variable that holds a method dictionary Point Class class x 55 name Point MethodDictionary y 77 methods values keys #+ #dist: CompiledMethod CompiledMethod
40 VisualWorks When the object is sent a message Its class is fetched The class MethodDictionary is fetched The selector of the message is looked up in the dictionary The CompiledMethod found there is activated
41 Instance Specialization Point class x 47 y 11 Point class x 23 y 42 name methods Class Point class x y class x y Point Point Behavior superclass methods Behavior superclass methods name methods Class Point
42 Instance Specialization If you want all instances of your class to be specializable, you can override #new new Create a speciaizable instance ^Behavior new superclass: self; format: self format; methoddictionary: MethodDictionary new; new Implement the following instance method to specialize behavior specialize: astring Compile astring as a method for this instance only self class compile: astring notifying: nil
43 Lazy Specialization You might only want to specialize when necessary. Use these methods for lazy specialization: specialize: astring Compile astring as a method for this instance only self specialize. self class compile: astring notifying: nil specialize class self isspecialized iftrue: [^self]. class := Behavior new superclass: self class; format: self class format; methoddictionary: MethodDictionary new. self changeclasstothatof: class basicnew isspecialized ^self class shouldberegistered
44 Visual Smalltalk In Visual Smalltalk, each instance has a reference, not to its class, but to an array of MethodDictionaries Each method dictionary has an instance variable called class, which is set to the class to which it belongs #class is implemented in Visual Smalltalk by running down the array of method dictionaries and finding the first one whose class field is set. You can change the class by changing the method dictionary array
45 Visual Smalltalk Point class Array MethodDictionary x y values Class keys #+ #dist: CompiledMethod CompiledMethod name methods Point values keys MethodDictionary
46 Instance Specialization class x y Point Array MethodDictionary Class Array MethodDictionary name methods Point MethodDictionary
47 Instance Specialization Any object can build the array of method dictionaries To specialize an instance, we: Fetch the method dictionary array Copy it, adding a slot at the beginning holding a fresh MethodDictionary instance The methods needed for this are already implemented
48 Visual Smalltalk Relevant methods addbehavior: MethodDictionary removebehavior: MethodDictionary reverttoclassbehavior methoddictionaries methoddictionaryarray methoddictionaryarray: anarray
49 Instance Specialization If you want all instances specializable: new ^super new specialize The other methods isspecialized ^self methoddictionaryarray == self class methoddictionaries specialize self isspecialized iftrue: [^self]. self addbehavior: MethodDictionary new. specialize: astring association self specialize. association := Compiler compile: astring in: self class. self methoddictionaryarray first add: association
50 Example partdoit: amethod witharguments: anarray Answer the result of evaluating the temporary instance method <amethod> with the argument values in <anarray> mdtemp result mdtemp := MethodDictionary new at: amethod selector put: amethod; yourself. self addbehavior: mdtemp. [result := self perform: amethod selector witharguments: anarray] ensure [self removebehavior: mdtemp]. ^result
51 The Difference In VisualWorks, you access the method dictionary through the class instvar In Visual Smalltalk, you access the class through the method dictionary
52 VisualAge The VisualAge programming model is similar to the VisualWorks model, with a few changes The new unnamed class must be subclassed from Class, not Behavior new Create a specializable instance ^Class new superclass: self; instanceshape: self instanceshape instvarnames: self instvarnames; setmethoddictionary: MethodDictionary new; new
53 VisualAge In VisualAge, both MethodDictionary and CompiledMethod are directly subclassed from object
54 Lazy Specialization Use these methods for lazy specialization: specialize: astring Compile astring as a method for this instance only self specialize. self class compile: astring notifying: nil specialize class self isspecialized iftrue: [^self]. class := Class new superclass: self class; instanceshape: self instanceshape instvarnames: self instvarnames; setmethoddictionary: MethodDictionary new. self changeclassto: class isspecialized ^self class name isnil
55 VisualAge In VisualAge, we need to define the following method in Object: changeclasstothatof: anobject self fixclassto: anobject class
56 Topic Three - Some Practical (and Not-so Practical) Applications Type-safe objects Code generation Metrics and code quality tools
57 Type-safe Objects You can t be serious! TypedValueHholder WorkingObject #doesnotunderstand:
58 TypedValueHolder Similar to PluggableAdaptor Instance variables value - the real object type - the object class getblock - a block for getting the value setblock - a block for setting the value validateblock - a block for validating possible new values
59 WorkingObject Instance variables variables - a dictionary of typedvalueholders realobject - the object that we re wrappering Methods Class #on: arealobject #updatedrealobject #doesnotunderstand:
60 #doesnotunderstand: doesnotunderstand: amessage "Private - See if the message selector is one of the field names of the receiver. If so, access that field. If not, see whether the real object understands the message. If so, let him respond to it. Else scream" field s key s := amessage selector. key := (s select: [ :c (c = $:) not ]) assymbol. field := variables at: key ifabsent: [ (self realobject respondsto: s) iftrue: [ ^(amessage receiver: self realobject) perform] iffalse: [ ^super doesnotunderstand: amessage]]. s last = $: iftrue: [^self privateat: key put: amessage arguments first] iffalse: [^self privateat: key]
61 Metrics Metrics are measures of important properties of the software being tested Metrics use the following meta-level facilities Class and class hierarchy queries Method queries Possible applications include Statistical analysis Project management
62 Metrics Metrics can be used to understand and predict the quality and cost of developing and maintaining large computer systems They can also be used to determine qualitative differences between different development projects If a particular library contains an average of 60 methods per class but the average over a number of projects is 20, DON'T YOU WANT TO KNOW WHY?
63 Different Kinds of Metrics There are two major categories of metric measurements: Static measures (time-independent) Easily obtained from Smalltalk because of meta-level facilities Dynamic measures (time-dependent) Best gathered in the context of team development tools like ENVY/developer and Team/V. This includes: Run-time measures (requires code execution) Evolutionary measures (requires histories over time) W. LaLonde, J. Pugh, Gathering metric information using metalevel facilities, Journal of object-oriented programming, March-April
64 What Not to Do ;-) Before this course Hello World edit After this course [(Smalltalk at: #PendingEvents) perform: (OrderedCollection compiledmethodat: #add:) with: (Message new receiver: ( #($H $e $l $l $o $ $W $o $r $l $d inject: into:[ :sum :value sum, value asstring]) selector: ( tide reverse assymbol) arguments: #())] fork
65 Summary Meta-level programming can be fun! Just because you can do it doesn t mean that you must do it Take your time (you ll need a lot of it anyway)
66 Caveat Meta-programming is important for mastery of Smalltalk, but it is not important for effective engineering. In fact, it's far more important to know when NOT to use it than it is to know how TO use it. - Kent Beck
Squeak Object Model. Technion - Israel Institute of Technology. Updated: Spring Object-Oriented Programming 1
Squeak Object Model Technion - Israel Institute of Technology Updated: Spring 2015 236703 - Object-Oriented Programming 1 Agenda Class exploring Class object, default / common behaviors Objects equality
More informationEliminating Procedural Code
Chapter 28 Eliminating Procedural Code In procedural programming, we write a lot of code that gets information then makes a decision based on the information. In C, we see a lot of if/else if/else blocks,
More informationObject. Accessing. Changing. Chapter
Chapter 10 Object Smalltalk is a rooted system, which means that there is a root superclass from which all other classes are descended. That root superclass is Object. (Actually, there other root classes,
More informationThe Smalltalk class hierarchy
The Smalltalk class hierarchy As we have seen, classes in Smalltalk are arranged in the form of a tree. The class above a given class in the hierarchy is its superclass; classes below are its subclasses.
More informationCHAIN OF RESPONSIBILITY (DP 223)
CHAIN OF RESPONSIBILITY (DP 223) Object Behavioral Intent Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request. Chain the receiving objects
More information9. Understanding Classes and Metaclasses
9. Understanding Classes and Metaclasses ST Introduction Birds-eye view Reify your metamodel A fully reflective system models its own metamodel. 1.2 Roadmap > Metaclasses in 7 points > Indexed Classes
More informationAn Introduction to Smalltalk for Objective-C Programmers
An Introduction to Smalltalk for Objective-C Programmers O Reilly Mac OS X Conference October 25 28, 2004 Philippe Mougin - pmougin@acm.org http://www.fscript.org IT Management & Consulting What you will
More informationBasic Objects, Conditionals and Loops
Basic Objects, Conditionals and Loops Booleans Basic Loops Overview of the Collection hierarchy more than 80 classes: (Bag, Array, OrderedCollection, SortedCollection, Set, Dictionary...) Loops and Iteration
More informationThe DCI Paradigm Implemented in Squeak
The DCI Paradigm Implemented in Squeak Trygve Reenskaug, Dept. of Informatics, University of Oslo, Norway Home: http://folk.uio.no/trygver E-mail: The DCI paradigm separates a program into different perspectives
More informationXXXXXXXXXXXXXXXXXXXXXXX. Evolution of Software Languages
Section 8: Simula Smalltalk Evolution of Software Languages Theo D'Hondt Bachelor of Computer Science Faculty of Sciences and Bio-Engineering Sciences Vrije Universiteit Brussel Academic Year 2015-2016
More informationLord of the Base Image - Things every Library Supervisor should know
Lord of the Base Image - Things every Library Supervisor should know Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group jpelrine@daedalos.de About this Tutorial 16:30-18:00 PM Coffee
More informationWorking with Bytecodes: IRBuilder and InstructionStream. Marcus Denker. Reasons for working with Bytecode
Working with Bytecodes: IRBuilder and InstructionStream Reasons for working with Bytecode Generating Bytecode Implementing compilers for other languages Experimentation with new language features Parsing
More informationOO design. Classes, Responsibilities, Collaborations (CRC) 13/9/1999 COSC
OO design Classes, Responsibilities, Collaborations (CRC) 1 bank accounts the system to be modelled: bank accounts with differing fee structures purpose: evaluate different account types with respect to
More informationST Introduction. Birds-eye view
3. Standard Classes ST Introduction Birds-eye view Reify everything by reifying its entire implementation model, Smalltalk succeeds in being open, and extensible. New features can be added without changing
More informationThere are a few important ways that Smalltalk is different then other languages:
The Presenters Ginny Ghezzo: Project Manager for IBM VisualAge Smalltalk and Level 3 support for the Application Builder Craig Chaney: Technical Lead on the Virtual Machine, Communications and Linux development
More informationEfficient Proxies in Smalltalk
Efficient Proxies in Smalltalk Mariano Martinez Peck 12 Noury Bouraqadi 2 Marcus Denker 1 Stéphane Ducasse 1 Luc Fabresse 2 1 RMoD Project-Team, Inria Lille Nord Europe / Université de Lille 1 2 Université
More informationSmalltalk. Topics. History of Smalltalk. OOP and GUI. Steve Jobs, PARC, Dec Smalltalk 1. The best way to predict the future is to invent it.
Smalltalk The best way to predict the future is to invent it. Alan Kay, 1971 Topics History and significance of Smalltalk Object-oriented programming The Smalltalk language Smalltalk today Additional Examples
More informationSmalltalk Implementation
Smalltalk Implementation Prof. Harry Porter Portland State University 1 The Image The object heap The Virtual Machine The underlying system (e.g., Mac OS X) The ST language interpreter The object-memory
More informationSafely Extending the Environment Part 2 - being a good citizen Joseph Pelrine Daedalos Consulting
Safely Extending the Environment Part 2 - being a good citizen Joseph Pelrine Daedalos Consulting I just got back from Smalltalk Solutions (although that s the topic for another article - or a couple).
More informationSmalltalk FOOP. Smalltalk
2015-03-20 Smalltalk Smalltalk 2015-03-20 Smalltalk 1 First Examples hello Transcript show: Hi World hello5 1 to: 5 do: [:i (Transcript show: Hi World ) cr] hello: times 1 to: times do: [:i (Transcript
More informationAbstract Interpretation for Dummies
Abstract Interpretation for Dummies Program Analysis without Tears Andrew P. Black OGI School of Science & Engineering at OHSU Portland, Oregon, USA What is Abstract Interpretation? An interpretation:
More informationTemplate Method Structure. Template Method Example. Template Method Example. Template Method Example. Benefits of Template Method
Design Patterns in Smalltalk CSC591O April 9, 1997 Raleigh, NC Bobby Woolf Senior Member of Technical Staff Knowledge Systems Corp. 4001 Weston Parkway Cary, North Carolina 27513-2303 919-677-1116 bwoolf@ksccary.com
More informationSmalltalk Best Practice Patterns. Part I
Smalltalk Best Practice Patterns Part I 1 Based on the Book by Kent Beck 2 Based on the Book by Kent Beck Very little here is Smalltalk-specific 2 Why Patterns? 3 Why Patterns? There are only so many ways
More informationFrom Design to Implementation
From Design to Implementation The Presenters Rick Trotter, IBM Smalltalk Group Dave Maeda, IBM Smalltalk Group Coding the video-store application Today we will see how the video-store application Booch
More informationSyntax and Messages. Stéphane Ducasse 8.1
Syntax and Messages The syntax of Smalltalk is simple and uniform, but it can look strange at first sight! Literals: numbers, strings, arrays... Variable names Pseudo-variables Assignments, returns Message
More informationLATENT METHODS. Richard CS
LATENT METHODS Richard O'Keefe @ CS Outline Background The problem Some non-solutions My solution Does it apply elsewhere Background Alan Kay invented tablet computers (the Dynabook) His research group
More informationThis chapter describes some of the more common errors that Smalltalk programmers make and gives suggestions on how to prevent the errors.
Chapter 22 Common Errors This chapter describes some of the more common errors that Smalltalk programmers make and gives suggestions on how to prevent the errors. Notifier window messages As you test your
More informationAbout Instance Initialization
Learning Object-Oriented Programming and Design with TDD About Instance Initialization Stéphane Ducasse http://stephane.ducasse.free.fr http://www.pharo.org W5S06 W5S06 2 / 26 How to ensure that an instance
More informationBuilding a Gopher from Sockets and Widgets
an article for The Smalltalk Report by Patrick Mueller Patrick Mueller is a member of the IBM Smalltalk Distributed team in IBM Cary. He coauthored the HP/IBM submission to OMG for Smalltalk mappings to
More informationChapter 11. Categories of languages that support OOP: 1. OOP support is added to an existing language
Categories of languages that support OOP: 1. OOP support is added to an existing language - C++ (also supports procedural and dataoriented programming) - Ada 95 (also supports procedural and dataoriented
More informationPrototyping Languages Related Constructs and Tools with Squeak
Prototyping Languages Related Constructs and Tools with Squeak Alexandre Bergel Distributed Systems Group Dept. of Computer Science Trinity College Dublin 2, Ireland www.cs.tcd.ie/alexandre.bergel Marcus
More informationPharo Syntax in a Nutshell
Pharo Syntax in a Nutshell Damien Cassou, Stéphane Ducasse and Luc Fabresse W1S06, 2015 W1S06 2 / 28 Getting a Feel About Syntax In this lecture we want to give you the general feel to get started: Overview
More informationAdriaan van Os ESUG Code Optimization
Introduction Working at Soops since 1995 Customers include Research (Economical) Exchanges (Power, Gas) Insurance Projects in VisualWorks GemStone VisualAge 2 Demanding projects Data-intensive Rule based
More informationOO Design with Smalltalk a Pure Object Oriented Language and Environment
OO Design with Smalltalk a Pure Object Oriented Language and Environment About the exercises The exercises developped in the following lessons have been originally written by Roel Wuyts and Koen De Hondt
More informationLecture 13: Object orientation. Object oriented programming. Introduction. Object oriented programming. OO and ADT:s. Introduction
Lecture 13: Object orientation Object oriented programming Introduction, types of OO languages Key concepts: Encapsulation, Inheritance, Dynamic binding & polymorphism Other design issues Smalltalk OO
More informationThe System Transcript, Class Point and Inspectors
Module 4 1 Module 4: The System Transcript, Class Point and Inspectors This module starts by introducing the System Transcript, illustrating how it can be used with a number of examples. The Transcript
More informationGhost: A Uniform and General-Purpose Proxy Implementation
Ghost: A Uniform and General-Purpose Proxy Implementation Mariano Martinez Peck 1,2,, Noury Bouraqadi 2,, Luc Fabresse 2,, Marcus Denker 1,, Camille Teruel 1, Abstract A proxy object is a surrogate or
More informationUniversity of Berne Institute of Computer Science
University of Berne Institute of Computer Science http://www.iam.unibe.ch/~ducasse/ SUnit Explained Stéphane Ducasse (revised by Rick Zaccone) Directory Table of Contents Begin Article Copyright c 2003
More informationObject Model. Object Oriented Programming Spring 2015
Object Model Object Oriented Programming 236703 Spring 2015 Class Representation In Memory A class is an abstract entity, so why should it be represented in the runtime environment? Answer #1: Dynamic
More informationExceptions. References. Exceptions. Exceptional Conditions. CSE 413, Autumn 2005 Programming Languages
References Exceptions "Handling Errors with Exceptions", Java tutorial http://java.sun.com/docs/books/tutorial/essential/exceptions/index.html CSE 413, Autumn 2005 Programming Languages http://www.cs.washington.edu/education/courses/413/05au/
More informationObject-Oriented Thinking
Chapter 9 Object-Oriented Thinking Smalltalk is one of the pure Object-Oriented (OO) languages. Unlike C++, which makes it very easy to write procedural code (ie, use C++ as a better C), Smalltalk makes
More information2. Classes & Inheritance. Classes. Classes. Éric Tanter Objects and Design in Smalltalk. How do you create objects?
Objects and Design in Smalltalk 2. Classes & Inheritance Éric Tanter etanter@dcc.uchile.cl 1 Classes How do you create objects? Ex-nihilo in prototype-based languages With a class in class-based languages
More informationST Introduction. Birds-eye view
6. Debugging ST Introduction Birds-eye view It can be easier to talk to objects than to read classes The system is alive. Talk to it. The debugger can be your best friend. Donʼt be afraid of it. 1.2 Roadmap
More informationIdioms for Building Software Frameworks in AspectJ
Idioms for Building Software Frameworks in AspectJ Stefan Hanenberg 1 and Arno Schmidmeier 2 1 Institute for Computer Science University of Essen, 45117 Essen, Germany shanenbe@cs.uni-essen.de 2 AspectSoft,
More informationObject Oriented Paradigm Languages
Object Oriented Paradigm Languages The central design goal is to build inherent abstraction into the system, moving all the abstract implementation details from the user level (ad-hoc) to the system level
More informationRoos Instruments, Inc. RTALK - SMALLTALK ON THE JVM
Roos Instruments, Inc. RTALK - SMALLTALK ON THE JVM Roos Instruments, Inc. HARDWARE AND SOFTWARE FOR IC TEST Smalltalk Basics Message Based Everything is an Object Simple syntax Fast ODA ( On Demand Assembler
More informationDesign issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?
Encapsulation Encapsulation grouping of subprograms and the data they manipulate Information hiding abstract data types type definition is hidden from the user variables of the type can be declared variables
More informationDerived and abstract data types. TDT4205 Lecture 15
1 Derived and abstract data types TDT4205 Lecture 15 2 Where we were We ve looked at static semantics for primitive types and how it relates to type checking We ve hinted at derived types using a multidimensional
More informationINVAIDER: A FRAMEWORK FOR VISUAL PROGRAMMING LANGUAGES. B.S., University of Illinois, 1990 THESIS. Submitted in partial fulllment of the requirements
INVAIDER: A FRAMEWORK FOR VISUAL PROGRAMMING LANGUAGES BY JAMES MICHAEL CONTI B.S., University of Illinois, 1990 THESIS Submitted in partial fulllment of the requirements for the degree of Master of Science
More informationCS354 gdb Tutorial Written by Chris Feilbach
CS354 gdb Tutorial Written by Chris Feilbach Purpose This tutorial aims to show you the basics of using gdb to debug C programs. gdb is the GNU debugger, and is provided on systems that
More informationThe Smalltalk Environment, SUnit, and Inheritance
Creating Objects in Smalltalk The Smalltalk Environment, SUnit, and Inheritance Object are created by sending a message to some other (exisiting!) object called a factory! Usually, the factory object is
More informationRefactorings. Refactoring. Refactoring Strategy. Demonstration: Refactoring and Reverse Engineering. Conclusion
Refactorings Refactoring What is it? Why is it necessary? Examples Tool support Refactoring Strategy Code Smells Examples of Cure Demonstration: Refactoring and Reverse Engineering Refactor to Understand
More informationA Lazy List Implementation in Squeak
A Lazy List Implementation in Squeak Takashi Yamamiya This material is based upon work supported in part by the National Science Foundation under Grant No. 0639876. Any opinions, findings, and conclusions
More informationIntroduction to Smalltalk
Introduction to Smalltalk Randal L. Schwartz, merlyn@stonehenge.com Version 1.01 on 20 July 2009 This document is copyright 2009 by Randal L. Schwartz, Stonehenge Consulting Services, Inc. This work is
More information:3002 Wilf 2017
95.3002 Name one thing that finds bugs early Making sure that the run or execute method for all tables that search have an error message at the end if the search fails to find anything. Readahead and ScannerReadahead
More informationIntro. Scheme Basics. scm> 5 5. scm>
Intro Let s take some time to talk about LISP. It stands for LISt Processing a way of coding using only lists! It sounds pretty radical, and it is. There are lots of cool things to know about LISP; if
More informationSelected Design Patterns
Selected Design Patterns Design Patterns are recurrent solutions to design problems They are pros and cons We already saw: Factory, Hook, Templates Singleton Composite «ChapterNr».1 Alert!!! Design Patterns
More informationInside Smalltalk MVC: Patterns for GUI Programming
Inside Smalltalk MVC: Patterns for GUI Programming Chien-Tsun Chen Department of Computer Science and Information Engineering National Taipei University of Technology, Taipei 106, Taiwan ctchen@ctchen.idv.tw
More informationRules and syntax for inheritance. The boring stuff
Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for
More informationCPS 506 Comparative Programming Languages. Programming Language
CPS 506 Comparative Programming Languages Object-Oriented Oriented Programming Language Paradigm Introduction Topics Object-Oriented Programming Design Issues for Object-Oriented Oriented Languages Support
More informationP2: Collaborations. CSE 335, Spring 2009
P2: Collaborations CSE 335, Spring 2009 Milestone #1 due by Thursday, March 19 at 11:59 p.m. Completed project due by Thursday, April 2 at 11:59 p.m. Objectives Develop an application with a graphical
More informationWeiss Chapter 1 terminology (parenthesized numbers are page numbers)
Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement
More informationOutline Smalltalk Overview Pragmatic Smalltalk Closing. Pragmatic Smalltalk. David Chisnall. February 7,
February 7, 2009 http://etoileos.com Outline Using The Smalltalk Family Smalltalk - first dynamic, object-oriented, language. Self - Smalltalk without classes. JavaScript - Self with Java syntax. A Quick
More information3. A Simple Counter. Creating your own class
In this exercise, you will write your first complete program. The program is very simple, the goal of the exercise is to get used to the Pharo environment and the basics of the language. From the Pharo
More informationForth Meets Smalltalk. A Presentation to SVFIG October 23, 2010 by Douglas B. Hoffman
Forth Meets Smalltalk A Presentation to SVFIG October 23, 2010 by Douglas B. Hoffman 1 CONTENTS WHY FMS? NEON HERITAGE SMALLTALK HERITAGE TERMINOLOGY EXAMPLE FMS SYNTAX ACCESSING OVERRIDDEN METHODS THE
More informationBeyond the Refactoring Browser: Advanced Tool Support for Software Refactoring
Beyond the Refactoring Browser: Advanced Tool Support for Software Refactoring Tom Mens Tom Tourwé Francisca Muñoz Programming Technology Lab Vrije Universiteit Brussel Pleinlaan 2, 1050 Brussel, Belgium
More informationWhy using Smalltalk for Teaching Object- Oriented Design
Why using Smalltalk for Teaching Object- Oriented Design N. Bouraqadi - Ecole des Mines de Douai S. Ducasse - University of Berne S. Stinckwich - University of Caen R. Wuyts - Université Libres de Bruxelles
More informationHow Developers Use the Dynamic Features of Programming Languages: The Case of Smalltalk
How Developers Use the Dynamic Features of Programming Languages: The Case of Smalltalk Oscar Callaú, Romain Robbes, Éric Tanter (University of Chile) David Röthlisberger (University of Bern) Proceedings
More informationDue: 9 February 2017 at 1159pm (2359, Pacific Standard Time)
CSE 11 Winter 2017 Program Assignment #2 (100 points) START EARLY! Due: 9 February 2017 at 1159pm (2359, Pacific Standard Time) PROGRAM #2: DoubleArray11 READ THE ENTIRE ASSIGNMENT BEFORE STARTING In lecture,
More informationA Fully Object-Oriented Exception Handling System: Rationale and Smalltalk Implementation
A Fully Object-Oriented Exception Handling System: Rationale and Smalltalk Implementation Christophe Dony Montpellier-II University - LIRMM Laboratory 161 rue ADA, 34392.Montpellier Cedex 05. dony@lirmm.fr
More informationgnu Smalltalk Library Reference
gnu Smalltalk Library Reference Version 3.2.5 24 November 2017 by Paolo Bonzini Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License,
More information2. The object-oriented paradigm!
2. The object-oriented paradigm! Plan for this section:! n Look at things we have to be able to do with a programming language! n Look at Java and how it is done there" Note: I will make a lot of use of
More informationSelf-review Questions
7Class Relationships 106 Chapter 7: Class Relationships Self-review Questions 7.1 How is association between classes implemented? An association between two classes is realized as a link between instance
More informationA Browser for Incremental Programming
A Browser for Incremental Programming Nathanael Schärli a, Andrew P. Black b a Software Composition Group, University of Bern, Switzerland b OGI School of Science & Engineering, Oregon Health & Science
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationCopyright 1997 by Alec Sharp PDF-Conversion by Lukas Renggli Download more free Smalltalk-Books at:
Copyright 1997 by Alec Sharp PDF-Conversion by Lukas Renggli Download more free Smalltalk-Books at: http://www.iam.unibe.ch/~ducasse/webpages/freebooks.html European Smalltalk Users Group: http://www.esug.org
More informationPrinciples of Programming Languages. Objective-C. Joris Kluivers
Principles of Programming Languages Objective-C Joris Kluivers joris.kluivers@gmail.com History... 3 NeXT... 3 Language Syntax... 4 Defining a new class... 4 Object identifiers... 5 Sending messages...
More informationLesson 10A OOP Fundamentals. By John B. Owen All rights reserved 2011, revised 2014
Lesson 10A OOP Fundamentals By John B. Owen All rights reserved 2011, revised 2014 Table of Contents Objectives Definition Pointers vs containers Object vs primitives Constructors Methods Object class
More informationINHERITANCE AND EXTENDING CLASSES
INHERITANCE AND EXTENDING CLASSES Java programmers often take advantage of a feature of object-oriented programming called inheritance, which allows programmers to make one class an extension of another
More informationCS558 Programming Languages Winter 2013 Lecture 8
OBJECT-ORIENTED PROGRAMMING CS558 Programming Languages Winter 2013 Lecture 8 Object-oriented programs are structured in terms of objects: collections of variables ( fields ) and functions ( methods ).
More informationObject Model. Object Oriented Programming Winter
Object Model Object Oriented Programming 236703 Winter 2014-5 Class Representation In Memory A class is an abstract entity, so why should it be represented in the runtime environment? Answer #1: Dynamic
More informationGraphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub
Lebanese University Faculty of Science Computer Science BS Degree Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub 2 Crash Course in JAVA Classes A Java
More informationInheritance (Chapter 7)
Inheritance (Chapter 7) Prof. Dr. Wolfgang Pree Department of Computer Science University of Salzburg cs.uni-salzburg.at Inheritance the soup of the day?! Inheritance combines three aspects: inheritance
More informationJava Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p.
Preface p. xix Java Fundamentals p. 1 The Origins of Java p. 2 How Java Relates to C and C++ p. 3 How Java Relates to C# p. 4 Java's Contribution to the Internet p. 5 Java Applets and Applications p. 5
More informationExceptions. CSE 142, Summer 2002 Computer Programming 1.
Exceptions CSE 142, Summer 2002 Computer Programming 1 http://www.cs.washington.edu/education/courses/142/02su/ 12-Aug-2002 cse142-19-exceptions 2002 University of Washington 1 Reading Readings and References»
More informationExceptions. Readings and References. Exceptions. Exceptional Conditions. Reading. CSE 142, Summer 2002 Computer Programming 1.
Readings and References Exceptions CSE 142, Summer 2002 Computer Programming 1 http://www.cs.washington.edu/education/courses/142/02su/ Reading» Chapter 18, An Introduction to Programming and Object Oriented
More informationExceptions and Continuations. Lecture #19: More Special Effects Exceptions and OOP. Approach II: Non-Standard Return. Approach I: Do Nothing
Lecture #19: More Special Effects Exceptions and OOP Test #2 in two weeks (14 April), in class. Autograder runs Sunday night sometime. Exceptions and Continuations Exception-handling in programming languages
More informationCSC207H: Software Design. Java + OOP. CSC207 Winter 2018
Java + OOP CSC207 Winter 2018 1 Why OOP? Modularity: code can be written and maintained separately, and easily passed around the system Information-hiding: internal representation hidden from the outside
More informationSome instance messages and methods
Some instance messages and methods x ^x y ^y movedx: dx Dy: dy x
More informationClasses and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Classes and Methods לאוניד ברנבוים המחלקה למדעי המחשב אוניברסיטת בן-גוריון 22 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented
More informationRunning Pharo on the GemStone VM. James Foster VP of Finance & Operations, GemTalk Systems LLC ESUG 2017 Maribor, Slovenia 4 September 2017
Running Pharo on the GemStone VM James Foster VP of Finance & Operations, GemTalk Systems LLC ESUG 2017 Maribor, Slovenia 4 September 2017 Agenda GemStone/S Introduction Replacing Base Class Libraries
More information1 Reflection and Metaprogramming in Smalltalk
Programming Language Design Matthias Springer, 15D54036 1 Abstract In this work, we present examples for metaprogramming using thiscontext and mixins and their implementation in Squeak/Pharo, both of which
More informationObjective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5
Objective Questions BCA Part III page 1 of 5 1. Java is purely object oriented and provides - a. Abstraction, inheritance b. Encapsulation, polymorphism c. Abstraction, polymorphism d. All of the above
More informationOutline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring
Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,
More informationUMBC CMSC 331 Final Exam
UMBC CMSC 331 Final Exam Name: UMBC Username: You have two hours to complete this closed book exam. We reserve the right to assign partial credit, and to deduct points for answers that are needlessly wordy
More informationLecture Contents CS313D: ADVANCED PROGRAMMING LANGUAGE. What is Inheritance?
CS313D: ADVANCED PROGRAMMING LANGUAGE Computer Science department Lecture 5: Inheritance & Polymorphism Lecture Contents 2 What is Inheritance? Super-class & sub class Protected members Creating subclasses
More informationClasses and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון
Classes and Methods גרא וייס המחלקה למדעי המחשב אוניברסיטת בן-גוריון 2 Roadmap Lectures 4 and 5 present two sides of OOP: Lecture 4 discusses the static, compile time representation of object-oriented
More informationChapter 1: Object-Oriented Programming Using C++
Chapter 1: Object-Oriented Programming Using C++ Objectives Looking ahead in this chapter, we ll consider: Abstract Data Types Encapsulation Inheritance Pointers Polymorphism Data Structures and Algorithms
More information2. The object-oriented paradigm
2. The object-oriented paradigm Plan for this section: Look at things we have to be able to do with a programming language Look at Java and how it is done there Note: I will make a lot of use of the fact
More informationDynamic Dispatch and Duck Typing. L25: Modern Compiler Design
Dynamic Dispatch and Duck Typing L25: Modern Compiler Design Late Binding Static dispatch (e.g. C function calls) are jumps to specific addresses Object-oriented languages decouple method name from method
More information