Lecture Notes for CS 383 Software Engineering I

Read Syllabus

Today we start the text, chapter 1. There were copies of the text in the bookstore last I checked.

Introduction to Software Engineering

What does "software engineering" really mean? A good fraction of expert computer scientists say this term is a misnomer. This course is really about: tools and methods that are useful for larger-scale software development projects.

Course Perspective

I agree strongly with Bernd Bruegge that you learn by doing, and that you learn more and better by doing a larger project than you could do by yourself or in a small group.

Ideally this course would cover the entire software lifecycle, and you would learn hard truths about coming into a project during the middle of development. You would have to read and understand others' documents, ask questions until it makes sense, and make an important contribution in a short span. In practice, it is hard to achieve this in a university setting. Don't expect this knowledge to come without a price, whether you learn it here or on the job someday.

What I Learned from Last Year

The customer got something real interesting, it just didn't look very much like what the students were assigned. In order to avoid this discrepancy, some changes are needed.
More leadership
Both instructor and student leadership. Less democracy and chaos.
Early rounds of coding needed to feed design process
Spiral not waterfall.
Competition
Large teams. Two of them. Shared Assets.

External Inputs

Agile
HP suggests test-driven development.
Multi-core
Because it's there. On server, 4 or more cores. On client, 2 or more.

