Post on 07-Jun-2018
IPIJ: Chapter Outlines Page 1
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Introduction to Interactive Programmingby Lynn Andrea Stein
A Rethinking CS101 Project
Interactive Programming In JavaChapter Outlines
Lynn Andrea Stein
Massachusetts Institute of TechnologyDepartment of Electrical Engineering and Computer Science
Cambridge, MA 02139 USAipij@ai.mit.edu
http://www.ai.mit.edu/projects/cs101/
Front MatterI. Table of Contents2. Preface
1. Why Interactive Programming?2. Ramifications for Later Curriculum3. A Short History of the Rethinking CS101 Project
1. Research Roots2. Classroom Experience
4. How to Use This Book1. Part By Part2. Pedagogical Elements and Supplementary Materials
5. About the Author6. Acknowledgements
3. List of Figures4. List of Tables5. List of Sidebars
1. Java Sidebars2. Style Sidebars
Part 1: Introduction To Interactive Program DesignChapter 1: Introduction to Program Design
IPIJ: Chapter Outlines Page 2
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Chapter Overview
Objectives of this Chapter
1. Computers and Programs2. Thinking Like a Programmer3. Programming Primitives, Briefly4. Ongoing Computational Activity5. Coordinating a Computational Community
1. What is the Desired Behavior of the Program?2. Who are the Members of the Community?3. What Goes Inside Each One?4. How Do They Interact?
6. The Development Cycle7. The Interactive Control Loop
Chapter Summary
Exercises
Chapter 2: The Programming Process
Chapter Overview
Objectives of this Chapter
1. The Problem1. Problem Requirements
1. Assumptions2. Promises/Guarantees
2. The Community Around You1. Program Libraries2. Users3. Physical Environment4. Understand their interfaces (and assumptions)
3. Requirements are a Moving Target1. Software Lifecycle2. Documenting your Design
2. Designing a solution1. Who are the members?2. How do they Interact
IPIJ: Chapter Outlines Page 3
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
1. What Promises?2. What Assumptions?3. Who does what?
3. What goes inside?4. Nouns and Verbs5. Acting it out
3. The process1. Keep it simple2. Keep it working3. You'll still have to debug (debugging is normal)
1. When it's not working2. make state manifest3. Explain it to someone4. Act it out
4. Documentation
Chapter Summary
Exercises
Interlude: A Community of Interacting Entities
Overview
Objectives of this Interlude
1. Introduction: Word Games2. Designing a Community
1. A Uniform Community of Transformers2. The User and the System3. What Goes Inside
3. Building a Transformer1. Transformer Examples2. Strings
1. String Concatenation2. String Methods
3. Rules and Methods4. Classes and Instances5. Fields and Customized Parts6. Generality of the Approach
IPIJ: Chapter Outlines Page 4
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
4. Summary
Suggested Exercises
Sidebar: Selected String Methods
Part 2: Entities and InteractionsChapter 3: Things, Types, and Names
Chapter Overview
Objectives of this Chapter
1. Things1. Primitive Things and Literals
1. Numbers2. Characters and Strings3. Booleans
2. Objects2. Naming Things
1. Referring to Things2. Assignment
3. Types1. Declarations and The type-of-thing name-of-thing Rule2. Definition = Declaration + Assignment3. Primitive Types4. Object Types
4. Types of Names1. Shoebox Names2. Label Names
Chapter Summary
Exercises
Sidebar: Java Naming Syntax and ConventionsSidebar: Java Primitive Types
Chapter 4: Specifying Behavior: Interfaces
Chapter Overview
IPIJ: Chapter Outlines Page 5
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Objectives of this Chapter
1. Interfaces are Contracts1. Generalized Interfaces and Java Interfaces2. A Java Interface Example
2. Method Signatures1. Name2. Parameters and Parameter Types3. Return Type4. Putting It All Together: Abstract Method Declaration Syntax5. What a Signature Doesn't Say
3. Interface Declaration1. Syntax2. Method Footprints and Unique Names3. Interfaces are Types: Behavior Promises4. Interfaces are Not Implementations
Chapter Summary
Exercises
Style Sidebar: Method DocumentationStyle Sidebar: Interface Documentation
See also Java Chart on Interfaces.
Chapter 5: Expressions: Doing Things With Things
Chapter Overview
Objectives of this Chapter
1. Simple Expressions1. Literals2. Names
2. Method Invocation3. Combining Expressions4. Assignments and Side-Effecting Expressions5. Other Expressions that Use Objects
1. Field Access2. Instance Creation3. Type Membership
IPIJ: Chapter Outlines Page 6
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
6. Complex Expressions on Primitive Types: Operations1. Arithmetic Operator Expressions2. Explicit Cast Expressions3. Comparator Expressions4. Logical Operator Expressions
7. Parenthetical Expressions and Precedence
Chapter Summary
Exercises
Style Sidebar: Don't Embed Side-Effecting ExpressionsSidebar: Java OperatorsSidebar: Arithmetic ExpressionsSidebar: Coercion and CastingSidebar: Java Operator PrecedenceSidebar: Other Assignment Operators
See also Java Chart on Expressions
Chapter 6: Statements and Rules
Chapter Overview
Objectives of this Chapter
1. Statements and Instruction-Followers2. Simple Statements3. Declarations and Definitions4. Sequence Statements5. Flow of Control
1. Simple Conditionals2. Simple Loops
6. Statements and Rules1. Method Invocation Execution Sequence2. Return
Chapter Summary
Exercises
Style Sidebar: Formatting Declaration Statements
IPIJ: Chapter Outlines Page 7
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Style Sidebar: Formatting BlocksStyle Sidebar: Using BooleansStyle Sidebar: Documentation
See also Java Chart on Statements
Interlude: Entities and Aggregates/Rules and Roles
Overview
Objectives of this Interlude
1. The Problem2. Representation3. Interacting with the Rules4. Paying Attention to the World5. Fancy Dot Tricks6. Remembering State
1. Fields2. Fields vs. Variables
7. Summary
Suggested Exercises
Chapter 7: Building New Things: Classes and Objects
Chapter Overview
Objectives of this Chapter
1. Classes are Object Factories1. Classes and Instances2. Recipes Don't Taste Good3. Classes are Types
2. Class Declaration1. Classes and Interfaces
1. implements and type inclusion2. contract vs. implementation
3. Data Members, or Fields1. Fields are not Variables
1. Hotel Rooms and Storage Rental2. Whose Data Member is it?
IPIJ: Chapter Outlines Page 8
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
3. Scoping of Fields4. Comparison of Kinds of Names
2. Static Members4. Methods
1. Method Declaration2. Method Body and Behavior3. A Method ALWAYS Belongs to an Object
1. this.2. Static Methods
4. Method Overloading5. Constructors
1. Constructors are Not Methods2. Syntax3. Execution Sequence4. Multiple Constructors and the Implicit No-Arg Constructor5. Constructor Functions
Chapter Summary
Exercises
Style Sidebar: Class DeclarationSidebar: Java Types and Default InitializationTable: Comparison of Kinds of NamesStyle Sidebar: Field DocumentationStyle Sidebar: Method Implementation DocumentationSidebar: Method Invocation and ExecutionStyle Sidebar: Constructor DocumentationStyle Sidebar: Capitalization Conventions
See also Java Charts on Classes, Methods, and Fields.
Part 3: Refining DesignsChapter 8: Designing with Objects
Chapter Overview
Objectives of this Chapter
1. Object-Oriented Design
IPIJ: Chapter Outlines Page 9
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
1. Objects are Nouns2. Methods are Verbs3. Interfaces are Adjectives4. Classes are Object Factories5. Some Counter Code (An Example)6. Public and Private
2. Kinds of Objects1. Data Repostories2. Resource Libraries3. Traditional Objects
3. Types and Objects1. Declared Types and Actual Types2. Use Interface Types3. Use Contained Objects to Implement Behavior4. The Power of Interfaces
Chapter Summary
Exercises
Style Sidebar: Class and Member DocumentationSidebar: FinalSidebar: class Math
Collections: An Extended Example
Overview
Objectives
1. Exercises
Chapter 9: Animate Objects
Chapter Overview
Objectives of this Chapter
1. Animate Objects2. Animacies are Execution Sequences3. Being Animate-able
1. Implementing Animate
IPIJ: Chapter Outlines Page 10
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
2. AnimatorThread3. Creating the AnimatorThread in the Constructor4. A Generic AnimateObject
4. More Details1. AnimatorThread Details2. Delayed Start and the init() Trick3. Threads and Runnables
5. Where do Threads come from?1. Starting a Program2. Why Constructors Need to Return
Sidebar: class AnimatorThreadSidebar: Thread MethodsSidebar: class MainStyle Sidebar: Using main()
Chapter Summary
Exercises
Chapter 10: Reusing Implementation: Inheritance
Chapter Overview
Objectives of this Chapter
1. Derived Factories1. Simple Inheritance2. java.lang.Object3. Superclass Membership
2. Overriding1. super.
2. The Outside-In Rule3. Problems with Private
3. Constructors are Recipes1. this()
2. super()
3. Implicit super()
4. Interface Inheritance5. Relationships Between Types
IPIJ: Chapter Outlines Page 11
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
The class ObjectStyle Sidebar: Explicit Use of this. and super()
Sidebar: Abstract Classes
1. Chapter Summary
Exercises
Interlude: A System of Animate Objects
Objectives
Overview
Suggested Exercises
Chapter 11: When Things Go Wrong: Exceptions
Chapter Overview
Objectives of this Chapter
1. Exceptional Events1. When Things Go Wrong2. Expecting the Unexpected3. What's Important to Record
2. Throwing an Exception3. Catching an Exception4. Throw vs. Return5. Designing Good Test Cases
Sidebar: Throw Statements and Throws ClausesSidebar: Try Statement SyntaxSidebar: Exceptions, Errors, and RuntimeExceptions
1. Chapter Summary
Exercises
Part 4: Refining InteractionsChapter 12: Dealing with Difference: Dispatch
Chapter Overview
IPIJ: Chapter Outlines Page 12
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Objectives of this Chapter
1. Conditional Behavior2. If and else
1. Basic Form2. Else3. Cascaded Ifs4. Many Alternatives
3. Limited Options: Switch1. Constant Values
1. Symbolic Constants2. Using Constants
2. Syntax1. Basic Form2. The Default Case3. Variations4. Switch Statement Pros and Cons
4. Arrays1. What is an Array?
1. Array Declaration2. Array Construction3. Array Elements
2. Manipulating Arrays1. Stepping Through an Array Using a For Statement2. Using Arrays for Dispatch
5. When to Use Which Construct
Sidebar: if Statement SyntaxSidebar: final
Style Sidebar: Use Named ConstantsSidebar: break and continue statementsSidebar: switch Statement SyntaxSidebar: Array SyntaxSidebar: for Statement Syntax
1. Chapter Summary
Exercises
Chapter 13: Encapsulation
IPIJ: Chapter Outlines Page 13
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Chapter Overview
Objectives of this Chapter
1. Design, Abstraction, and Encapsulation2. Procedural Abstraction
1. The Description Rule of Thumb2. The Length Rule of Thumb3. The Repetition Rule of Thumb4. An Example5. The Benefits of Abstraction
3. Protecting Internal Structure1. private2. Packages
1. Packages and Names2. Packages and Visibility
3. Inheritance4. Clever Use of Interfaces
4. Inner Classes1. Static Classes2. Member Classes3. Local Classes and Anonymous Classes
5.
Style Sidebar: Procedural AbstractionSidebar: Package Naming SummarySidebar: Package Visibility SummarySidebar: Inner Classes
1. Chapter Summary
Exercises
Chapter 14: Intelligent Objects and Implicit Dispatch
Chapter Overview
Objectives of this Chapter
1. Procedural Encapsulation and Object Encapsulation2. From Dispatch to Objects
1. A Straightforward Dispatch
IPIJ: Chapter Outlines Page 14
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
2. Procedural Encapsulation3. Variations4. Pushing Methods Into Objects5. What Happens to the Central Loop?
3. The Use of Interfaces4. Runnables as First Class Procedures5. Callbacks6. Recursion
1. Structural Recursion1. A Recursive Class Definition2. Methods and Recursive Structure3. The Power of Recursive Structure
2. Functional Recursion
Chapter Summary
Exercises
Chapter 15: Event-Driven Programming
Chapter Overview
Objectives of this Chapter
1. Control Loops and Handler Methods1. Dispatch Revisited
2. Simple Event Handling1. A Handler Interface2. An Unrealistic Dispatcher3. Sharing the Interface
3. Real Event-Driven Programming1. Previous Examples2. The Idea of an Event Queue3. Properties of Event Queues
4. Graphical User Interfaces: An Extended Example1. java.awt2. Components3. Graphics4. The Story of paint
5. Events and Polymorphism
IPIJ: Chapter Outlines Page 15
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Chapter Summary
Exercises
See also the AWT Quick Reference.
Interlude: Achieving Customized Behavior
Objectives
Overview
Suggested Exercises
Chapter 16: Event Delegation (and AWT)
Chapter Overview
Objectives of this Chapter
1. Model/View: Separating GUI Behavior from Application Behavior1. The Event Queue, Revisited
2. Reading What the User Types: An Example1. Setting up a User Interaction2. Listening for the Event3. Registering Listeners4. Recap
3. Specialized Event Objects4. Listeners and Adapters: A Pragmatic Detail5. Inner Class Niceties
Sidebar: cs101.awt.DefaultFrame
1. Chapter Summary
Exercises
See also the AWT Quick Reference.
Interlude: An AWT Application
Objectives
Overview
IPIJ: Chapter Outlines Page 16
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Suggested Exercises
Part 5: Systems of ObjectsChapter 17: Models of Communities
Chapter Overview
Objectives of this Chapter
1. State Machines2. State Spaces3. Organizational Behavior4. Network Models5. Patterns6. UML7. Metrics
1. Static Complexity2. Throughput and Latency
Sidebar: FSM Rules
1. Chapter Summary
Exercises
Chapter 18: Interfaces and Protocols: Gluing Things Together
Chapter Overview
Objectives of this Chapter
1. Pacing2. Procedure Calls3. Callbacks4. Explicit Communication Channel Objects5. Protocols
Chapter Summary
Exercises
Chapter 19: Communication Patterns
IPIJ: Chapter Outlines Page 17
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Chapter Overview
Objectives of this Chapter
1. What is a Client-Server Interaction?2. Implementing Client-Server Interactions
1. Client Pull2. Server Push
3. The Nature of Duals4. Pushing and Pulling Together
1. Passive Repository2. Active Constraint
Chapter Summary
Exercises
Interlude: Combining Events and Interactive Control Loops
Objectives
Overview
Suggested Exercises
Chapter 20: Synchronization
Chapter Overview
Objectives of this Chapter
1. Reads and Writes2. An Example of Conflict3. Synchronization4. Java synchronized
1. methods2. (blocks)
5. What synchronization buys you6. Safety rules7. Deadlock8. Obscure Details
Chapter Summary
IPIJ: Chapter Outlines Page 18
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Exercises
Chapter 21: Network Programming
Chapter Overview
Objectives of this Chapter
1. A Readable Writeable Channel1. Tin Can Telephones2. Streams
2. Using A Channel1. For Writing
1. Flushing Out the Stream2. A Scribe Example
2. For Reading1. Reading and Blocking2. A Lector Example
3. Encapsulating Communications3. Real Streams
1. Abstract Stream Classes2. Decorator Streams3. Stream Sources4. Decoration in Action
4. Network Streams: An Example1. Starting from Streams2. Decorating Streams3. Sockets and Ports4. Using A Socket5. Opening a Client-Side Socket6. Opening a Single Server-Side Socket7. A Multi-Connection Server8. Server Bottlenecks
Chapter Summary
Exercises
Interlude: Client/Server Chat
Objectives
IPIJ: Chapter Outlines Page 19
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
Overview
Suggested Exercises
Chapter 22: Conventional Architectures
Chapter Overview
Objectives of this Chapter
1. Server Architechtures1. Dumb broadcast server2. Routing server3. DNS
2. RPC3. Peer Architectures
1. Ring2. Round Robin3. Cubes
4. Arbitration5. Blackboard6. Tuple-space
Chapter Summary
Exercises
Appendices1. Applets2. AWT Quick Reference
1. AWT Components2. Component3. Canvas4. Widgets and their Event Types5. Basic Widgets6. ItemSelectable Widgets7. Text Widgets8. Container9. Panel and Frame
10. Dimension, Point, and Rectangle
IPIJ: Chapter Outlines Page 20
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
11. Graphics12. AWT Events13. ActionEvent and ActionListener14. AWT Listeners and Adapters
3. IO Quick Reference1. InputStream and Reader2. OutputStream and Writer3. Sources of Streams4. InputStreamReader and OutputStreamWriter5. Files6. Pipes7. Streams that Add Features8. Buffering9. Primitive Data
10. Object Streams and Serialization11. Other Useful Streams12. IOExceptions
4. Java Charts1. About Java Charts2. Program File3. Class Declaration4. Field Declaration5. Method Declaration6. Expression7. Statement8. Disclaimers, Notes, Amendments, etc.
5. Glossary6. Indices
1. Syntax Sidebars2. Style Sidebars3. Interludes4. Case Studies5. Terms
© 2003 Lynn Andrea Stein
This chapter is excerpted from a draft of Introduction to Interactive Programming In Java, a forthcomingtextbook. It is a part of the course materials developed as a part of Lynn Andrea Stein's Rethinking CS101Project at the Computers and Cognition Laboratory of the Franklin W. Olin College of Engineering and
IPIJ: Chapter Outlines Page 21
http://www.cs101.org/ipij/outline.html 09/18/2003 11:39:08 AM
formerly at the MIT AI Lab and the Department of Electrical Engineering and Computer Science at theMassachusetts Institute of Technology.
Questions or comments:<webmaster@cs101.org>