1 / 16

The Role of Design in the First-Year Computer Science Curriculum

The Role of Design in the First-Year Computer Science Curriculum. CCSC Third Annual Northeastern Conference Friday 24-April-98 Rick Mercer - Penn State rhm1@psu.edu These slides are at www.bk.psu.edu/faculty/mercer. First some quotes.

lecea
Download Presentation

The Role of Design in the First-Year Computer Science Curriculum

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. The Role of Design in the First-Year Computer Science Curriculum CCSC Third Annual Northeastern Conference Friday 24-April-98 Rick Mercer - Penn State rhm1@psu.edu These slides are at www.bk.psu.edu/faculty/mercer

  2. First some quotes Design is the set of activities including (1) defining an architecture for the software that satisfies the requirements and (2) specifying an algorithm for each software component Alan Davis

  3. Good design comes from experience, experience comes from bad design Fred Brooks

  4. Freshman can't design • anonymous

  5. A CCSCNC Aside • Imaginethis is week #13 of your first course and you can • construct and manipulate objects send messages • implement classes • you know a few OO design heuristics guidelines • you know control structures and arrays • this is the first of several lectures on OO design • You have adopted Computing Fundamentals with Standard C++, 2nd Edition, Rick Mercer, Franklin, Beedle, and Associates

  6. Snapshot of the next two weeks • Week #13 Outline • Introduce object-oriented design in the context of a case study JukeBox • Role play some scenariosone team up front at first • Develop Component/Responsibility/Helper (CRH) cards • Week #14 Outline • Design classes methods, instance variables • Select 4 to 5 person teams pick new project • Analyze the problem, design a solution

  7. Object-Oriented Design • Object-oriented design activities • (1) identify the key abstractions (classes) and • (2) assign the major responsibility to each class

  8. A Problem Specification The student affairs office has decided to put some new found activity fee funds toward a music juke box in the student center. The JukeBox should allow a student to play individual songs. No money is required. Instead, a student swipes a magnetic Student ID card in a card reader to select songs. Each student is allowed to play up to 1500 minutes worth of "free" JukeBox music in their academic careers at the school, but never more than two selections on any given date. A student may select a CD from the available collection of CDs and then select an individual song from the CD. Students may not play entire CDs.

  9. Goals for the First Phase 1. Find classes that model (shape) the system as a natural and sensible set of abstractions. 2. Determine the purpose, or main responsibility of each class. • what an instance of the class must be able to do • what each object must know about itself 3. Look for helpers • To help complete its responsibility, one object may delegate responsibility to other objects.

  10. One Possible Architecture: The major components and the system boundary CardReader Gets Student ID StudentCollection Stores valid Students Student Track- Selector Gets track to play JukeBox Coordinates activities CDCollection Stores all CDs that can be played CDPlayer Plays a Track CD Track

  11. Scenario: What happens when a Student, with a valid account, wants to select a Track? ... JukeBox: Okay, now I should check to make sure the Student is able to select this Track before telling the CDPlayer to play it. I seem to remember I just can not simply play a Track without checking on a few things. I know the current Student and the selected Track. What do I do now? Who is role playing Track? Who is role playing Student?

  12. Object-Oriented Design Heuristics guidelines to good design • Minimize the number of message sends between a class and its helper. • Avoid all-powerful (omnipotent) classes. • Distribute system intelligence among the classes as evenly as possible. The top-level classes in a design should share the work uniformly.

  13. CRH cards to Class definitions • CRH Cards capture analysis and some design decisions

  14. CRH cards help design classes // First draft, no constructors yet class cdCollection { public: void addCD(const CD & aCD); // Add a CD to the collection if possible bool removeCD(const CD & aCD); // Remove CD if possible or return false private: vector <CD> my_data; int my_size; };

  15. A design pattern: Iterator class CD { public: CD(); CD(string initArtist, string initTitle, int initNum); //--modifiers void addTrack(const track & nextTrack); // accessors string artist() const; string title() const; int cdNumber() const; track getTrack(int trackNum) const; int size() const; //--iterator functions void first(); void next(); bool isDone() const; track currentItem() const; private: vector <track> my_data; int my_index; . . .

  16. Summary • Team projects and putting things in context helps case studies • Students design when • select classes and responsibilities the architecture • consider design heuristics and patterns • Object-oriented design is a natural, doable way to introduce design • Given the chance, Freshman can design

More Related