CSc 668/868: Object Oriented Programming
© 2008 by Dr. Barry Levine
Topics 8
Note on Group Work 11
CSC 868 Oral Presentations 12
An Introduction to Object-Oriented Analysis and Design 14
Macro Level Process 21
Object-Oriented Analysis 22
Object-Oriented Design 22
IMPLEMENT A STORE/POST (Point of Sale Terminal) SYSTEM 23
POST 24
Databases 25
Object-Oriented Analysis 26
Conceptual Model for POST (objects found in the real world – nouns drawn from the requirements/specification) 28
Object-Oriented Design 30
High-level Stages in the STORE/POST Software System: 31
POST Assignments 32
Sample File I/O API 34
Use Case View 38
Logical View 38
Relationships 38
Component View 39
Some Notes on Java 40
this in Java 40
this Used in Method Calls 41
Enumerated Types and Type Safety 42
Architectural Design (Appendix 2) 43
Architectural Patterns 43
Model-View-Control 43
Client-Server 43
Reflection 44
Layers 44
Package Structures 44
Java's Remote Method Invocation - RMI 46
Distributed Garbage Collection 49
Object Registration 49
RMI Example - Accounts used by ATM's 49
Steps to run this example (JDK 1.5 on Windows XP): 53
RMI Example - Remote methods returning remote objects 55
Steps to run this example (JDK 1.5 on Windows XP): 59
RMI Client-Server Implementation of the POST Problem 62
Main Objects Shipped from Server (Store) to Client (POST) 62
Main Objects Shipped from Client to Server 62
Objects on Client (POST) 63
Objects on Server (Store) 63
Comments 63
Object Oriented Programming Principles 64
Documentation 64
Message passing versus function calls 64
Quality of an Interface 65
Inheritance (type/subtype relationship) 67
Subclassing heuristics 67
Software Reuse 70
Subclass/Subtypes 71
Polymorphic Variables 72
Reverse Polymorphism 72
Replacement vs Refinement 74
Implementation Issues 76
Covariance and Contravariance (Overriding methods) 78
Covariant Return Types 78
Multiple Inheritance 79
Polymorphism (deals with types) 80
Forms of Polymorphism 80
Visibility and Dependence 82
Coupling and Cohesion 82
Law of DemeterÔ 85
Overriding versus Shadowing 87
Overriding: Accessibility and Exceptions 88
A Note on Protected Variables and Methods 90
Frameworks and Patterns 91
Another Look at Classes 92
OOP AND SOFTWARE ENGINEERING 93
ABSTRACTION 93
INFORMATION HIDING 93
ABSTRACTION AND INFORMATION HIDING 94
LOCALIZATION 94
Software Engineering Concepts 95
SURFACE AREA 95
FACTORS INFLUENCING SURFACE AREA 95
HARDWARE IC's: 95
SOFTWARE IC's: 95
SOFTWARE QUALITY 96
MODULES 97
TOP-DOWN VS OBJECT-ORIENTED DESIGN 98
Unit Testing 99
Squeak/Smalltalk - 80 101
Identifiers: 102
Message Expressiongs 102
SELF 103
Class Variables 104
Generators 105
CLASSES AND METACLASSES 107
Reflection and Persistence (Appendix 5) 116
Reflection 116
Reflective Systems 116
Strategies 119
Static Structure 120
Runtime Classes 121
Runtime Type Information in Java 122
Dynamic Instantiation 124
Dynamic Instantiation in Java 124
Dynamic Instantiation in C++ (The Prototype Pattern) 125
Persistence 126
Databases 126
Data Streams 129
Output Streams 129
Input Streams 130
Object Streams 130
Databases 136
Connection 137
Statements 137
Result Set 138
Programming and Design Principles 140
Challenges in modern programming 140
Coupling and variabilities 140
What is a good design? 140
Documenting policy 140
Object Oriented Analysis and Design 141
Event Notification (Appendix 3) 144
Overview 144
Design Patterns 144
The Publisher-Subscriber Pattern 146
Dynamic Structure 147
The Publisher-Subscriber Pattern in Java 148
Example: Monitoring Devices (continued) 148
Java Foundation Classes (JFC) 151
Constraint Networks 153
Programming Note 157
Some Important Design Patterns 160
Model-View-Controller 160
Adaptor Pattern 160
Chain of Responsibility Pattern 160
Decorator Pattern 160
Observer Pattern 160
Proxy Pattern 161
Strategy Pattern 161
Streams Pattern (Pipes and Filters, Dataflow) 161
References 161
Refactoring to Patterns 162
1. Compose Method Refactoring 162
Example 162
Benefits and Liabilities 164
2. Replace Conditional Logic with Strategy 165
Example 165
Benefits and Liabilities 168
3. Replace Conditional Dispatcher with Command 169
Example 169
Benefits and Liabilities 172
4. Replace Type Code with Class 173
Example 173
Benefits and Liabilities 174
Frameworks. Toolkits, and Polymorphism (Appendix 4) 175
Overview 175
Frameworks 175
Example: Application Frameworks 176
Example: Client-Server Frameworks 176
Object-Oriented Concepts 177
Polymorphism 177
Abstraction 178
Working with Unknown Classes 181
MFW: A Framework for Music Applications 182
Heterogeneous Collections 182
Virtual Factory Methods 183
Factories in Java 185
Inner Classes 185
Local Classes 186
Anonymous Classes 186
Closures, Functors, and Thunks 187
Power Types as Factories 189
Toolkits 191
Generic Methods 194
Singletons 195
Example: A Simple Application Framework 195
Calculator 196
The Console Framework 196
Example: Pipelines 200
PIPES: A Pipeline Toolkit 203
Programming Notes 208
Stereotypes 208
The Java Collections Framework 209
More on Design Patterns 209
Adaptor Pattern 210
Façade Pattern 212
Comparison between Façade and Adaptor Patterns 213
Encapsulation 215
Bridge Pattern 217
Composite Patterns 219
Delegation (Appendix 6) 220
Objects as States 220
Delegation Defined 222
Adapters 223
Handle-Body Idioms 224
Shared Bodies 225
Presentation and Control (Appendix 7) 230
The Model-View-Controller Architecture 230
Static Structure 231
GUI Toolkits 232
Views and View Notification 232
Example: MFC's Document-View Architecture (Develop word processor) 233
Building an Application Framework (AFW) 236
AFW 1.0: A CUI Application Framework 236
Design 236
Implementation 237
Example: Account Manager 241
AFW 2.0: A GUI Application Framework with Multiple Views 243
Design 243
Implementation 243
Commands and Command Processors 249
AFW 3.0: A GUI Application Framework with a Command Processor 250
Design 250
Implementation 251
Example: Polygon Viewer Customization of Version 3.0 of AFW 259
Design 262
Implementation 262
Mementos 264
Static Structure 264
Resource Managers 265
Integrating Patterns in the Design of a Hierarchical File System 267
Four main benefits of patterns: 267
Goals for the system: 267
Application of the Composite Pattern 268
Intent of the Composite Pattern: 270
Applicability Section - use Composite when 270
Directory 271
Include a mkdir command 271
mkdir version 1 - problems: 272
mkdir version 2 - simplification via uniform treatment: 273
mkdir version 3 - use of downcasting: 274
Adding Symbolic Links: Proxy Pattern 275
File System Class Structure with Composite and Proxy 277
Visitor Pattern 278
Visitor Code With No Common Operation Behavior 279
Visitor Code With Common Operation Behavior 281
Modifications to Code Using Visitor 282
Visitor Benefit 282
Deleting Files and Directories within a Single User Protection Framework (e.g. single user on a PC, not a multi-user system under e.g. UNIX) - the Template Pattern 283
Summary of Design Patterns Used in the File System Design 287
Active and Distributed Objects (Appendix 8) 288
Multi-Threading 288
Implementing and Scheduling Threads 288
Inter-Thread Communication 289
Active Objects 289
The Master-Slave Design Pattern 289
Java Threads 290
Scheduling 291
Thread States 291
Preemptive vs. Nonpreemptive Scheduling 291
Example: Bouncing Balls 291
Producer-Consumer Problems 295
Example: A Joint Checking Account Simulation 296
Monitors 298
Direct Communication 301
Example: A Date Client 302
A Server Framework 303
Design 303
Implementation 303
Example: A Command Server Framework 305
Indirect Communication 307
Proxies 307
Conclusion 310
Documentation and Coding Standards 311
Sample Coding Standards 313
Summary of Notes Mentioned in the String Class 317
Miscellaneous Issues 318
SWITCH. 318
TRY/CATCH/FINALLY.: 318
General Comments: 318
Names: 318
General Programming 319
LAYOUT OF SOURCE FILES (*.java) 319
SCRUM: An Empirically-Based Process for Software Project Management 321
Principles behind the Agile Manifesto 321
Overview 322
Scrum Summary 325
Scrum Components and Processes– Definitions and Functionality 326
Scalability 354
Management Issues 355
Scrum Notes for 668/868 356
Weekly Deliverables (due each Friday) 360
Squeak Smalltalk Exercise 361
Project Information 363
Project Milestones (Deliverables include mockups, specs, architecture diagrams as determined by the indicated milestone) 364
Final Project Deliverables 364
Object-Oriented Programming
CSc 668/868
Dr. Barry Levine
Thornton 949, x81661
Course Number: CSC 668/868
Course Title: Advanced Object Oriented Software Design and Development
Number of Credits: 3
Schedule: Three hours of lecture/discussion per week.
Prerequisite: Senior or graduate standing, and at least a C grade in CSC 413, or consent
of instructor.
Catalog Description
Basic principles of object oriented analysis and design utilizing UML, advanced object oriented programming principles, design patterns, frameworks and toolkits; Agile software design processes. Development of a mid-size programming project working in teams. Paired with CSC 868. Students completing this course may not take CSC 868 later for credit. Extra fee required.
Topics
1. An Introduction to Object-Oriented Analysis and Design
2. Some Notes on Java
3. Architectural Design
4. Java's Remote Method Invocation – RMI
5. Object Oriented Programming Principles
6. OOP and Software Engineering
7. Software Engineering Concepts
8. Unit Testing
9. Squeak/Smalltalk – 80
10. Reflection and Persistence
11. Programming and Design Principles
12. Event Notification
13. Design Patterns
14. Refactoring
15. Frameworks. Toolkits, and Polymorphism
16. Delegation
17. Presentation and Control
18. Active and Distributed Objects
19. SCRUM: An Empirically-Based Process for Software Project Management
20. Documentation and Coding Standards
Course Objectives and Role in Program
The prime objective of the course is to teach the student to analyze, design and implement object-oriented software systems by means of a mid-sized project. Students will learn the application of software architectures in various settings, including the application of design patterns, frameworks and toolkits. The ability to architect software systems is basic to all subsequent courses in which software development is an integral part. In addition, many of the concepts facing the prospective developer in modern software technology, such as Refactoring and team-oriented Agile software development processes are examined in detail and integrated into general software practice.
Learning Outcomes
At the end of the course students will be able to
· Utilize processes and artifacts to work effectively in a team-oriented development environment
· Apply various software architectures, including frameworks and design patterns, when developing software projects
· Develop Smalltalk applications
· Program distributed applications in a Java environment
· Effectively construct medium-sized object-oriented programs.
Project
Student teams will propose and develop a medium-sized project of their own.
Project Meetings
We will have ongoing meetings to discuss the term project - you will bring project documentation to these meetings (class diagrams, etc.) so I can assess your design efforts and relevancy to your proposal
Software
Squeak Smalltalk (free) is available for download (see ilearn)
Java is available on the PC’s (free) – you MUST use an IDE such as Netbeans
Grading (approximate)
CSc 668 CSc 868
Labs........................50% Labs........................40%
Class Participation.....5% Class Participation.....5%
Term project............45% Term project...........40%
Presentation............15%
Note: Students enrolled in CSc 868 are required to provide a presentation of a course-related article found in the current Computer Science literature. All students are required to be present at the 868 presentations. Up to 10% of the lab points will be deducted from the grade of students who do not attend the presentations.
Texts
Squeak: Object-Oriented Design with Multimedia Applications, Mark Guzdial, Prentice Hall, 2000
Applying UML and Patterns - an Introduction to Object-Oriented Analysis and Design by Craig Larman, Prentice Hall , [1998] (Optional)
Core Java 2 - Volume II-Advanced Features (5th Edition) by C. Horstmann & G. Cornell, Prentice Hall, [December 10, 2001] (Optional)
Recommended References:
Design Patterns, Elements of Reusable Object-Oriented Software, Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, Addison Wesley, Reading, MA. 1995.
· "Software Patterns", Communications of the ACM, October, 1996.
· Refactoring to Patterns, Joshua Kertevsky, Addison-Wesley 2005
· Design Patterns Explained: A New Perspective on Object-Oriented Design, A. Shalloway & J. Trott, Addison-Wesley, 2002
· Pattern Hatching Design Patterns Applied, J. Vlissides, Addison-Wesley, 1998
· Agile Software Development with Scrum, Ken Schwaber & Mike Beedle, Prentice-Hall, 2001
· IEEE Computer, Special Issue on Agile Software Development, June 2003
· Refactoring; Improving the Design of Existing Code, Martin Fowler, Addison-Wesley, 2000
· Framework-Based Software Development in C++, Gregory F. Rogers, Prentice Hall, 1997
Note on Group Work
In most cases programmers work in groups (for better or worse) so it's important that you check out and learn about group dynamics while in school...in fact, many CS programs require students to work in groups in most courses.
There are many recipes for success/failure that you should learn. Therefore, if you are struggling with your group during the term I EXPECT you to check things out with me BEFORE you reach an untenable situation - be proactive!
I will act as facilitator, not judge. My goal will be to help you resolve issues so you can continue in a productive manner.
Again, SEE ME AS SOON AS POSSIBLE IF YOU ARE ENCOUNTERING GROUP
PROBLEMS.
In summary,
· All group members are expected to contribute to the best of their abilities
· Each group member MUST participate in teamwork and group work, attend meetings and be courteous and responsible
· All group members get the same grade UNLESS the instructor is told or discovers that somebody is not contributing fully
You will select a group leader for each group
Role of group leads
· Organize and schedule meetings
· Single point of contact with instructor
· Help resolve issues
· Can request meeting/input from instructor
· Participation in creating deliverables (a bit reduced for group lead tasks)
· Responsible for submitting documents, as described at the end of the Reader
CSC 868 Oral Presentations
The additional requirement for people enrolled in CSc 868 is to present a review of an article found in the Computer Science literature on Object-Oriented Programming. You should peruse the literature in the library (SFSU library or UC Berkeley library or...) to determine a topic you are interested in studying. Then bring a copy of the article to me for PRIOR approval. You will present your review to the class during a regular meeting. We will agree upon a time for presentation. The presentation should last approximately 30 minutes (the time will depend on the article; in any case, you should practice your lecture to ensure that it doesn't exceed 25 minutes. This is to allow for any questions). I will give suggestions for each presentation.
Library references are:
- ACM SIGPLAN (especially the conference proceedings on object-oriented programming).
- IEEE Software
- Software: Practice and Experience
- IEEE Transactions on Software Engineering
- Communications of the ACM
- Computer Language
- The Journal of Systems and Software
Unlike the 868 programming assignments, the reviews will be done on an individual basis. You are required to receive my approval on your proposed review ... (be sure to plan ahead since it is possible that I will not approve your initial request).
BE SURE TO PREPARE TRANSPARENCIES/POWERPOINT PRESENTATION FOR YOUR LECTURES. USE EXAMPLES AND PICTURES.
DO NOT DO NOT DO NOT PRESENT YOUR MATERIAL BY READING FROM YOUR SLIDES!!!
DO NOT BRING ANY NOTES...YOUR PRESENTATION SHOULD FOCUS ON YOUR SLIDES (people have a tendency to use notes as a crutch and simply read from them)
Of course, if you spend most of the time reading from your slides then it will not be enjoyable nor very interesting for the audience. Please see me for any suggestions.
After presenting a complete reference to your article you should present a coherent outline of the presentation (frequently refer back to this outline to help the audience follow the flow of your talk). You should give an introduction, overview of your presentation,
then the main body of your talk and end with any conclusions.
BE SURE TO USE PICTURES AND EXAMPLES to help the audience understand
your talk.
The weight of the review is approximately 15% of your grade for 868. In any case, if you do not present a review then you will not receive a grade higher than a "C" for the course.
After I approve your article you need to send me the following information:
Your name,
Title, author(s), date of pub, where published
An Introduction to Object-Oriented Analysis and Design
Macro Process