About Instance Initialization

Size: px
Start display at page:

Download "About Instance Initialization"

Transcription

1 Learning Object-Oriented Programming and Design with TDD About Instance Initialization Stéphane Ducasse W5S06

2 W5S06 2 / 26 How to ensure that an instance is well initialized? Possible solution Automatic initialize Lazy initialization Proposing the right interface Providing a default value

3 W5S06 3 / 26 Provider responsibility This is the responsibility of the class to provide well-formed objects A client should not make assumptions or been responsible to send specific sequence of messages to get a working object

4 A First Implementation of Packet W5S06 4 / 26 Object subclass: #Packet instancevariablenames: 'contents addressee originator ' Packet >> printon: astream super printon: astream. astream nextputall: ' addressed to: '; nextputall: self addressee. astream nextputall: ' with contents: '; nextputall: self contents Packet >> addressee ^ addressee Packet >> addressee: asymbol addressee := asymbol

5 Example of instance creation W5S06 5 / 26 Packet new addressee: #mac ; contents: 'hello mac'

6 Fragile Instance Creation W5S06 6 / 26 If we do not specify a contents, it breaks! p p := Packet new addressee: #mac. p printon: astream > error

7 W5S06 7 / 26 Problems Responsibility of the instance creation relies on the clients A client can create packet without contents, without address and the instance variables are not initialized correctly error (for example, printon:) Fragile system (printon: should be robust)

8 W5S06 8 / 26 Fragile Instance Creation Solutions Automatic initialization of instance variables Proposing a solid interface for the creation Lazy initialization Providing a default value

9 Assuring Instance Variable Initialization How to initialize a newly created instance? Define the method initialize Packet >> initialize super initialize. contents := ''. addressee := #noad Makes sure that contents and addressee have always a value W5S06 9 / 26

10 The New/Initialize Couple W5S06 10 / 26 Object >> initialize "do nothing. Called by new my subclasses override me if necessary" ^ self Acts as a constructor in other languages

11 W5S06 11 / 26 Lazy Initialization When some instance variables are: not used all the time consuming space, difficult to initialize because depending on other need a lot of computation Use lazy initialization based on accessors But accessor access should be used consistently!

12 W5S06 12 / 26 Lazy Initialization Example A lazy initialization scheme with default value Packet >> contents contents isnil iftrue: [ contents := 'no contents' ] ^ contents apacket contents or self contents A lazy initialization scheme with computed value Dummy >> ratio ratio isnil iftrue: [ ratio := self heavycomputation ]