Things Learned in Previous Years of Teaching Software Engineering

  • Design is more difficult than coding
  • Communicating and committing are more difficult than technical issues
  • Integration is more difficult than designing and coding your own stuff
  • All modern OO languages have ugly "warts". There is a "semantic gap" between clean OO as seen in designs, and the "OO" provided by programming languages.

    Discussion of this Year's Project Topic

    CS 383 has a delightful set of contradictory requirements
    Project needs to be the "right size and shape".
    Bigger than you can do on your own. Small enough we can complete it, at least somewhat.
    Project should be Interesting and Fun
    By definition, that means it uses networking and graphics a lot
    Project can require no prior expertise on networking and graphics
    Those classes are not prerequisites. Consider this a warmup.
    Last Year's Topic Burned me out a Bit on Java/Webby stuff...
    And it will be harder to do interesting things with multicores there.
    I am a Gamer, but...
    There is a separate class or two for that.
    Strong External Forces on the class
    We need to cover accreditation-required mainstream SE topics
    Strong External Forces on Dr. J
    Publish or Perish. Sponsor obligations. Dr. J's CVE deliverables.
    Lecture 2

    Good News / Bad News

    From a Math Professor via Bruce Bolden:

    Good news: the program I'm working on for my computer science homework compiles.
    Bad news: That's about all it does.
    The Expert says: We in industry call this "code reviewed by GCC".

    The Core Problem: Complexity

    Over time, this means: change. What complexity? This refers not to the asymptotic time and space complexity of a code, although they are a crucial part of it, but its complexity to humans trying to build or maintain software. There are dimensions to it: static vs. dynamic, and control vs. data

    Famous software "engineering" failures

    What ones do you know of?

    What does software engineering really consist of?

    Coding and Testing
    we knew about this part already; much of SE comes before it
    Knowledge acquisition
    learn the application domain the software deals with
    Modeling
    reducing application domain to a discrete, computable approximation
    Problem-solving
    overcoming many surprises along the way
    Rationale
    explaining why we are doing things this way and not that other way
    Documenting all of the above
    for both internal and external parties, with different needs and vocabulary

    Project Discussion.

    Discussion of the ICU MUD Project. Lecture 3

    Happy Labor Day

    Try to remember not to come to class this coming Monday. See you next Wednesday. Hint: do not put off your homeworks until the night before they are due!

    Teams: C++ and Java

    Let's all get acquainted.
    C++ Java
    Jon Stoker		Constantine M.		Cliff Clark
    Cody Miller		Usman Loum		Ben Daly
    Thor King		Travis Weingart		Ben Adler
    
    
    Kazunori Matsuura	Ben Blaker		Roseanne Sands
    Jesse Brent		Jess Smith		Stephen Tutton
    Creg Empey		Lavanya Mynam		Raymond Chau
    

    HW#1

    Major SE Concepts

    Participants and roles.
    Typically: client, user, manager, developer, artist, content creator, technical writer... Really, there are many kinds of "developers", only some of whose job is conventional coding. User interface designer, database designer, system architect, network protocol designer...
    Work Products
    Specification, operation manual, status report, test manual, source code, database, configuration/build/install scripts...
    Activities, tasks, and resources.
    Requirements: functional and non-functional.
    Notations, methods, and methodologies.

    Major SE Activities

    Requirements Elicitation
    Problem specification, use cases, feasibility, project planning
    Analysis
    Model the problem domain
    System Design
    Model the major elements of the solution. Processes and their communications, classes and their relationships.
    Object Design
    Model the details. Class instance data, methods, and interactions.
    Implementation (CS 384)
    Code
    Testing (CS 384)
    Find bugs, validate

    Managing Development

    Communication
    Tools, standards, rules of engagement, principles of authority
    Rationale
    Evaluating alternatives, making and remembering decisions
    Software configuration management
    Tracking changes, porting, build and install tools
    Project Management
    Oversight, budgeting, scheduling
    Software Lifecycle
    Shipping the software is only the beginning

    Lecture 4

    Introduction to Software Lifecycles

    Note: material here is from Chapter 15, it is not yet assigned reading.
  • Know your Waterfall Model and your Spiral Model, they are fair-game on tests.

    Some quotes on tools, relevant to software engineering

    Software development is like war:
    "We shall not fail or falter; we shall not weaken or tire. Neither the sudden shock of battle nor the longdrawn trials of vigilance and exertion will wear us down. Give us the tools and we will finish the job." -- Sir Winston Churchhill
    Do you only need one or two tools?
    "An apprentice carpenter may want only a hammer and saw, but a master craftsman employs many precision tools. Computer programming likewise requires sophisticated tools to cope with the complexity of real applications, and only practice with these tools will build skill in their use." -- Robert Kruse

    Why is Software Engineering Crucial?

    Because the larger a program gets, and the more features you add, the more bugs you get. Why? Because things get too complex for us to handle. Until we can solve this unsolvable puzzle, Moore's Law is limited or revoked by our inability to utilize hardware, just as we are unable to utilize our own brain (wetware).

    Belady-Lehman observed:

    [D. Berry, The Inevitable Pain of Software Development, Monterey Workshop 2002]

    So, Software Engineering is All About Pain

    Software Engineering, it turns out, is mainly about pain. Dan Berry, one of software engineering's luminary founding fathers, had this to say about software engineering methods:
    Each method, if followed religiously, works. Each method provides the programmer a way to manage complexity and change so as to delay and moderate the B-L upswing. However, each method has a catch, a fatal flaw, at least one step that is a real pain to do, that people put off. People put off this painful step in their haste to get the software done and shipped out or to do more interesting things, like write more new code. Consequently, the software tends to decay no matter what. The B-L upswing is inevitable.
    Dr. Berry goes on to give the following examples:
    Software Method Pain
    Build-and-fix doesn't scale up
    Waterfall Model it is impossible to fully understand and document complex software up front
    Structured ProgrammingChange is a nightmare: patch or redesign from scratch
    Requirements EngineeringHaggling over requirements is a royal pain.
    Extreme ProgrammingWriting adequate test cases is a pain
    Rapid Prototyping We can't bear to throw away the prototype!
    Formal Methods Writing formal specification, and verifying it, may be a pain. Changing requirements is definitely a pain.
    Code inspections Documentation prep for inspection is a pain; nobody wants to be inspected.
    "Daily Builds" Testing, regression testing, and possibly reworking your latest change to not break someone else's latest change is a pain.
    My goal for this course is to maximize your learning while minimizing your pain.

    Introduction to UML

    Read Textbook Chapter 2 if you have not already.

    UML stands for Unified Modeling Language. A "modeling language" is not a programming language, although some efforts have been made to "compile" UML diagrams down into code. UML was created when 3 very successful software engineering diagramming gurus banded together to wipe out the other 12 software engineering gurus. Actually, there was a serious need to create a common notation; prior to that, software engineers that worked with one guru's diagrams might not easily be able to read or understand software designs drawn by another software engineer who had been trained using another guru's diagrams.

    Chapter 2 of Bruegge gives an overview of UML, featuring 5 common kinds of diagrams, starting with use case diagrams, which are the type we will study first.

    use case diagrams
    document how human users and other "external entities" perform tasks using the software system that is to be built.
    class diagrams
    document major application domain entities whose representation in the system will include state and behavior. These diagrams document the associations, or relationships, between classes. At implementation time, there may be many implementation classes in addition to whatever classes are written to correspond to domain classes and domain class relationships.
    interaction diagrams
    depict dynamic behavior and communication between objects. Generally more detailed elaborations and special cases of the "relationships" from class diagrams.
    statecharts
    These are finite automata, with software engineering semantics added. There are states, events, and behavior that goes on during states or events.
    activity diagrams
    flowcharts and similar diagrams in which the elements depicted represent the execution of a sequence of instructions.

    Lecture 5

    Here's the CS Lab FAQ

    Check it out; it provides some useful information on our current labs.

    Team Assignments

    Nutter: Java
    Fischer: C++, Naresh Vinukonda: C++

    "That was Easy..."

    Extended discussion of hw #2 and class project.

    SVN and Version Control

    SVN stands for "Subversion", which is really just a cutesy name for this excellent revision control system. SVN is almost an improved clone of a popular system called CVS, and much of this discussion could apply to both of those systems interchangeably, but SVN is a little newer and better. It is a software version control system, whose primary function is to aid in the coordination of programmers on large projects. Compared with earlier tools SCCS (source code control system) and RCS (revision control system), SVN offers some significant advantages: For these good technical and political reasons, SVN will be our source code control system of choice.

    Major SVN Commands

    SVN works using a "repository" which is a database for source files.

    Unless you are creating your own repository, the first command you need is

    svn checkout projectname
    
    which grabs a copy of a named project from the repository. The various svn commands that manipulate the repository have the syntax
       svn command [filenames...]
    
    The other commands you need immediately for SVN include:
    svn diff [filenames...]
    Show any differences between your file and the version in the repository
    svn update [filenames...]
    Merge in any changes others' have committed to the repository. If you have changed lines that others have changed, the conflict is reported and both copies of the changed lines are left in for you to merge by hand.
    svn commit [filenames...]
    Merge your changes into the repository.
    svn log [filenames...]
    Show history of changes that were made to a file or files.
    There are many other SVN commands, and command-line options, that you may find useful; read the manuals! One option of special interest is -r tag which let's you ask for older versions from the repository instead of the current version. This may help if the current repository gets broken. :-) Use it with care, however; when you go back to an earlier version, the repository doesn't think any changes you make apply to the current version.

    Similarly, there are "gotchas" to avoid if you have to move a directory around in the SVN repository. One student just did a "mv" and then was stuck in a "eternal SVN conflicts from hell" mode, until he found out he needed to do new "svn add" commands for the directories at their new locations. His GUI client interface (Eclipse) allowed him to get into this mess and failed to warn / prevent it... So be careful: you have been warned.

    Lecture 6

    Announcements

    Big Concepts from Bruegge Chapter 2

    Use Cases and Class Extraction

    You can identify classes from a software specification document by looking for "interesting" nouns, where interesting implies there are some pieces of information to represent in your application, and operations to perform on them. You can also identify classes by developing use cases from the specification document.

    Lethbridge defines a use case as:

    A use case is a typical sequence of actions that an actor performs in order to complete a given task.
    I would say: use cases are formatted descriptions of "discrete" tasks. By "discrete", we mean an individual standalone thing a user does while using the system.

    If you look through the tasks mentioned in a specification document, you can identify a set of candidates. Example candidate tasks for a "wargame":

    Example candidate tasks for a Parker Brothers game called Monopoly:

    Entire books have been written about use cases. Use cases are also described in Chapter 11 of the Unicon book; some of today's examples may be found there.

    Terminology

    actor
    role that an external entity plays in a system
    use case (or just "case")
    depiction of some aspect of system functionality that is visible to one or more actors.
    extension
    a use case that illustrates a different or deeper perspective on another use case
    use
    a use cases that re-uses another use case.

    Now we will expand on the discussion of use cases, use case diagrams, and look at examples.

    Use Case Descriptions

    Drawing an oval and putting the name of a task in it is not very helpful by itself, for each use case you need to add a detailed use case description. Your first homework assignment is to "go and do this" for your semester project.

    Section 7.3 of the text explains the format of use case descriptions. Each use case has many or all of the following pieces of information. The items in bold would be found in any reasonable use case description.

    Name
    The name of the use case.
    Actors
    What participants are involved in this task.
    Goals
    What those people are trying to accomplish.
    Preconditions
    The initial state or event that triggers this task.
    Summary
    Short paragraph stating what this task is all about.
    Related use cases
    What use cases does this use case use or extend? What uses/extends this use case?
    Steps
    The most common sequence of actions that are performed for this task. Lethbridge divides actions into two columns: user input is given in the left column, while system response is given in the right column. The two column format is optional, but saves on paper and may improve clarity. The steps are numbered, so there is no ambiguity in using both columns on each line.
    Alternatives
    Some use cases may vary the normal sequence of steps.
    Postconditions
    what does this task produce?

    Lecture 7

    Today we continue our discussion of use cases, but first, some perspective!

    Requirements Elicitation Techniques

    Purpose: produce a requirements specification document. Identify functional and non-functional requirements (F+URPS) (Completeness, Consistency, Correctness). Focus on the users' view of the system, NOT the internals. Identify actors, scenarios, use cases. Refine and relate use cases.

    Scenarios

    Before there were use cases, there were scenarios. A scenario is a narrative description of what people do and experience as they try to make use of computer systems and applications [Carroll]. Scenarios may describe a current way things are done, a proposed way that a future software system should do them, a method of evaluating a system, or a method of training a user on a system.

    From Scenarios to Use Cases

    A set of scenarios may include many different instances in which the user is really performing the same task; these get merged into a use case. Use cases typically contain a primary sequence of steps performed in common by any scenario in which the user is doing that task, plus a number of exceptions or alternatives. See the simple use-case writing guide on page 137.

    Use case descriptions, examples

    A simple generic use case for a "file open" operation might look like:

    Open File

    Summary: A user performs this task in order to view a document. The user specifies a filename and the document is opened in a new window.

    Steps:

    1. Choose "Open" from the menu bar.
    2. System displays a File Open dialog.
    3. User selects a filename and clicks "OK".
    4. System closes the dialog and opens the file in a new window.

    Alternative: If the user clicks Cancel in step 3, no file is opened.

    Lethbridge-style two column format is nicely motivated in the following example, which has enough steps to where two columns saves enough space to matter. When you start having trouble fitting the whole use case description on a page, there are substantial benefits to a compact format.

    Exit parking lot, paying cash

    Actor: car driver

    Goal: to leave the parking lot

    Precondition: driver previously entered the parking lot, picked up a ticket, and has stayed in the lot long enough that they must pay to leave.

    Summary: driver brings their vehicle to an exit lane, inserts their ticket into a machine, and pays the amount shown on the machine.

    Related use case: exit parking lot, paying via credit card.

    Steps:
    1. Drive to exit lane, triggering a sensor. 2. System prompts driver to insert their ticket.
    3. Insert ticket. 4. System displays amount due.
    5. Insert money into slot until cash in exceeds amount due.   6. System returns change (if any) and raises exit barrier
    7. Drive through exit, triggering a sensor. 8. Lower exit barrier

    Alternative: User crashes through exit barrier with rambars on front of truck in step 1. (just kidding)

    The following example (by Lethbridge et al) gives you one more look at use case descriptions. This one is for a library management application.

    Check out item for a borrower

    Actor: Checkout clerk (regularly), chief librarian (occasionally)

    Goal: Help the borrower borrow the item, and record the loan

    Precondition: The borrower wants to borrow a book, and must have a library card and not owe any fines. The item must be allowed for checkout (not on reserve, not from reference section, not a new periodical, etc.)

    Steps:
    1. Scan item's bar code and borrower's library card. 2. Display confirmation that the loan is allowed, give due date.
    3. Stamp item with the due date.
    4. Click "OK" to check out item to borrower. 5. Record the loan and display confirmation that record has been made.

    Alternative: the loan may be denied for any number of interesting reasons in step 2 (see preconditions).

    Now, ask yourself: why is Dr. J convinced that use case descriptions are a vital software engineering job in the initial stages of requirements analysis? The first person to tell me can stop by for a delicious San Saba chocolate covered almond in my office.

    Use Case Diagrams

    One reason to do a use case diagram is to summarize or catalog what tasks are part of the system; a sort of table of contents for the beautiful set of use case descriptions that you should write. But the main reason use case diagrams exist is in order to show who does what, when different users (actors) participate in different (overlapping) tasks. If you only have one actor, or there are no tasks in which multiple actors interact, there may be no reason that you have to do a use case dialog.

    Consider the following figure from a book by Lethbridge.

    There are three actors (Registrar, Student, Professor), and there are five use cases. The "Find information about course" use case is vague and probably the three actor types can find out different information from each other. They are not typically involved in the same instance of finding out information about a class, so the example could be better.

    The next figure illustrates a bunch of more exotic use case diagram items, namely actors and use cases that use or extend other actors and use cases.

    Given that UML is a diagramming notation, its ironic that the main thing about use cases are the use case descriptions. It is easy to omit one interesting category of actor in use case diagrams, namely: external system actors. A computer program may interact with external entities that are not humans; they may be remote database servers, for example.

    The Bruegge textbook, as well as Figures 11-1 and 11-2 of the Unicon book give some more examples of use cases.

    Lecture 8

    Announcements

    ssh+svn tricks.
    This part is different than how CVS does it, so I am having to learn along with you.
    Group name: cs383_svn created, but our sysadmin Larry has this to say:
    An old account existed for Benjamin Blaker that I was able to move forward,
    so I reset his password and notified him.  I was able to create a new
    account for Yik Chun Chau and I sent notification of the account (login) and
    password.  I was unable to create or find accounts for Roseanne Sands and
    Stephen Fischer. If you can find out the VandalWeb IDs (ala abcd1234) I can
    create accounts for them and notify them.
    
    It is possible some of the students have not tried to log onto wormulon yet,
    so they may not know if their passwords work. If they can't get on - just
    have them send me an email and I'll reset the passwords.
    

    Lecture 9

    Lecture 10

    Lectures 9 and 10 by Ziad.

    Lecture 11

    Lecture 11 was spent by students working in groups on requirements analysis.

    Lecture 12

    Where we are at: you are finishing up and turning in your first pass at requirements analysis. As of 11am, 7 people had added their names to the svn repository. We need to move forward with some lecture material; there will be another round of requirements analysis, after some feedback, for you to refine your ieas.

    Overview of Projects

    Software engineering applies to small projects, but matters more for big projects.

    Consider Figure 3-2, one of the dumbest statecharts I have ever seen. Still, it conveys information about major project phases.

    Project Communications

    Team Organization

    Hierarchy vs. peer-based vs. liaison-based organizations. How do teams talk to other teams?

    Roles

    Examples: system architect, object designer, implementor, tester... There are different kinds of roles, which relate to management, development, cross-functional, and consultant responsibilities.

    Schedule

    This is harder than just developing a linear sequence: in a large team effort, multiple things must be developed in parallel, and various tasks cannot be started until others are completed. Gantt and PERT charts are two ways to present this information, one with a strong horizontal time axis, and one without.

    Analysis - What Else Besides Use Cases

    This week we are moving on into Object-Oriented Analysis. Having studied the application domain (well, some of you have), it is time to produce an analysis model. "Structure and formalize the requirements".

    The analysis model is sometimes viewed as a three-part chorus: "functional model", "object model", "dynamic model".

    At this phase, we start talking about objects in more detail, still focusing on the application domain, not the implementation. Domain objects can be classified into three general categories: entity, boundary, and control. You can use <<stereotypes>> to identify a class' category. Alternatively, you could color code them or group them physically, maybe separating the categories using dashed lines or some such.

    Identifying Entities

    Red flags:

    POSModelExample
    Proper nouninstance Alice
    Common nounclassField officer
    "Doing" verboperation (method)create, submit, select
    "Being" verbinheritanceis a kind of, is one of either...
    "Having" verbAggregationhas, consists of, includes
    Modal verbconstraints must be
    Adjectiveattributeincident description

    Boundary Objects

    Red flags:

    Control Objects

    Coordinate boundary and entity objects. "Manage" the forward progress through a use case. One control object per use case, or maybe per actor in the use case.

    Sequence Diagrams

    Kind of redundant with use case descriptions, but the shift in perspective often identifies additional classes and methods. See figures 5-8 through 5-10 (Bruegge).

    CRC Cards

                        class                    
    responsibilities





    collaborators





    Exercise: how many use cases can we identify in our project? Write some example use case descriptions based on that.

    Lecture 13

    Class Diagrams

    Class diagrams are the "meat and potatoes" of object-oriented analysis and design. We will begin our discussion of them today, and continue next week. Class diagrams describe more detailed, more implementation-oriented things than use case diagrams.

    Class diagrams can present varying levels of detail about the classes in them. Some class diagrams may have nothing more than the class name for each class; others may hold the full list of fields and methods. When more space is taken by class details, there is room for fewer classes per diagram, so you often have "overview diagrams" that show many classes and their connections, supplemented by "detail diagrams" that show more information about closely related classes.

    Associations

    Perhaps the main purpose for class diagrams is to identify and depict relationships between objects that will be needed in the running system. An association is the word we use for such a relationship. We draw a line between the rectangles for classes to depict an assocation. There are three major types of associations:
    inheritance
    aggregation
    user defined

    Inheritance: the Un-Association

    We have discussed how inheritance is not really an association, it is a relationship between kinds of things, in the design and maybe in the programming language type system, whereas associations are relationships between instances (objects) at run-time. Inheritance is so vital that many class diagrams focus specifically on a large inheritance class hierarchy, similar to a biological taxonomy of species. Inheritance is usually a static feature of a design, although there exist languages in which instances can change who they inherit from at runtime.

    Here is an example class hierarchy from the Lethbridge book (chapter 2):

    Aggregation: the Simplest Association

    Aggregation, the parts-whole relationship, is perhaps the most useful association of all of them. Many many complex things are made up of an assembly of simpler items. There are at least two flavors of aggregation, static and dynamic. Static aggregation is lifelong aggregation; the parts cannot exist apart from the whole, or enter or leave the whole. Dynamic aggregation is more like a team whose members can come and go. Here is an example of a massive chain of aggregations with a familiar theme:

    Association Details

    There are many details added to associations to show more information about the relationship. Some of these details are discussed in Chapter 5 in your text.
    link
    just as classes have instances at runtime called objects, associations have instances at runtime called links. Links occasionally are so important and complicated that they need their own attributes. The main information about them is usually their lifetime, and what instances they are connecting.
    multiplicity
    a.k.a. cardinality, it is the number of object instances per link instance in a given relationship
    qualifier
    some many-to-one relationships have a unique key used to traverse the association.
    roles
    the different ends of an association may have differing roles associated with them. Especially useful if both ends of an association connect the same class.
    composition
    there is a special kind of aggregation called composition, which denotes aggregations in which the component parts have no existence apart from the whole thing. The relationship is hardwired, static, or constant. Composition is marked using a filled diamond; hollow diamond means a regular (transitory, or dynamic) aggregation.

    Here are some more class diagram figures from some old software engineering text (Pfleeger). One point here is that it is logical to start with a simple sketch of classes and basic relationships, and add many details later on.

    As a larger example of class diagrams and associations, consider a previous semester's project. They produced two, overlapping class diagrams, one focusing mainly on cards and card decks and one focusing on characters, units, and the map. We can look at these two diagrams and consider what they did right, what needs to be changed for the campaign game. We can also work, as an example, some of the classes and relationships for the Monopoly game.

    User-defined Association Examples

    Here is an association you might see in a human resources application:
    Person
    employee                 employer
                    Works-for
    Company

    What are some example instances of this association?

    Here is a more detailed version of that association:
    Person
    name
    SSN
    address
    salary
    job title
    employee                 employer
    *               Works-for
    Company
    name
    address

    There is a multiplicity, since many people may work for the same company. But what if a given person works for more than one company?

    Here is an association you might need for a geography application:

    Country
    name
    Has-capital
    City
    name

    Now, what are some examples of this association? Give me some instances -- and their "links". To include more information in this association, we need to know:

    Statecharts

    A statechart, or state diagram, depicts dynamic properties of a system. See p. 276 of the text. A statechart consists of
    a set of states
    drawn as circles, ovals, or rectangles, with a label or number inside.
    a set of transitions
    drawn as arrows from one state to another.
    a start state, and a set of final states

    Some of you may be getting an eery sense of deja vu at this point. Statecharts are a non-trivial extension of finite automata, because they have:

    instead of "input symbols", events associated with transitions
    these may be complex, synchronous or asynchronous
    events may have conditions, drawn inside square brackets
    activities

    Lecture 14

    SVN Woes ... and Practices

    Statechart Diagram Examples

    Lecture 15

    Announcements

    HW clarification

    HW #3 really is due Monday October13. However, given the large amount of time I am giving for it, I'd like some good class diagrams, and don't anticipate giving you feedback and a re-do after October 13. I'd like everyone to do some class diagramming, enough to pass your midterm. You are strongly encouraged to (a) critique and help your teammates make your team's class diagrams the strongest set you can muster, and (b) run your class diagrams past Dr. J (via e-mail or in person) prior to the final submission, for preliminary feedback and suggestions.

    More Class Diagram Examples

    If you google or UML class diagram examples, you will come up with lots of links like the following which maybe useful in coming to terms with UML class diagrams. However, the main way to get used to them is to practice them yourselves, which we will do in class today.

    Lecture 16

    Comparing the C++ and Java team's Requirements Analysis Documents

    Attribute Java Team C++ Team Winner / Notes
    Pagecount 28 pages 48 pages. C++
    Titlepage yes sort of Java (better logo needed)
    Record of changes yes no Java (but granularity issue)
    Name JMUD Wellspring C++ (but why this name?)
    References 6 6 need main UML reference
    Product Perspective so-so so-so Need more / real perspective
    Functions bullet list paragraph Unclear, sketchy
    Constraints bullet list hooey Java
    Site dependencies sketchy reasonable C++
    Packaging and delivery "whichever" "on CD's" need strategy for packaging and delivery to public
    User Interfaces screenshot table Java. Need prototype and details, think about usability
    Section Numbering ok jumped shark at 2.6.11 Java
    External interface requirements awol incomplete C++
    Use case Diagrams 4, good, 1 major complaint 4, good, 2 major complaints
    Use case Descriptions 16 39 C++

    More Statechart Examples

    Next week we will work on statechart examples relevant to your semester project.

    Ethics and Social Implications of Computing Technologies.

    Review papers at Dr. J's CS Ethics page.

    Goldwater

    Outstanding sophomores and juniors should be aware of the Barry M. Goldwater Scholarship. This is a national scholarship that supports undergraduates who are majoring in the natural sciences, math or engineering. The award amount is for up to $7500.00 to pay for the final year or two of undergraduate education. This is also a scholarship that UI students have been quite successful in winning in recent years. If you are an outstanding student please consider submitting an application. NOTE: the internal deadline for applications is Monday, November 12th. Additional information on the Goldwater Scholarship is available at:
    http://www.uidaho.edu/honors_program/UIgoldwaterinfo.htm

    When is Open Source, not really Open?

    Compare major open source licenses. GPL, LGPL, BSD, MIT, etc.

    Homework Comments (from past years)

    Lecture 17

    Excerpts from Software is Hard

    Introduction to System Design

    Read Bruegge Chapter 6!

    The line between analysis and design is a gray one. Broadly, requirements analysis was supposed to focus on what the software should do, while design should figure out how to do it. In our project, we are still figuring out our requirements, but we need to work out a design. The best we can do is: resolve any conflicts in currently-proposed requirements, make any pending decisions, document what we've identified and agreed on at this point, and call that our requirements document, realizing that it may have fatal flaws of omission or commission.

    Bruegge says that our next job is to identify design goals, establish an initial subsystem decomposition, and refine that subsystem decomposition until all design goals are satisfied.

    Design Goals

    Bruegge is not especially helpful here, stating that some design goals come from the nonfunctional requirements, and some emerge from further discussion with the client, and that they all need to be written down. The nonfunctional requirements are already written down. The client is not a software designer, what do they know about it? We need to think "outside the text" a minute here.

    Subsystem Decomposition

    What exactly is a subsystem? The amount of work a single developer or team can produce? This idea from Bruegge seems bad on the face of it. The subsystems should address relatively separable or independent elements within the overall system; it should be logically driven by the requirements or our ideas of how to meet those requirements. But it is the case that one of the consequences of subsystem decomposition is to identify pieces that persons or teams can focus on in detail.

    A subsystem is characterized by what services or interfaces it provides to the rest of the application.

    Object Oriented Design: Adding Detail

    You can view object oriented design as a process of adding detail to class diagrams. We will look at as many examples of this process as we can.

    For detailed design, we need to reorganize/regroup and assign teams to go into the details of various aspects of content delivery and activities.

    We should divide the labor right now for work on design, adding details and corrections to your project analysis, and merging ideas you find in other folks' homeworks #2-3.

    Make sure your names are on any submitted course documents. In fact, I need to know who did which parts of which documents, so I don't lump everyone together under the same grade. If you are asked to prepare part of a document you don't understand, better ask your classmates and/or instructor what is needed for that part.

    Vertical and Horizonal Teams

    Last class we identified major technical categories (UI, database, etc.). Dr. J mentioned the possibility of organizing around functional tasks instead, each team being responsible for a set of related use cases.
    Administration team (MikeB, BrandonArp, RusselF, ChrisS, Serge)
    account creation and management, user and teacher reporting
    Navigation team (Justin, JoeyG, DanM, Trevor, AnthonyK)
    integration / user interface / map / activity selection
    Library skills team (DeanT, AndrewG, JosephE)
    develop content / activities / NPC's related to library skills
    Data (tutorial) team (MarkC, ChrisF, KaneG)
    develop content / activities / NPC's related to binary representations
    Algorithms team (AlexO, Curt, KC, Shruti, BrandonM)
    develop content /activities / NPCs related to logic and sequencing of algorithms and problem solving
    Help / chat team (NateE, BenS, Patrick, BennyH)
    develop automated and human-based help and chat communications

    User Interface Design

    By the next round of turnin, we will need to establish a fairly complete user interface design for things like the main screen. User Interface Design is the subject of an entire course (CS 485) and for our purposes we will have to settle for a rudimentary and primitive introduction.

    User interface design starts from what tasks/activities the application is to support. You probably will discover a few tasks in this phase that requires a dialog for a task we haven't identified previously. But mainly we need to design dialogs and sequences of actions to perform specific tasks in use cases.

    Aspects of User Interfaces

    look
    this is the most obvious part of user interface design, but not the most important part
    feel
    this is like: what clicks perform what operations. how many clicks does it take. does it feel like you are directly manipulating the objects on the screen, or does it feel like you are following a long sequence of orders you receive from the program.
    metaphors
    users can quickly learn an unfamiliar task, or quickly interpret an unfamiliar graphic, if a familiar metaphor is used. Examples: "desktop metaphor"
    mental model
    a user interface provides the user with a particular mental model of how they view the system. designing that model will determine many aspects of the user interface (what info to show, what tasks to support)
    navigation rules
    navigation through large structures which don't all fit on the screen is a central issue for many (most) applications.

    A few Obvious User Interface Tips

    1. Minimize # of clicks for common tasks
    2. Provide all the information that's needed on a single screen
    3. Strive for "direct manipulation"
    4. Modeless is usually better than modal
    5. Be familiar and consistent with other applications

    Lecture 18

    Interpersonal Communications: Some Rules of Engagement

    1. Respect your classmates, even when you disagree or they are wrong.
    "Treat others the way you would like to be treated" - Jesus. I am not impressed, and will not tolerate for long, group "leaders" who disrespect their teammates publically. If you have a problem with one of your team member's contributions, discuss it with them privately. If you cannot resolve it through polite discussion with the individual, discuss it RESPECTFULLY within your group, and if there is a problem that can't be resolved internally, see me. Part of your grade will be based on whether I determine that you respected your classmates or not.
    2. Accept group decisions even when you disagree.
    "The Needs of the Many Outweigh the Needs of the Few...or the One" - Spock. There has to be some mechanism for making decisions, whether it is democracy, dictatorship, or whatever. Those decisions should be made based on what's best for the group, not what makes an individual look good.
    3. You must include all group members in decisions.
    I want to hear no more team members who are surprised about something that affects them.
    4. You should do your best to contribute to your team.
    "From each according to his abilities" - Marx. The easiest way to fail this course is to not contribute to your team. If you do your best, make your contribution, and the team discards it, that is not your problem or fault. If you don't do your best to help your team succeed, don't be surprised at the grade you get.
    5. E-mail is not a good medium for resolving problems.
    I have found through many long years that e-mail does not work well at conveying emotions. Using e-mail to try to resolve problems can easily make them worse. Of course, sometimes you have no choice, but basically e-mail is easily misinterpreted. Human faces and intonation are lost, and people do not type as well as they talk. When there is a problem, your best bet is to e-mail to setup a meeting to discuss it. Your next best bet is to think, and rethink, what you are planning to send by e-mail. Ask: how will this person react to this e-mail? Have I respected them? Will they understand my situation? Will they feel I am attacking them, or trying to help?
    Example of how not to use e-mail for interpersonal communications:
    From: ralph
    To: cjeffery
    Date: Wed, Apr 22
    Subject: Carping

    I'm more than a bit tired of beating you about the ears in hopes that you'll rearrange your priorities, work habits, or whatever it takes to get your research on track.

    I'll assess the situation in a couple of weeks. If I'm still not satisfied with your progress, I'll put it in writing.

    This e-mail may have accomplished a certain motivational goal, but it did not improve the working relationship between sender and recipient.

    Why are interaction and collaboration diagrams useful?

    These UML diagram types help connect the use cases and classes. Each scenario (== sequence of steps for a use case description) can lead to a collaboration diagram. The collaboration diagrams in turn help identify missing classes, methods, and associations for class diagrams.

    Lecture 19

    Design Buzzwords and Vague Concepts

    Here are some buzzwords and ideas that relate to design:

    Design methods

    1. modular decomposition
    top-down breaking up function into parts
    2. data-oriented decomposition
    top-down breaking up information into parts
    3. event-oriented decomposition
    identifying what changes are to be made, and when they occur
    4. outside-in design
    blackbox I/O orientation
    5. object-oriented design
    relationships between data

    Things that get designed

    1. Architecture
    interaction between programs and their environment, including other programs
    2. Code
    algorithms and data structures, starting with equations, pseudocode, etc.
    3. Executable/package
    how is this system going to be installed and run on user machines?
    Common architectures Pipes, layers, client-server, peer-to-peer, ring ...

    Some common breakdowns

    Lecture 20

    Team Meeting Day: Wednesday

    Please turn in an attendance sheet. Friday will be a guest lecture on the collaborative virtual environment, given by Mr. Hani bani-Salameh.

    "Good" Design

    Low coupling
    Coupling refers to the interdependences between components. Components need to be as independent as possible. The book defines many kinds of coupling, including content coupling, control coupling, stamp coupling, and data coupling.
    High cohesion
    Cohesion refers to the degree to which a component is focused and connected internally (it is almost "internal coupling"). Bad cohesion has a single component doing unrelated tasks. Bad cohesion may coinside with lots of duplicate code (same thing repeated with slight changes for different tasks). The book defines levels of cohesion: coincidental, logical, temporal, procedural, communicational, sequential, functional.
    Minimal complexity
    There are several types of complexity, but in general, complexity is bad, and the goal is to minimize it while meeting requirements. Most of the complexity measures that are out there measure the complexity of code, but we are talking about design right now. Designs that are complex, or designs that poorly address the application domain and requirements, lead to complex code. Bad programmers can of course create complex code from even good designs.

    Good/Bad Design Examples

    Comments on Homework

    Homework #5 submissions are posted.
    Are you a team?
    Did you meet with your team enough to sew your homework #5 together into a coherent document? Division of labor is great, but integration is harder and equally important. It will be part of your grade on future team homeworks from now on. It requires scheduling and not everyone-goes-and-does-their-part-the-night-before-its-due.
    Produce a readable document
    I have to be able to read your hard copies, I really mean it! If you can't format your diagrams to fit the page, or print a lot of text so small I can't read it with my glasses on, or don't have enough toner in your printer: fix it.
    Produce an editable, electronic document
    Hand-drawn sketches are welcome. Whose job is it to scan them in so that they are part of the project ? .jpg or .pdf files are welcome. For us to be able to edit, we need the .dia or other source files used to produce the .jpg or .pdf if there are any.
    Avoid "buzzword infection"
    Students learning software engineering or UML are exposed to many new terms. When writing software engineering documentation, keep the technical buzzwords out of your application domain descriptions unless they really belong there. Example: in use cases you learn about actors, so in your descriptions of the application domain, the word "actors" starts being used to refer to many non-actor things.

    Lecture 21

    Design Patterns

  • Reading:

    Design Patterns Background

    Design Patterns were invented in homage to architectural patterns, specifically the work of Christopher Alexander. Their initial introduction for software design, in a book by Gamma, Helm, Johnson and Vlissides in 1995, had an electrifying effect: suddenly it was no longer possible to talk about software design without referring to as many of the patterns as possible. A whole mini-industry and cult sprang up around the task of specifying as many patterns as possible. Of course, most of those patterns are not very useful.

    The original design patterns book described in detail 23 reoccurring patterns in software, divided into three main categories: creational (5 patterns), structural (7 patterns), and behavioral (11 patterns). Each pattern is described exceedingly well in prose and outlined in a UML class diagram, after which example implementations are sketched in C++ or Smalltalk. Within all three categories a great deal of similarity can be observed, such as the heavy use of abstract classes; enough to suggest the existence of meta-patterns.

    The design patterns fad has died down, but the concept of design patterns has been thoroughly institutionalized by the software engineering community.

    What is a Design Pattern?

    Minimalist Definition

    A quad-tuple consisting of:
  • a pattern name
  • a description of what problem it solves
  • a description of the solution
  • an assessment of consequences and implications of the pattern

    Expanded Definition

  • Name and Classification
  • Intent
  • Also Known As
  • Motivation
  • Applicability
  • Structure (e.g. UML)
  • Participants
  • Collaborations
  • Consequences
  • Implementation
  • Sample Code
  • Known Uses
  • Related Patterns

    How Design Patterns Solve Design Problems

  • finding objects - if the pattern says you need one, you need one
  • determining granularity - several patterns address granularity explicitly
  • specifying interfaces - patterns describe part or all of the public interfaces of the classes in them
  • specifying implementations - patterns may include known-efficient code samples
  • code reuse - "design reuse facilitates code reuse"

    How to Select a Design Pattern

    GoF suggest several ways, such as
  • look for which design problem above affects you, then look for design patterns that pertain to it
  • scan all the patterns' Intent sections
  • study how patterns interrelate
  • study patterns of similar purpose - to tell when to use which

    I would just add that, first you familiarize yourself with a bunch of design patterns, and then when doing design you recognize which pattern to use via deja vu.

    How to Use Design Patterns

  • Buy the GoF book, read the pattern in detail
  • Look at the sample code to get a concrete feel for it
  • Apply (translate) the pattern Structure section to your application classes
  • Adapt the sample code when it is appropriate to do so; otherwise write your own

    Design Patterns versus Pattern Languages

    Students of Christopher Alexander were quick to note that the design patterns book is mostly just a catalog of buzzwords and misses the point. Design patterns should be more about the rules for connecting patterns than about the individual patterns themselves, which we mostly already know or could invent when needed. I started getting into this with a mathematician colleague in San Antonio, but then moved to Las Vegas and then Las Cruces, and have been too busy to pursue this to its appropriate conclusion.

    Some Cynical Observations About Design Patterns

  • Of course these were not new inventions, they were a catalog of tried and true methods. That is OK.
  • Design Patterns proponents are trying to create a common vocabulary of buzzwords, to reduce the cost of communication and increase the level of understanding when software engineers are talking with one another.

    Name That Design Pattern

    If we do well enough on this quiz, we have a common vocabulary, and have either already learned design patterns, or don't actually need them.
  • Provide an interface for creating objects without specifying their concrete classes.
  • Separate the construction of a complex object from its representation.
  • Let subclasses decide which class to instantiate for a specified object-creation interface.
  • Specify objects to create using a prototypical instance; create objects by copying.
  • Ensure a class has only one instance, and provide a global point of access.
  • Convert the interface of a class into another interface, expected by clients.
  • Decouple abstraction from implementation, so the two can vary independently.
  • Compose objects into tree structures to represent part-whole hierarchies. Treat individuals and composites uniformly.
  • Attach additional responsibilities to an object dynamically.
  • Provide a single unified interface to a set of subsystem interfaces.
  • Use sharing to support large numbers of fine-grained objects efficiently.
  • Provide a surrogate or placeholder for another object.
  • Give more than one object a chance to handle an incoming message. Pass the request along the chain until an object handles it.
  • Encapsulate a request as an object.
  • Interpret sentences in a language by defining and operating on an internal data structure representation of that language.
  • Provide a way to access the elements of an aggregate object sequentially.
  • Define an object that encapsulates how a set of objects interact.
  • Capture and externalize an object's internal state so that the object can be restored to this state later.
  • Create a mechanism such that when one object changes its state, all its dependent observers are notified and updated.
  • Allow an object to alter its behavior when its internal state changes, appearing to have changed its class.
  • Define a set of encapsulated, interchangeable, algorithms; allow algorithms to vary independently of their clients.
  • Define the skeleton of an algorithm, deferring some steps to subclasses.
  • Represent an operation on elements of an object structure; enable new operations without changing the element classes.

    Lecture 22

    Read the Coplien paper mentioned at start of the last lecture.

    The Patterns

    Our textbook doesn't cover all of the GoF design patterns, it seems to consider some of them to be primary. I think more are valuable and general than what Bruegge covers, but agree that not all are equally important.

    A ton of the examples in the design patterns revolve around the GUI aspects of "a diagram drawing tool" (uniquely relevant for some instances of CS 383, such as Fall08)

    Abstract Factory

    Provide an interface for creating objects without specifying their concrete classes.

    Example: UI Toolkit that can create either Qt or Windows-native components.

    Builder

    Separate the construction of a complex object from its representation so that the same construction process can create different representations.

    Example: an RTF reader might parse input (construction process), producing different representations for different output (ASCII, LaTeX, Wysiwig...)

    Factory Method

    Let subclasses decide which class to instantiate for a specified object-creation interface.

    Example: application framework needs to instantiate classes, but only knows about abstract classes, which it cannot instantiate

    Prototype

    Specify objects to create using a prototypical instance; create objects by copying.

    Example: Toolbar-based applications where you create an instance by clicking on one. The toolbar may be generic framework code. Each button could be a different subclass, but instead attach a different prototype instance to each one.

    Singleton

    Ensure a class has only one instance, and provide a global point of access.

    Example: a print spooler. Highlander quote: "There can be only one".

    Adapter

    Convert the interface of a class into another interface, expected by clients.

    Bridge

    Decouple abstraction from implementation, so the two can vary independently.

    Lecture 23

    Dr. J's "Best of the Rest"

    These may not be covered in Bruegge, but they seem valuable in Real Life, from my personal experience.

    Decorator

    An alternative to subclassing for extending functionality.

    Facade

    Provide a unified interface to a set of interfaces. Can anyone say "DirectX" or "SDL"?

    Flyweight

    Share the constant part in a big pool; reduce the cost of thousands-of-similar-objects. GoF mentions word processor example, but Dr. J has lots of personal examples from the field of compilers.

    Proxy

    A placeholder for another object to control access to it. Networked/remote objects. "Secure" objects. What else?

    Chain of responsibility

    Decouple the sending of a message from who will receive it. Fundamental to concepts such as exception handling, and event-driven programming. Often called delegation.

    Command

    Encapsulate a request as an object. Multiple benefits such as queueing and logging.

    Antipatterns

    Thoughts on Coplien's Paper

  • Emphasis on patterns is analogous to emphasis on associations instead of classes
  • Patterns are about systems, not just individual components
  • Patterns can form "microarchitectures"
  • Patterns can be applied to other areas besides design (process patterns, user interface patterns, teaching patterns, project organization patterns, software process patterns...)
  • Patterns can be "interdisciplinary" among different software areas.
  • Patterns thrive on capturing and articulating points of complexity (no complexity => no need for patterns). OOP needs patterns worse than traditional structured programming because OOP tends to be more complex than structured programming (e.g. dynamic data-driven relationships instead of static code-control-flow relationships).
  • Patterns' immediate ancestor were "programming idioms"
  • Patterns are about people, not houses, or software. The human side is usually about either utility, or aesthetics. Software designs tend to capture API's and data structures but miss nuances of relationships; software process distances itself from unreliable human beings.
  • Human Software Pattern Example: Simply Understood Code

    Lecture 24

    HW#6

    Will be due in a week.

    Lecture 25

    Welcome back from Break

    Dr. J went to London and survived a thrilling barrage of world-renowned sites.

    Weekly Status Report comments

    Offhand, my initial impression is that the weekly status reports will be valuable. They give me an additional back-channel of feedback on what is going on.
    format
    The web form I made up is not all that great. I need to be able to read these really easily. Plain text in the body of the e-mail would be better than an attachment that isn't easily readable because of internal scrollbars. Duh, at least I fixed my war.html form's HTML so that the text areas are no longer these tiny rectangles (I had said "columns" instead of "cols". HTML is not very forgiving.)
    granularity
    If I only get two reports, that's not enough, but some teams would prefer to avoid individual reporting. The point of weekly reports is to tell me what you are doing; probably an upper bound ought to be 2-3 subteam members can submit a joint report on their activities.
    redundancy
    I got many copies of the same report document, with tweaks. I only want one copy, so if you are sharing report text, I want a single submission with all contributors' names on it.
    persistence
    There needs to be a better mechanism for keeping these reports, besides me just shoving them underneath my pillow. Like, maybe svn.
    sharing
    some reports contain information that would be useful if it were visible to the entire team
    privacy
    Some reports might contain information that should be for my eyes only.
    Upshot: comments and suggestions are welcome; I am going to tweak/improve what we are doing with weekly reports.

    Project Issues

    These come from your weekly status reports.
    C++: Boost
    Is it working everywhere that matters? Does it have version issues?
    Java: XML parsing
    Presumably we are using standard class libraries and examples, yes? Do we need any supporting discussion or demonstration?
    File Format
    This is: how we store UML projects and diagrams on disk. Generally there are text and binary formats, and there are human-readable and not-really-human-readable formats out there.
    Protocol
    This needs to subsume file format (need to transmit whole diagrams on start of collaboration), adding incremental/edit commands.

    Lecture 26

    Design Document Discussion

    For the end of semester, the software design document should be a pretty detailed description of what is going on. What we have done up to now includes class diagrams, with some supporting class diagrams and statecharts, UI prototypes and screenshots. What we for sure need in addition includes: overview of design, software architecture section, and detailed prose descriptions of items that appear in various diagrams, for example public API's of classes called from other teams' code, and "dictionaries" that describe classes, associations, states, events, etc. that appear in UML diagrams.

    We went into the SSDD Template and found it has additional suggestions that may be useful, such as a Requirements Traceability section that maps from requirements elements to their corresponding design elements.

    Designing for Security

    This course isn't about security; our textbook has almost nothing on it. Your requirements documents varied widely as to whether you thought the system we are designing needs to be very secure or not. What are the main parameters of security that we can design for? What are the standard tools of the trade?

    Student answers in class included protecting against malicious I/O-based attacks, such as "SQL injection". Dr. J pointed out the obvious need to encrypt any data that is non-public, and mentioned SSH tunnels as the easiest way to do this in many cases. It was also mentioned that the 2007-2008 sysem might best protect the privacy of users by not retaining any more private information than might be absolutely necessary. The system is not intended for official academic course delivery or grading, so FERPA probably does not apply.

    Lecture 27

    Design Tools

    Design Tools cover a wide range of functions ranging from UML drawing tools to user interface builders. Anytime design tools come up, the phrase CASE (computer-aided software engineering) is liable to get used. Ideally a CASE tool would integrate and automate the many phases of software engineering, including design. Since the waterfall is not realistic, ideally a CASE tool would be able to show changes in UML diagrams that occur in the coding phase.

    Earlier I was appalled to find that Eclipse didn't bundle a UML design drawing tool. Now I am appalled to find the Eclipse doesn't really bundle a Java GUI builder tool either! In both cases, we are supposed to select, download, and install a plug-in. Eclipse.org apparently endorsed and adopted a tool called Visual Edit, but the tool is not supported in the current version of Eclipse, an indication that it (VE) is in trouble.

    Anyhow, Dr. J bites the bullet and tries installing some plug-ins. Let's see, Help...Software Updates... Find and Install... yes, this is not too bad. Not willing to go back to earlier version of Eclipse, so visual edit is out, but "Jigloo" seems to have good ratings, will try it.

    Lecture 28

    GUI, GUI, GUI

    "Jigloo" almost worked for me, but (a) a trivial "hello, applet" program reported various compile errors, missing types, etc, and (b) the whole Eclipse process collapsed (out of memory) after less than 10 minutes of Jigloo'ing on a 2GB machine. Although it is possible for you-all to write your GUI's from scratch, I would prefer to have an interface builder do as much work as possible. It would be fairly easy in Visual Studio. It would be fairly easy in Netbeans. It would be even easier in Unicon. We need an interface builder or we dump Eclipse.

    It is ultimately your job to select a GUI builder product, not mine. I tried WindowBuilder Pro Installer, a commercial tool that is supposed to be better than the free stuff; it had a messy activation feature and after I did everything and tried to use it, it seemingly hung (growing the process at around 3MB/sec, I waited a few minutes and then gave up).

    Dr. J's Reflection on UML Diagram Types

    We need to spend some more time on getting the Details worked out for our software design. UML is not going to magically solve that for us, it is a set of diagramming notations, no more. Having said that, it is the case that bad UML diagrams may make it more difficult for us to accomplish our goal (of working out the details well enough to where we will be able to implement them), and good ones may help.

    The Bruegge text calls an activity diagram a special-case of a state chart, and in some of your homeworks I may have criticized a diagram for having not very well-defined, or too "verb" oriented states. My view is that activity diagrams are not statecharts. If you did an activity diagram, don't call it a statechart, and I won't criticize it for sounding "verb"-ish.

    A good class diagram...

    Conveys key relationships (associations) between classes
  • not just inheritance and aggregation, but application domain (and object communication) relationships
    Conveys enough detail to be useful in the implementation...
    not just class member variables and methods, but roles, multiplicity...
  • A good statechart...

    Has well-defined states, represented by a specific variable (or two) in a (explicitly identified) class
    I should be able to see and understand what variable(s) in the class diagram represent the states in the statechart.
    has states whose lifetime generally exceeds a single method.
    has states which affect the object's behavior
    Typical

       class C(h2ostate, slushdegree)
          method precipitate(x,y)
              case foostate of {
              "solid": pileup(1.0)
              "liquid": drain(1.0)
              "slush": { pileup(slushdegree); drain(1.0 - slushdegree) }
              }
          end
    

    A good activity diagram...

    conveys control flow details for a particular method...
    many of the states may be implemented as method calls in this or another class... or they can be assignments, etc.
    would serve as pseudo-code allowing straightforward coding
    for every "fork", there had better be an identifiable "join", a.k.a. "barrier". This is small-scale, or "fine-grained" concurrency. If you really want to diagram true and persistent concurrent threads or processes with synchronous or asynchronous communication, look to other UML diagram types.

    A good interation (sequence or collaboration) diagram...

    shows "messages" (method invocations) which bounce control flow through a number of objects in order to fulfill a given use case
    drills down to the specifics
    shows possibly many instances that are involved
    can be tied back to the class diagram(s)
    it should be clear how each object knows the other object to whom the sequence diagram shows it sending a message. Is it via an object reference in class A (identified by an association line in the class diagram)? If not, how does (the object from) class A know to send (the object from) class B a message?

    Lecture 29

    The End is Near

    3 weeks left? Time in this class for one more culminating assignment, including a presentation of your designs in detail.

    More Notes from HW#6's

    Please address these matters in your homework #7. Your grade will be affected by how well you address them.

    Should a class diagram be a connected graph? What does it mean if there are several disconnected subgraphs, or classes with no associations at all? It means there are relationships (associations) missing.

    Just like use case diagrams need supporting use case descriptions which are obviously more important than the diagram itself, class diagrams must have a supporting text section which describes, in some detail in natural lanuage, what each class and each association means. The admin team's createAccount State Diagram has a pretty good example of this.

    Can a statechart be an NFA, or does it have to be a DFA? Sorry, but you have to either be a DFA, or you have to add mutually-exclusive guards/conditions on your events, see Nav team's Activity State Diagram #1 for an example where the "Navigate Path" event needs guards/conditions.

    A narrative story line? Maybe not, but understanding of the whole system is affected by whether the connections between use cases, statecharts or sequence or activity diagrams, and class diagrams are apparent. Ideally, a use case would motivate the extra details included in the secondary UML diagrams, which would motivate substantial content in the UML class diagram. At least, when looking at diagrams I should know what use cases and class(es) they belong to -- put in cross references, using an obvious naming or numbering scheme. Include the whole thing, not just the recent work but the parts I need from before in order to understand the new stuff.

    Let me say it again: for each statechart, I want to know what class it belongs to and what member variable(s) in the class diagram represent the state information.

    As details grow, don't be bashful about splitting your class diagram into multiple views: one big-picture view and multiple close-ups-with-details is the natural thing to expect.

    What, no title? Yes, I actually expect you to label and identify your work properly.

    .docx? Please save as .doc, .docx is not multiplatform yet. Don't leave Linux and Mac users in the lurch.

    .png? Please include source files, I really mean it.

    Lecture 30

    More HW#6-Inspired Musings on Design

    When do you split a state chart? When some states pertain to one object and other states pertain to a different object, consider splitting the statechart and do two statecharts that execute in parallel in the respective objects. Example from the data types team: there was a tank game, and it had a state chart for what we might call the "game control" (i.e. what the player is seeing, the user interface) but some states seemed to suggest (to me) that the objects in the game such as the tanks might need to track their state (damaged, moving etc), but that needs to be done in a separate statechart.

    When do you know a design is not finished and you have more details to work out? When you see a class with a name like "Hex Game", it not only needs its own variables and methods, you also suspect that its a whole big coarse-grained subsystem with other classes, associations, statecharts, and so forth all missing and needed.

    Remember how you are supposed to define major UML diagrammatic elements in a supporting text description? This is not just for classes, it goes for associations as well. And generally, associations often need more thought in your class diagrams, teams often get associations wrong or they are just missing.

    The goal of things like activity diagrams or statecharts is NOT to restate the same things listed in the usecase diagrams! It is to work out details at a finer grain of detail, the "inside-the-objects" details, as opposed to the use case descriptions' "user-eye-view" from outside the objects.

    In addition to what I said last time about diagrams referencing related items in other diagrams or text sections of the overall design document, I would add that (duh) diagrams need enough clear title markings so that they can be identified. Perhaps besides just a name, each diagram should indicate its UML diagram type and have a brief explanation of what it depicts.

    Sneak Peek at HW#8

    HW#8 is available so you can plan your schedule ahead accordingly.

    Discussion of Sequence Diagrams

    The class featured a discussion of sequence diagrams and what to do if your part of the project had no interesting items that needed one. Dr. J's main answer was: look for pieces of functionality where your design has not really broken out things at a fine-enough granularity yet. Other answers include: was your team too conservative in its interpretation of its role? Does your team have more people in it than are needed for the tasks you've defined for yourself? Team reallocations may be appropriate.

    Lecture 31

    Design Patterns Note

    Our textbook seems to select the following design patterns as especially interesting and worth understanding: Bridge, Adapter, Strategy, Abstract Factory, Command, and Composite. It has supporting examples of these patterns, so study them. Appendix A gives details on 9 design patterns, these 6 plus 3 more (Facade, Observer, Proxy).

    Bruegge section 8.4.7 suggests a sort of buzzword-based "expert system" for detecting when natural language requirements or design prose suggests particular design patterns, for example when you hear something like "policy and mechanism should be decoupled", a light dings in your head and you say "this sounds like a job for.... a Strategy!"

    Composite

    Compose objects into tree structures to represent part-whole hierarchies. Treat individuals and composites uniformly. The client won't have to know whether they are working with a leaf or not. New kinds of leaves won't require that the hierarchy code be modified.

    Decorator

    Attach additional responsibilities to an object dynamically.

    Facade*

    Provide a single unified interface to a set of subsystem interfaces. Goal: reduce coupling between a subsystem and the rest of the system.

    Flyweight

    Use sharing to support large numbers of fine-grained objects efficiently.

    Proxy*

    Provide a surrogate or placeholder for another object.

    Chain of Responsibility

    Give more than one object a chance to handle an incoming message. Pass the request along the chain until an object handles it.

    Command*

    Encapsulate a request as an object. Assists with queing the tasks for later execution, prioritizing them, and supporting an "undo" operation.

    Interpreter

    Interpret sentences in a language by defining and operating on an internal data structure representation of that language.

    Iterator

    Provide a way to access the elements of an aggregate object sequentially.

    Mediator

    Define an object that encapsulates how a set of objects interact.

    Memento

    Capture and externalize an object's internal state so that the object can be restored to this state later.

    Observer*

    Create a mechanism such that when one object changes its state, all its dependent observers are notified and updated. Also called "Listeners" in some systems; a whole "publish-subscribe" paradigm follows this pattern.

    State

    Allow an object to alter its behavior when its internal state changes, appearing to have changed its class.

    Strategy*

    Define a set of encapsulated, interchangeable, algorithms; allow algorithms to vary independently of their clients.

    Template Method

    Define the skeleton of an algorithm, deferring some steps to subclasses.

    Visitor

    Represent an operation on elements of an object structure; enable new operations without changing the element classes.

    Object / Component Design

    Specifying the public interfaces (set of public methods) helps you:
    • identify missing attributes and operations
    • specify type signatures and visibility
    • specify invariants
    • specify preconditions and postconditions
    The first two of these are absolutely necessary to get to the implementation stage, while the latter two are vital in debugging and/or proving a module's correctness.

    Lecture 32

    HW#7 Comments

    all of them graded except... library stations team
    some of you marked who-did-what, most didn't
    would like to re-grade some of these, and some of your HW#6, with individual's contributions identified
    mixed results as far as correcting problems noted previously
    fixed in a few cases, not in others
    sequence trouble
    when it looks like an event triggers a prior event, the diagram gets suspicious to me.
    new block-copy-and-edit diagrams
    find a way to merge them
    new rhetorical and generic diagrams
    find a way to apply them to illustrate our situation concretely
    granularity issues
    many diagrams where the story does not yet tell enough details for you to go and implement what you've designed
    supporting text
    teams that put in the supporting text to explain diagrams generally got better grades than teams that didn't.
    some teams did some nice prototyping work
    associations are still underrepresented minorities
    they need further elaboration, especially inter-team associations such as DB and activity-related communications

    Lecture 33

    Online Course Evaluations

    As of Friday 12:20pm, our response rate was up to 56%; last semester the the departmental average was around 60%, so you are close. I won't know who submitted evaluations and who didn't, but thanks for those of you who have participated. I do not believe the system will be on next week, if you are going to participate it needs to be today.

    Final Examination Review

    The final exam is XXXXday December XX, from XX:XX-XX:XXpm. It is a comprehensive examination. It may address any of the following topics. Not all topics will be covered. Some topics would have to be abbreviated or questions on them would have to be structured carefully in order to allow them to be answered in a short amount of time.
    1. Define and compare several development models.
    2. Construct a project plan and schedule.
    3. Develop a set of questions for a customer in order to elicit requirements.
    4. Develop a software requirements specification document.
    5. Develop UML use case descriptions and diagrams.
    6. Develop user interface descriptions and prototypes.
    7. Develop a software design document.
    8. Develop UML class diagrams, statecharts, activity diagrams and collaboration diagrams
    9. Define inheritance, aggregation, and user-defined associations/responsibilities between classes.
    10. Establish and maintain mappings between requirements and design documents.
    11. Define major architectural styles for computer-based systems. Identify an appropriate architecture for a given requirements specification.
    12. Seek out, evaluate, select, and utilize appropriate function libraries and class libraries to address the needs of an application domain or software design.
    13. Work together in small groups and report effectively on group activities and decisions.
    14. Define multiple team organizational styles and roles.
    15. Summarize the Software Engineering Code of Ethics and the ACM Code of Ethics, and apply these principles in hypothetical scenarios.
    16. Write about issues relevant to the success of a software project.
    17. Review technical documents and provide constructive feedback.
    18. Describe several primary sources for software engineering research and information.
    19. Summarize the current state and trends in professional certification mechanisms for software engineering.
    20. Study and report on the function and usage of unfamiliar software development tools.
    21. Effectively use a user interface builder or similar prototyping or code generating tool.
    22. Describe the application of design patterns.
    23. Define several of the most widely applicable design patterns.