1/66
Looks like no tags are added yet.
Name | Mastery | Learn | Test | Matching | Spaced | Call with Kai |
|---|
No analytics yet
Send a link to your students to track their progress
Which company pioneered the “personal” computer in the early 1970s?
Xerox
Smalltalk has only two reserved words. What are they?
Self and Super
Smalltalk has three non-class globals. What are they?
true, false, nil
Instead of using commands (reserved words like if-then-else, do, while, for), Smalltalk uses what syntax to handle branching and looping?
Message sending / blocks (closures)
Although Smalltalk is often described as object-oriented, what feature makes it close to a functional paradigm?
Blocks / closures as first-class objects
What is image-based persistence?
The whole system state is saved as an image and resumed later. All coding is done inside the live environment
Modern commercial implementation of Smalltalk?
Cincom VisualWorks
Modern open-source implementation of Smalltalk
Pharo
Describe implementation of not without if-then
Boolean class with two subclasses for True and False that have a not method. The not method for each returns false if true and true if false.
Describe implementation of or without if-then.
False and true each have their own or method. In false or returns what was passed in. in true it returns true.
Describe implementation of and without if-then.
False and true each have their own method. The and method for false returns false. The and method for true returns whatever was passed in.
Alan Kay’s analogy for objects?
Biological cells
Sending a message is ________?
Making a choice
“Do not ask, tell” means?
Tell objects what to do instead of asking for data and deciding externally.
Two general categories defined by a class?
state and behavior
what does it mean that “A subclass expresses a delta”
A subclass represents only the differences from its superclass.
Two steps in sending a message?
1. Look up the method
2. Execute the method
When using self/this, where does method lookup start?
In the receiver’s class
When using super, where does method lookup start?
In the superclass
Tests verify that what worked before _____.
Still works
Tests reduce the fear _____.
Of change
A test that is not _______ does not exist!
Automated
A test: In this , this produces this __.
Context, input, output
Three possible outcomes of a test?
Success, Fail, Error
Method run before each test?
setUp
Method run after each test?
tearDown
At a minimum, you should write a test for ___.
Every bug
What is test-driven development?
Write tests before writing implementation code.
Testing like documentation?
Tests show how code should behave.
Testing better than memory because?
Tests are executable and repeatable.
How do tests help software evolve?
They catch regressions during changes.
Design patterns are _________ solutions to design problems.
Reusable
How do design patterns assist communication?
Shared vocabulary among developers
Five elements of a design pattern?
Name, intent, problem description, solution description, consequences
Three categories of design patterns?
Creational, structural, behavioral
What is the template method pattern?
A superclass defines an algorithm structure while subclasses fill in steps/hooks.
Difference between a data structure and an object?
Data structures expose data; objects hold data and behavior.
Presence of if-then-else or switch-case should be examined for replacement with what?
self-send (hook) to be implemented in subclasses
Intent of singleton pattern?
Ensure only one instance exists.
Solution for singleton pattern?
Private constructor + static/shared instance accessor
A composite allows us to compose objects into tree structures to represent what?
Part-whole hierarchies
A composite allows clients to treat _______ objects and _________ objects uniformly.
Individual, composite
Example of composite pattern?
File systems
Example of composite pattern in Flutter?
Widget trees
Advantage of state pattern?
Eliminates large conditionals by delegating behavior to state objects. Each state implements only its operations, and it implements its transitions.
How many concrete classes needed for rock-paper-scissors?
4
What methods implemented in each concrete class?
A vs method, playAgainstRock, playAgainstPaper, and playAgainstScissors
Meaning of the double in double dispatch?
There are two messages passed.
How are conditionals handled?
Through polymorphic method calls instead of if-then-else.
Without explicit initialization, what is in temporary variables in C++?
undefined values
Without explicit initialization in Smalltalk, Python, or Dart?
nil / None / null
If a function can return null, what burden is on clients?
They must check for null.
What is a null object?
An object with neutral/do-nothing behavior replacing null.
What is lazy initialization?
Delaying object creation until first use.
Duration of a variable?
When a variable is deallocated
Scope of a variable?
Where a variable is visible
What should you do instead of placing a literal in a large method?
Instance variable with setter or separate hook methods
What is the flyweight pattern?
Shared object, but also allow for classes to have their own modified version
Using flyweight for Date objects?
Reuse shared Date instances instead of creating duplicates.
What is coupling?
Degree of interdependence between software modules
What is cohesion?
How closely related a class’s responsibilities are
What message sends are preferred by the Law of Demeter?
Sends to:
An argument passed to you
Instance variables
An object you create
Self, super, and your class
Who are the clients of a class?
Code/classes that use it
Purpose of inheritance?
Reuse and specialization
In subclassing, classes share ______________ and ___________.
Interface and implementation
In subtyping, classes share ______________ but not ___________.
Interface, implementation
What is duck typing?
If an object behaves correctly, its actual type does not matter (“if it walks like a duck and quacks like a duck, it must be a duck”).