Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz Summer Semester 2006.

Slides:



Advertisements
Similar presentations
Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz.
Advertisements

Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz.
Object Oriented Programming Chapter 7 Programming Languages by Ravi Sethi.
Road Map Introduction to object oriented programming. Classes
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
13. A bit of Smalltalk. © Oscar Nierstrasz 2 Roadmap  The origins of Smalltalk  What is Smalltalk?  Syntax in a nutshell  Seaside — web development.
Copyright W. Howden1 Lecture 15: Generalization, Polymorphism and States.
Chapter 10 Classes Continued
Object-oriented programming and design 1 Smalltalk in a Nutshell Objects & classes Messages & methods Inheritance & metaclasses.
1 Advanced Abstraction Mechanisms  Mixins  Traits  Delegation.
Inheritance and Polymorphism CS351 – Programming Paradigms.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
3/15/05H-1 © 2001 T. Horton CS 494 Object-Oriented Analysis & Design Evaluating Class Diagrams Topics include: Cohesion, Coupling Law of Demeter (handout)
Introduction to Ruby CSE 413 Autumn 2008 Credit: Dan Grossman, CSE341.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
OOP and Dynamic Method Binding Chapter 9. Object Oriented Programming Skipping most of this chapter Focus on 9.4, Dynamic method binding – Polymorphism.
Objective-C1 CS151 Presentation: Objective C Kai Tai Pang William Sze.
Instructor: Tasneem Darwish1 University of Palestine Faculty of Applied Engineering and Urban Planning Software Engineering Department Object Oriented.
Java Objects and Classes. Overview n Creating objects that belong to the classes in the standard Java library n Creating your own classes.
L11-12: Design Patterns Definition Iterator (L4: Inheritance)‏ Factory (L4: Inheritance)‏ Strategy (L5: Multiple Inheritance)‏ Composite (L6: Implementation.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
Chapter 12 Support for Object oriented Programming.
Objects & Dynamic Dispatch CSE 413 Autumn Plan We’ve learned a great deal about functional and object-oriented programming Now,  Look at semantics.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Patterns in programming1. 2 What are patterns? Answers to common design problems. A language used by developers –To discuss answers to design problems.
Object Oriented Software Development
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
(1) ICS 313: Programming Language Theory Chapter 12: Object Oriented Programming.
M1G Introduction to Programming 2 5. Completing the program.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Object Oriented Programming
Testing OO software. State Based Testing State machine: implementation-independent specification (model) of the dynamic behaviour of the system State:
Copyright © 2005 Elsevier Object-Oriented Programming Control or PROCESS abstraction is a very old idea (subroutines!), though few languages provide it.
Session 6 Comments on Lab 3 & Implications of Inheritance.
(1) ICS 313: Programming Language Theory Chapter 11: Abstract Data Types (Data Abstraction)
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
FEN 2014UCN Teknologi/act2learn1 Object-Oriented Programming “ The Three Pillars of OOP”: Encapsulation Inheritance Polymorphism The Substitution Principle.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
C# Fundamentals An Introduction. Before we begin How to get started writing C# – Quick tour of the dev. Environment – The current C# version is 5.0 –
ISBN Chapter 12 Support for Object-Oriented Programming.
Notices Assn 2 is due tomorrow, 7pm. Moodle quiz next week – written in the lab as before. Everything up to and including today’s lecture: Big Topics are.
Object Oriented Programming in Java Habib Rostami Lecture 2.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
1 Case Study: Meta Classes  Class representation in memory  Class variables and class methods  Meta Classes  3 Level System  4 Level System  5 Level.
Smalltalk Meta-Programming Programming Languages HUJI 2010 Yardena Meymann.
Object-Oriented Programming
Sections Inheritance and Abstract Classes
Multi-Methods in Cecil
Inheritance and Polymorphism
Object-Orientated Programming
Types of Programming Languages
Java Programming Language
Object-Oriented Programming
CSE 3302 Programming Languages
Refactoring.
Presentation transcript:

Dynamic Object-Oriented Programming with Smalltalk 1. Introduction Prof. O. Nierstrasz Summer Semester 2006

© Oscar Nierstrasz ST — xxx X.2 What you should know!  How does Smalltalk differ from Java or C++?  Where are Smalltalk programs stored?  Where are objects stored?  What was the Dynabook?  Is a class an object?  What is dynamic binding?  What is the difference between a message and a method?

© Oscar Nierstrasz ST — xxx X.3 Can you answer these questions?  What ideas did Smalltalk take from Simula? From Lisp?  Is there anything in Smalltalk which is not an object?  What exactly is stored in the changes file?  If objects have private state, then how can an Inspector get at that state?  How do you create a new class?  What is the root of the class hierarchy?  If a class is an object, then what is its class?The class of its class? …  If you don’t know, how would you find out?

2. Smalltalk Basics

© Oscar Nierstrasz ST — xxx X.5 What you should know!  How can you indicate that a method is “private”?  What is the difference between a comment and a string?  Why does 1+2*3 = 9?  What is a cascade?  How is a block like a lambda expression?  How do you create a new class?  How do you inspect an object?

© Oscar Nierstrasz ST — xxx X.6 Can you answer these questions?  Why does Smalltalk support single (and not multiple) inheritance?  Is the cascade strictly necessary?  Why do you need to declare local variables if there are no static types?  How can you discover the class of GUI object?  How does SUnit differ from JUnit?

3. Standard Classes

© Oscar Nierstrasz ST — xxx X.8 What you should know!  How are abstract classes defined in Smalltalk?  What’s the difference between a String and a Symbol?  Where are class names stored?  What is the difference between self and super?  Why do we need Blocks?  How is a Block like a lambda?  How would you implement Boolean>>and:?  What does inject:into: do?

© Oscar Nierstrasz ST — xxx X.9 Can you answer these questions?  How are Numbers represented internally?  Is it an error to instantiate an abstract class in Smalltalk?  Why isn’t the assignment operator considered to be a message?  What happens if you send the message #new to Boolean? To True or False?  Is nil an object? If so, what is its class?  Why does ArrayedCollection>>add: send itself the message shouldNotImplement?

4. Smalltalk Coding Idioms

© Oscar Nierstrasz ST — xxx X.11 What you should know!  What does yourself return? Why is it needed?  How is a new instance of a class initialized?  When should you implement invariants and preconditions?  What happens when we evaluate an expression with “print it”?  Why should a method never send super a different message?  How is super static and self dynamic?  How do you make your code self-documenting?

© Oscar Nierstrasz ST — xxx X.12 Can you answer these questions?  When should you override new?  If instance variables are really private, why can we see them with an inspector?  When does self = super?  When does super = self?  Which classes implement assert: ?  What does self refer to in the method SnakesAndLadders class>>example?

5. Seaside Lukas Renggli will give the lecture In 2006 — this version will not be used

6. Debugging

© Oscar Nierstrasz ST — xxx X.15 What you should know!  When should you explicitly return self?  Why shouldn’t you redefine methods named basic*?  Why are blocks not full closures?  How do you provide access to instance variables that are collections, without breaking encapsulation?  What is one of the most important uses of super?  How does programming with Smalltalk differ from programming in a conventional static language?

© Oscar Nierstrasz ST — xxx X.16 Can you answer these questions?  What will happen if you redefine the method class?  When should you define accessors for instance variables?  How can explicit references to class names make your application fragile?  Where is the method halt defined?

7. Understanding Classes and Metaclasses

© Oscar Nierstrasz ST — xxx X.18 What you should know!  What does is-a mean?  What is the difference between sending a message to an object and to its class?  What are the responsibilities of a metaclass?  What is the superclass of Object class?  Where is new defined?  What is the difference between class variables and class instance variables?

© Oscar Nierstrasz ST — xxx X.19 Can you answer these questions?  Why are there no explicit metaclasses?  When should you override new?  Why don’t metaclasses inherit from Class?  Are there any classes that don’t inherit from Object?  Is Metaclass a Class? Why or why not?  Where are the methods class and superclass defined?  When should you define an indexed class?  Are Java static variables just like class variables or class instance variables?  Where is the SystemDictionary Smalltalk defined?

8. Best Practice Patterns

© Oscar Nierstrasz ST — xxx X.21 What you should know!  How should you name instance variables?  Why should you be suspicious of comments?  How does Simple Delegation differ from Self Delegation?  When would you use Double Dispatch?  Why should you avoid introducing a Converter Method for an object supporting a different protocol?  How do you sort a Collection?  When should you use Lazy Initialization?

© Oscar Nierstrasz ST — xxx X.22 Can you answer these questions?  Which patterns would you use to implement a transactional interface?  How can Method Object help you to decompose long methods?  Why is it a bad idea to query an object for its class?  Why are you less likely to see Double Dispatch in a statically-typed language?  How can you avoid Modifying Super?  How can you avoid writing case statements?  What pattern does Object>>-> illustrate?

9. Refactoring and Design Patterns

© Oscar Nierstrasz ST — xxx X.24 What you should know!  How does the Open-Closed Principle apply to OOP?  What are signs that an object has clearly-defined responsibilities?  How can you recognize misplaced methods?  How should you refactor long methods?  How can you eliminate duplicated code between unrelated classes?  Why are type tests a code smell?  When do design patterns themselves turn into code smells?  Why is it a bad idea to use global variables to store Singleton instances?

© Oscar Nierstrasz ST — xxx X.25 Can you answer these questions?  How do the Common Closure and Common Reuse Principles alter the usual notion of cohesion?  How does refactoring differ from reengineering?  Can refactoring be fully automated?  In what situations does the Law of Demeter not apply?  How do design patterns make use of delegation?  Why are Long Parameter Lists a code smell?  Are isNil tests a code smell? What design pattern could help you eliminate them?  Is the Smalltalk SystemDictionary a good example of a Singleton?

10. Reflection

© Oscar Nierstrasz ST — xxx X.27 What you should know!  What is the difference between introspection and intercession?  What is the difference between structural and behavioural reflection?  What is an object? What is a class?  What is the difference between performing a message send and simply evaluating a method looked up in a MethodDictionary?  In what way does thisContext represent the run-time stack?  What different techniques can you use to intercept and control message sends?

© Oscar Nierstrasz ST — xxx X.28 Can you answer these questions?  What form of “reflection” is supported by Java?  What can you do with a metacircular architecture?  Why are Behaviour and Class different classes?  What is the class ProtoObject good for?  Why is it not possible to become: a SmallInteger?  What happens to the stack returned by thisContext if you proceed from the self halt?  What is the metaclass of an anonymous class?

11. Working with Bytecode

© Oscar Nierstrasz ST — xxx X.30 What you should know!  What are the problems of the old compiler?  How is the new Squeak compiler organized?  What does the Squeak semantic analyzer add to the parser-generated AST?  What is the format of the intermediate representation?  What kind of virtual machine does the Squeak bytecode address?  How can you inspect the bytecode of a particular method?

© Oscar Nierstrasz ST — xxx X.31 Can you answer these questions?  What different groups of bytecode are supported?  Why is the SmaCC grammar only BNF-“like”?  How can you find out what all the bytecodes are?  What is the purpose of IRBuilder?  Why do we not generate bytecode directly?  What is the responsibility of class InstructionStream?  How would you implement a statement coverage analyzer?

12. Traits and Classboxes

© Oscar Nierstrasz ST — xxx X.33 What you should know!  Why does single inheritance lead to duplicated code?  How does the composing class retain control of trait composition?  What do “glue” methods do for traits?  What is the “flattening property” and why is it important for traits?  Why is there “inappropriate inheritance” in the Smalltalk Collections hierarchy?  What is a “class extension”?  In what way to classboxes ensure locality of changes?  What problems are solved by combined traits and classboxes?

© Oscar Nierstrasz ST — xxx X.34 Can you answer these questions?  Why do multiple inheritance and mixins leads to “fragile class hierarchies”?  C++, Eiffel and Python all offer multiple inheritance – are they broken?  Why don’t traits specify any state?  How much code is duplicated in the standard Java libraries?  What problems occur in Java due to the lack of class extensions?  Can classboxes be “flattened” in the same way that traits can? Why or why not?