13 Better W5S06 13 / 26 Packet >> contents contents isnil iftrue: [contents := 'no contents'] ^ contents is equivalent to Packet >> contents ^ contents ifnil: [ contents := 'no contents ]

14 W5S06 14 / 26 Strengthen instance creation interface Problem: A client can still create apacket without address. Solution: Force the client to use the class interface creation. Providing an interface for creation and avoiding the use of new: Packet send: Hello mac to: #Mac Packet class >> send: astring to: anaddress ^ self new contents: astring ; addressee: anaddress ; yourself

15 W5S06 15 / 26 Examples of instance initialization Step 1. SortedCollection sortblock: [:a :b a name < b name] SortedCollection class>>sortblock: ablock "Answer a new instance of SortedCollection such that its elements are sorted according to the criterion specified in ablock." ^ self new sortblock: ablock Step 2. self new => asortedcollection Step 3. asortedcollection sortblock: ablock

16 Another example W5S06 16 / 26 Step 1. OrderedCollection with: 1 Collection class >> with: anobject "Answer a new instance of a Collection containing anobject." newcollection newcollection := self new. newcollection add: anobject. ^ newcollection

17 Invoking per default the creation interface W5S06 17 / 26 OrderedCollection class >> new "Answer a new empty instance of OrderedCollection." ^ self new: 5

18 W5S06 18 / 26 Forbidding new? Problem: We can still use new to create fragile instances Solution: new should raise an error! Packet class >> new self error: 'Packet should only be created using send:to:'

19 W5S06 19 / 26 Forbidding new implications But we still have to be able to create instance! Packet class >> send: astring to: anaddres ^ self new contents: astring ; addressee: anaddress raises an error Packet class >> send: astring to: anaddress ^ super new contents: astring ; addressee: anaddress

20 W5S06 20 / 26 Forbidding new Solution: use basicnew and basicnew: Packet class >> send: astring to: anaddress ^ self basicnew contents: astring ; addressee: anaddress Conclusion: Do not override basic* methods else you will not be able to invoke them later

21 W5S06 21 / 26 Fluid vs. and default creation interface Often a fixed creation interface gets too large Too many possibilities Too many optional cases

22 Example: Problem with class definition in Pharo W5S06 22 / 26 Object subclass: #Behavior uses: TBehavior instancevariablenames: 'superclass methoddict format layout' classvariablenames: 'ClassProperties ObsoleteSubclasses' package: 'Kernel Classes'

23 Example: Problem with class definition in Pharo W5S06 23 / 26 subclass: s uses: at instancevariablenames: names classvariablenames: cvnames category: cat subclass: s uses: at instancevariablenames: names classvariablenames: cvnames package: cat subclass: s instancevariablenames: names classvariablenames: cvnames pooldictionaries: pools package: cat subclass: s uses: at instancevariablenames: names classvariablenames: cvnames pooldictionaries: pools category: acat......tag:......immediate:......ephemeron:...

24 Example of a fluid interface in Seaside W5S06 24 / 26 ScrapBook>>renderContentOn: html html paragraph: 'A plain text paragraph.'. html paragraph: [ html render: 'A paragraph with plain text followed by a line break.'. html break. html emphasis: 'Emphasized text '. html render: 'followed by a horizontal rule.'. html horizontalrule. html render: 'An image: '. html image url: ' plain.png' ]

25 W5S06 25 / 26 How to ensure that an instance is well initialized? Automatic initialize Lazy initialization Proposing the right interface Providing a default value

26 A course by Stéphane Ducasse Reusing some parts of the Pharo Mooc by Damien Cassou, Stéphane Ducasse, Luc Fabresse Except where otherwise noted, this work is licensed under CC BY-NC-ND 3.0 France

Use vs. Inheritance. Learning Object-Oriented Programming and Design with TDD. Stéphane Ducasse.

Use vs. Inheritance. Learning Object-Oriented Programming and Design with TDD. Stéphane Ducasse. Learning Object-Oriented Programming and Design with TDD Use vs. Inheritance Stéphane Ducasse http://stephane.ducasse.free.fr http://www.pharo.org W6S06 W6S06 2 / 20 Outline An exercise Some criteria Solutions

More information

Seaside: An Innovative Web Application Framework

Seaside: An Innovative Web Application Framework Seaside: An Innovative Web Application Framework Damien Cassou, Stéphane Ducasse and Luc Fabresse W4S08 http://www.pharo.org W4S08 2 / 24 Seaside A powerful, innovative and flexible framework Dedicated

More information

An Overview of Essential Collections

An Overview of Essential Collections Learning Object-Oriented Programming and Design with TDD An Overview of Essential Collections Stéphane Ducasse http://stephane.ducasse.free.fr http://www.pharo.org W2S08 W2S08 2 / 32 What You Will Learn

More information

Voyage. NoSQL Object Database. Damien Cassou, Stéphane Ducasse and Luc Fabresse. W4S11

Voyage. NoSQL Object Database. Damien Cassou, Stéphane Ducasse and Luc Fabresse.  W4S11 Voyage NoSQL Object Database Damien Cassou, Stéphane Ducasse and Luc Fabresse W4S11 http://www.pharo.org W4S11 2 / 27 Goal To let you build a real little application Show you a nice way to store objects

More information

About Double Dispatch

About Double Dispatch Learning Object-Oriented Programming and Design with TDD About Double Dispatch Stéphane Ducasse http://stephane.ducasse.free.fr http://www.pharo.org W8S02 W8S02 2 / 31 Outline Some fun exercises Thinking

More information

An Overview of Essential Collections

An Overview of Essential Collections An Overview of Essential Collections Damien Cassou, Stéphane Ducasse and Luc Fabresse W3S07 http://www.pharo.org W3S07 2 / 31 What You Will Learn Some basic collections Essential API to program collections

More information

Pharo Syntax in a Nutshell

Pharo 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 information

Learning From Real Examples

Learning From Real Examples Learning Object-Oriented Programming and Design with TDD Learning From Real Examples Stéphane Ducasse http://stephane.ducasse.free.fr http://www.pharo.org W7S05 W7S05 2 / 21 What You Will Learn Thinking

More information

Iterators. Damien Cassou, Stéphane Ducasse and Luc Fabresse. W3S09

Iterators. Damien Cassou, Stéphane Ducasse and Luc Fabresse.   W3S09 Iterators Damien Cassou, Stéphane Ducasse and Luc Fabresse W3S09 http://www.pharo.org W3S09 2 / 24 What You Will Learn Understand the power of iterators Offer an overview of iterators W3S09 3 / 24 Pharo

More information

3. A Simple Counter. Creating your own class

3. 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 information

Squeak Object Model. Technion - Israel Institute of Technology. Updated: Spring Object-Oriented Programming 1

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 information

Powerful Exceptions: an Overview

Powerful Exceptions: an Overview Powerful Exceptions: an Overview Damien Cassou, Stéphane Ducasse and Luc Fabresse W5S04 http://www.pharo.org W5S04 2 / 21 Exceptions Really powerful Can be resumed, restarted, and signaled as new exception

More information

9. Understanding Classes and Metaclasses

9. 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 information

2. Classes & Inheritance. Classes. Classes. Éric Tanter Objects and Design in Smalltalk. How do you create objects?

2. 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 information

A Lazy List Implementation in Squeak

A 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 information

Syntax and Messages. Stéphane Ducasse 8.1

Syntax 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 information

ST Introduction. Birds-eye view

ST 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 information

A simple reflective object kernel

A simple reflective object kernel A simple reflective object kernel S. Ducasse The Pharo Booklet Collection edited by S. Ducasse November 20, 2017 master @ d4e4b4f* Copyright 2017 by S. Ducasse. The contents of this book are protected

More information

TinyBlog: presentation and model

TinyBlog: presentation and model C H A P T E R 1 TinyBlog: presentation and model In this project, we will guide you to develop a mini project: a small web application, named TinyBlog, that manages a blog system (see its final state in

More information

Uniform and Safe Metaclass Composition

Uniform and Safe Metaclass Composition Uniform and Safe Metaclass Composition Stéphane Ducasse a Nathanael Schärli a Roel Wuyts b a Software Composition Group, IAM-Universität Bern, Switzerland b Decomp Laboratory, Université Libre de Bruxelles,

More information

To install Glamour on your Pharo image execute the following code:

To install Glamour on your Pharo image execute the following code: Glamour Chapter 1 Glamour with the participation of: Tudor Girba (tudor@tudorgirba.com) Browsers are a crucial instrument in understanding complex systems or models. A browser is a tool to navigate and

More information

ST Introduction. Birds-eye view

ST 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 information

In this chapter we enhance the Los Boquitas application with a new component showing upcoming events in a table.

In this chapter we enhance the Los Boquitas application with a new component showing upcoming events in a table. In this chapter we enhance the Los Boquitas application with a new component showing upcoming events in a table. 1. First, we need to have some events to display. a. We will start by defining an event

More information

Basic Objects, Conditionals and Loops

Basic 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 information

5-Sep-16 Copyright 2016 by GemTalk Systems LLC 1

5-Sep-16 Copyright 2016 by GemTalk Systems LLC 1 In this chapter we use the Flight Information application to learn about continuations, an often-cited but poorly understood feature of many Smalltalk dialects that allows Seaside applications to use subroutine

More information

Smalltalk FOOP. Smalltalk

Smalltalk 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 information

The Smalltalk class hierarchy

The 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 information

Template Method Structure. Template Method Example. Template Method Example. Template Method Example. Benefits of Template Method

Template 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 information

Programming with Seaside

Programming with Seaside Programming with Seaside Alexandre.Bergel@cs.tcd.ie LERO & DSG Trinity College Dublin, Ireland 1 Part I: Seaside in a Nutshell Outline 1. What is Seaside? 2. Starting Seaside 3. Create new Seaside Component

More information

Selected Design Patterns

Selected 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 information

This chapter describes some of the more common errors that Smalltalk programmers make and gives suggestions on how to prevent the errors.

This 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 information

6. Exemplary Solutions: Seaside: Components

6. Exemplary Solutions: Seaside: Components 6. Exemplary Solutions: Seaside: Components Exercise 6.1 STBuyTicketTask class >> canberoot ˆtrue self inform: Hello World Exercise 6.2 WAComponent subclass: #STPlayChooser instancevariablenames: plays

More information

Guru 101 Grokking the Smalltalk system. Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group

Guru 101 Grokking the Smalltalk system. Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group Guru 101 Grokking the Smalltalk system Smalltalk Solutions Europe 1998 Joseph Pelrine Daedalos Consulting Group jpelrine@daedalos.de About this talk 10:00-12:00 AM Coffee break Beer afterwards Intermediate

More information

Object-Oriented Design with Smalltalk A Pure Object Language and its Environment

Object-Oriented Design with Smalltalk A Pure Object Language and its Environment Object-Oriented Design with Smalltalk A Pure Object Language and its Environment Dr. Stéphane Ducasse 2002 Table of Contents 2. Table of Contents 2 1. Introduction 6 Structure of this Lecture 7 Structure

More information

Object-Oriented Design with Smalltalk a Pure Object Language and its Environment

Object-Oriented Design with Smalltalk a Pure Object Language and its Environment Object-Oriented Design with Smalltalk a Pure Object Language and its Environment Dr. Stéphane Ducasse ducasse@iam.unibe.ch http://www.iam.unibe.ch/~ducasse/ University of Bern 2000/2001 Table of Contents

More information

Smalltalk Best Practice Patterns. Part I

Smalltalk 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 information

Lord of the Base Image - Things every Library Supervisor should know

Lord 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 information

Smalltalk. 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. 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 information

Safe Metaclass Composition Using Mixin-Based Inheritance

Safe Metaclass Composition Using Mixin-Based Inheritance Safe Metaclass Composition Using Mixin-Based Inheritance Noury Bouraqadi bouraqadi@ensm-douai.fr http://csl.ensm-douai.fr/noury Dépt. G.I.P. - Ecole des Mines de Douai 941, rue Charles Bourseul - B.P.

More information

OO Design with Smalltalk a Pure Object Oriented Language and Environment

OO 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 information

Syntax and Messages. Stéphane Ducasse S.Ducasse

Syntax and Messages. Stéphane Ducasse   S.Ducasse Syntax and Messages Stéphane Ducasse Stephane.Ducasse@univ-savoie.fr http://www.listic.univ-savoie.fr/~ducasse/ 1 License: CC-Attribution-ShareAlike 2.0 http://creativecommons.org/licenses/by-sa/2.0/ 2

More information

XXXXXXXXXXXXXXXXXXXXXXX. Evolution of Software Languages

XXXXXXXXXXXXXXXXXXXXXXX. 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 information

Voyage: Persisting Objects in Document Databases

Voyage: Persisting Objects in Document Databases Voyage: Persisting Objects in Document Databases Esteban Lorenzano, Stéphane Ducasse, Johan Fabry and Norbert Hartl May 14, 2017 master @ 5e82534 Copyright 2015 by Esteban Lorenzano, Stéphane Ducasse,

More information

Efficient Proxies in Smalltalk

Efficient 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 information

Patterns Continued and Concluded. July 26, 2017

Patterns Continued and Concluded. July 26, 2017 Patterns Continued and Concluded July 26, 2017 Review Quiz What is the purpose of the Singleton pattern? A. To advertise to other developers that the object should only be modified by `main()` B.To prevent

More information

From Design to Implementation

From 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 information

Introduction to Smalltalk

Introduction 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

Call Stack Management

Call Stack Management Call Stack Management Clément Béra with Stéphane Ducasse Square Bracket tutorials January 23, 2018 master @ 9343841* Copyright 2017 by Clément Béra with Stéphane Ducasse. The contents of this book are

More information

Introduction to Seaside

Introduction to Seaside Introduction to Seaside Randal L. Schwartz, merlyn@stonehenge.com Version 2.01 on 20 July 2009 This document is copyright 2008, 2009 by Randal L. Schwartz, Stonehenge Consulting Services, Inc. This work

More information

Reflective Programming and Open Implementations. Dr. Stéphane Ducasse

Reflective Programming and Open Implementations. Dr. Stéphane Ducasse Reflective Programming and Open Implementations Dr. Stéphane Ducasse ducasse@iam.unibe.ch http://www.iam.unibe.ch/~ducasse/ University of Bern 2000/2001 1. Reflective Programming and Open Implementations

More information

CS 403/503 Exam 4 Spring 2017 Name

CS 403/503 Exam 4 Spring 2017 Name CS 403/503 Exam 4 Spring 2017 Name CS 403 Score is based on your best 8 out of 10 problems. CS 503 Score is based on your best 9 out of 10 problems. Extra credit will be awarded if you can solve additional

More information

:3002 Wilf 2017

: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 information

An Introduction to Squeak

An Introduction to Squeak An Introduction to Squeak Hello! Squeak is a language largely derived from Smalltalk. Now imagine what a coincidence it is to be do an assignment that uses the Smalltalk language after having just finished

More information

Flexible Dynamic Ownership in Smalltalk

Flexible Dynamic Ownership in Smalltalk Flexible Dynamic Ownership in Smalltalk Bachelorarbeit der Philosophisch-naturwissenschaftlichen Fakultät der Universität Bern vorgelegt von Pascal Maerki 21.02.2013 Leiter der Arbeit: Prof. Dr. Oscar

More information

Test-Driven Development (TDD)

Test-Driven Development (TDD) Test-Driven Development (TDD) CS 4501 / 6501 Software Testing [Lasse Koskela, Test Driven, Chapters 2-3] 1 Agile Airplane Testing Test harness: Appearance matches Color coding in place Fly 6ft (or 2m)

More information

esug.org (European Smalltalker Users Group) Javascript

esug.org (European Smalltalker Users Group) Javascript Serge Amber Pharo ( ) esug.org (European Smalltalker Users Group) Amber Web Smalltalk Web Smtalltalk Javascript Javascript Web Transcript Workspace SUnit (JUnit Smalltalk ) System Browser halt JQuery UI

More information

Object. Accessing. Changing. Chapter

Object. 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 information

Refactorings. Refactoring. Refactoring Strategy. Demonstration: Refactoring and Reverse Engineering. Conclusion

Refactorings. 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 information

ECE 122. Engineering Problem Solving with Java

ECE 122. Engineering Problem Solving with Java ECE 122 Engineering Problem Solving with Java Lecture 17 Inheritance Overview Problem: Can we create bigger classes from smaller ones without having to repeat information? Subclasses: a class inherits

More information

Software Evolution from the Field: An Experience Report from the Squeak Maintainers

Software Evolution from the Field: An Experience Report from the Squeak Maintainers Software Evolution from the Field: An Experience Report from the Squeak Maintainers Marcus Denker SCG University of Berne Switzerland Stéphane Ducasse LISTIC Université de Savoie France Roadmap > A little

More information

Improving the implementation of traits in Pharo

Improving the implementation of traits in Pharo Improving the implementation of traits in Pharo Sebastián Tleye To cite this version: Sebastián Tleye. Improving the implementation of traits in Pharo. Programming Languages [cs.pl]. 2013.

More information

University of Berne Institute of Computer Science

University 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 information

Ghost: A Uniform and General-Purpose Proxy Implementation

Ghost: 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 information

EMBEDDED SYSTEMS PROGRAMMING OO Basics

EMBEDDED SYSTEMS PROGRAMMING OO Basics EMBEDDED SYSTEMS PROGRAMMING 2014-15 OO Basics CLASS, METHOD, OBJECT... Class: abstract description of a concept Object: concrete realization of a concept. An object is an instance of a class Members Method:

More information

Enabling Software Analysis using PetitParser and Moose

Enabling Software Analysis using PetitParser and Moose 1 Enabling Software Analysis using PetitParser and Moose Michael Rüfenacht Software Composition Group University of Bern, Switzerland m.ruefenacht@students.unibe.ch http://scg.unibe.ch Abstract Static

More information

The Smalltalk Environment, SUnit, and Inheritance

The 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 information

Java Object Oriented Design. CSC207 Fall 2014

Java Object Oriented Design. CSC207 Fall 2014 Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code

More information

Learning Object-Oriented Programming, Design and TDD with Pharo

Learning Object-Oriented Programming, Design and TDD with Pharo Learning Object-Oriented Programming, Design and TDD with Pharo Stéphane Ducasse with Damien Pollet September 29, 2017 master @ 86ac50a 2017 by Stéphane Ducasse with Damien Pollet. This work is licensed

More information

Sapphire Scripting Smalltalk

Sapphire Scripting Smalltalk Bachelor Project Scripting Smalltalk Daniele Sciascia supervised by Prof. Dr. Laura Pozzi Prof. Dr. Michele Lanza Paolo Bonzini Abstract GNU Smalltalk is an open source project whose goal is to create

More information

Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic.

Goals of design. satisfies problem requirements, usable error free, resistant to incorrect input. readable, not purposefully cryptic. OOP design revisited design revisited 1 Goals of design usable software robust implementable understandable reusable generalizable extendable solves the problem, satisfies problem requirements, usable

More information

Chapter 2: Java OO II X I A N G Z H A N G

Chapter 2: Java OO II X I A N G Z H A N G Chapter 2: Java OO II X I A N G Z H A N G j a v a c o s e @ q q. c o m Content 2 Abstraction Abstract Class Interface Inheritance Polymorphism Abstraction What is Abstraction? Abstraction 4 An abstraction

More information

Pillar: A Versatile and Extensible Lightweight Markup Language

Pillar: A Versatile and Extensible Lightweight Markup Language Pillar: A Versatile and Extensible Lightweight Markup Language Thibault Arloing Yann Dubois Damien Cassou Stéphane Ducasse thibault.arloing@etudiant.univ-lille1.fr yann1.dubois@etudiant.univ-lille1.fr

More information

fohgp siejt karbl mcqdn

fohgp siejt karbl mcqdn CS 403/503 Exam 4 Spring 2017 Solution CS 403 Score is based on your best 8 out of 10 problems. CS 503 Score is based on your best 9 out of 10 problems. Extra credit will be awarded if you can solve additional

More information

Efficient Support for Mixin-Based Inheritance Using Metaclasses

Efficient Support for Mixin-Based Inheritance Using Metaclasses ubmission to the Workshop on Reflectively Extensible Programming Languages and ytems (REPL) at the International Conference on Generative Programming and Component Engineering (GPCE 03) eptember 22 nd,

More information

CHAIN OF RESPONSIBILITY (DP 223)

CHAIN 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 information

Author manuscript, published in "Proceedings of ESUG International Workshop on Smalltalk Technologies (IWST 2012) (2012)" Spec

Author manuscript, published in Proceedings of ESUG International Workshop on Smalltalk Technologies (IWST 2012) (2012) Spec Author manuscript, published in "Proceedings of ESUG International Workshop on Smalltalk Technologies (IWST 2012) (2012)" Spec A Framework for the Specification and Reuse of UIs and their Models Benjamin

More information

Working with Bytecodes: IRBuilder and InstructionStream. Marcus Denker. Reasons for working with Bytecode

Working 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 information

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017

Programming Language Concepts Object-Oriented Programming. Janyl Jumadinova 28 February, 2017 Programming Language Concepts Object-Oriented Programming Janyl Jumadinova 28 February, 2017 Three Properties of Object-Oriented Languages: Encapsulation Inheritance Dynamic method binding (polymorphism)

More information

CS410/510 Advanced Programming Lecture 5: Collections in Smalltalk Hamming s Problem Revisited

CS410/510 Advanced Programming Lecture 5: Collections in Smalltalk Hamming s Problem Revisited CS410/510 Advanced Programming Lecture 5: Collections in Smalltalk Hamming s Problem Revisited 1 List Operations Last week you heard about list operations in Haskell For each there is a corresponding operation

More information

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107

Index. Index. More information. block statements 66 y 107 Boolean 107 break 55, 68 built-in types 107 A abbreviations 17 abstract class 105 abstract data types 105 abstract method 105 abstract types 105 abstraction 92, 105 access level 37 package 114 private 115 protected 115 public 115 accessors 24, 105

More information

Powerful DSL engineering with Smalltalk

Powerful DSL engineering with Smalltalk Powerful DSL engineering with Smalltalk Stéphane Ducasse stephane.ducasse@inria.fr http://stephane.ducasse.free.fr/ Stéphane Ducasse 1 A word of introduction Reflective, metamodeler and happy programmer

More information

Pharo s Tips and Tricks

Pharo s Tips and Tricks Pharo s Tips and Tricks Stéphane Ducasse Square Bracket tutorials October 28, 2017 master @ d69dc78* Copyright 2017 by Stéphane Ducasse. The contents of this book are protected under the Creative Commons

More information

Object Model. Object Oriented Programming Spring 2015

Object 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 information

2. Smalltalk a reflective language. Oscar Nierstrasz

2. Smalltalk a reflective language. Oscar Nierstrasz 2. Smalltalk a reflective language Oscar Nierstrasz Birds-eye view Smalltalk is still today one of the few fully reflective, fully dynamic, objectoriented development environments. We will see how a simple,

More information

Seaside Web Application Toolkit for Squeak

Seaside Web Application Toolkit for Squeak Web Application Toolkit for Squeak Sheet #1 Introduction About us Lukas Renggli Adrian Lienhard users of the framework Developers Avi Bryant Julian Fitzell Sheet #2 Content What can be done with? Example

More information

Zero Configuration Scripts and Command-Line Handlers

Zero Configuration Scripts and Command-Line Handlers Zero Configuration Scripts and Command-Line Handlers Chapter 1 Zero Configuration Scripts and Command-Line Handlers with the participation of: Camillo Bruni (camillobruni@gmail.com) Weren t you fed up

More information

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance

Object Oriented Features. Inheritance. Inheritance. CS257 Computer Science I Kevin Sahr, PhD. Lecture 10: Inheritance CS257 Computer Science I Kevin Sahr, PhD Lecture 10: Inheritance 1 Object Oriented Features For a programming language to be called object oriented it should support the following features: 1. objects:

More information

gnu Smalltalk Library Reference

gnu 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 information

Java for Non Majors Spring 2018

Java for Non Majors Spring 2018 Java for Non Majors Spring 2018 Final Study Guide The test consists of 1. Multiple choice questions - 15 x 2 = 30 points 2. Given code, find the output - 3 x 5 = 15 points 3. Short answer questions - 3

More information

Pillar: A Versatile and Extensible Lightweight Markup Language

Pillar: A Versatile and Extensible Lightweight Markup Language Pillar: A Versatile and Extensible Lightweight Markup Language Thibault Arloing, Yann Dubois, Damien Cassou, Stéphane Ducasse To cite this version: Thibault Arloing, Yann Dubois, Damien Cassou, Stéphane

More information

A Browser for Incremental Programming

A Browser for Incremental Programming A Browser for Incremental Programming Nathanael Schärli and Andrew P. Black Department of Computer Science and Engineering OGI School of Science & Engineering Oregon Health & Science University 20000 NW

More information

Metaprogramming and Reflection Refactoring

Metaprogramming and Reflection Refactoring Metaprogramming and Reflection Refactoring Universität Bern Marcus Denker Hasso-Plattner-Institut Potsdam Software Architecture Group Prof. Dr. Robert Hirschfeld http://www.swa.hpi.uni-potsdam.de WS 2006/2007

More information

Read-Only Execution for Dynamic Languages

Read-Only Execution for Dynamic Languages Read-Only Execution for Dynamic Languages Jean-Baptiste Arnaud 1, Marcus Denker 1, Stéphane Ducasse 1, Damien Pollet 1, Alexandre Bergel 2, and Mathieu Suen 1 INRIA Lille Nord Europe - CNRS UMR 8022 -

More information

Spec: A Framework for the Specification and Reuse of UIs and their Models

Spec: A Framework for the Specification and Reuse of UIs and their Models Spec: A Framework for the Specification and Reuse of UIs and their Models Benjamin Van Ryseghem, Stéphane Ducasse, Johan Fabry To cite this version: Benjamin Van Ryseghem, Stéphane Ducasse, Johan Fabry.

More information

Squeak Smalltalk: Classes Reference

Squeak Smalltalk: Classes Reference Squeak Smalltalk: Classes Reference Version 0.0, 20 November 1999, by Andrew C. Greenberg, werdna@mucow.com Version 1.2, 26 April 2001, by Andrew P. Black, black@cse.ogi.edu Based on: Smalltalk-80: The

More information

Comp-304 : Object-Oriented Design What does it mean to be Object Oriented?

Comp-304 : Object-Oriented Design What does it mean to be Object Oriented? Comp-304 : Object-Oriented Design What does it mean to be Object Oriented? What does it mean to be OO? What are the characteristics of Object Oriented programs (later: OO design)? What does Object Oriented

More information

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1

STEAM Clown & Productions Copyright 2017 STEAM Clown. Page 1 What to add next time you are updating these slides Update slides to have more animation in the bullet lists Verify that each slide has stand alone speaker notes Page 1 Python 3 Running The Python Interpreter

More information

APIEvolutionMiner: Keeping API Evolution under Control

APIEvolutionMiner: Keeping API Evolution under Control APIEvolutionMiner: Keeping API Evolution under Control André Hora, Anne Etien, Nicolas Anquetil, Stéphane Ducasse, Marco Tulio Valente RMoD team, Inria, Lille, France Email: firstname.lastname@inria.fr

More information

Programming II (CS300)

Programming II (CS300) 1 Programming II (CS300) Chapter 05: Inheritance and Interfaces MOUNA KACEM mouna@cs.wisc.edu Fall 2018 Inheritance and Interfaces 2 Introduction Inheritance and Class Hierarchy Polymorphism Abstract Classes

More information

2. The object-oriented paradigm!

2. 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 information