﻿<?xml version="1.0" encoding="utf-8" ?> 
<?xml-stylesheet type="text/xsl" href="../../webpages/courses.xsl" ?>
<!--
/////////////////////////////////////////////////////////////////////////////
//  CSE687codeL2.xml - provides links Lecture #2 materials                 //
//                     on the ECS college server                           //
//                                                                         //
//  Jim Fawcett, CST 2-187, Syracuse University, jfawcett@twcny.rr.com     //
/////////////////////////////////////////////////////////////////////////////
-->

<courses name="Fawcett">

  <btitle>CSE687 Lecture #2</btitle>
  <theme src="../../webpages/CodeTheme.css" />

  <visible>
  <title>CSE687 - Lecture #2 Design Note</title>
  <subtitle>Prime Directives (PD)</subtitle>
  <revised>31 January 2007</revised>
  
  <hilight>
    <ifile title="Home">../../webpages/FawcettHome.xml</ifile>&#32;
    <ifile title="Courses">../../Courses.xml</ifile>&#32;
    <ifile title="Code">../../Code.xml</ifile>&#32;
    <ifile title="Books">../../Books.xml</ifile>&#32;
    <ilink title="Handouts">www.ecs.syr.edu/faculty/fawcett/handouts</ilink>&#32;
    <ifile title="Research">../../research.xml</ifile>&#32;
    <ifile title="SWDev">../../swdev.xml</ifile>&#32;
    <ifile title="WebDev">../../webdev.xml</ifile>&#32;
    <ifile title="News">../../news.xml</ifile>&#32;
    <ifile title="OtherLinks">../../OtherLinks.xml</ifile>&#32;
    <ifile title="SiteDesign">../../SiteDesign.xml</ifile>
  </hilight>

  <hilight>
    <ifile title="CSE681-SWMA">../../CSE681/CSE681Code.xml</ifile>&#32;
    <ifile title="CSE687-OOD">../../CSE687/CSE687Code.xml</ifile>&#32;
    <ifile title="CSE691-IP">../../CSE691/CSE691Code.xml</ifile>&#32;
    <ifile title="CSE775-DO">../../CSE775/CSE775Code.xml</ifile>&#32;
    <ifile title="CSE776-DP">../../CSE776/CSE776Code.xml</ifile>&#32;
    <ifile title="CSE778-AWP">../../CSE778/CSE778Code.xml</ifile>&#32;
    <ifile title="CSE784-SWS">../../CSE784/CSE784Code.xml</ifile>
  </hilight>
  
  <hilight>
    <ifile title="Design Study Guide">StudyGuideDesign.xml</ifile>&#32;
  </hilight>
  
  <br/>
  <section title="Prime Directives (PD):">
    <block>
      <olist>
        <litem>
          <b><i>No surprises</i></b><br/>
          A component, e.g., a module or class should act the way it looks like it should act.
          The interface should describe what it does in a way that any competent developer 
          can understand.
          <ind>
            C++ provides operator notation so a class can support syntax that fits the
            class's model, e.g., matrix, string, ...
          </ind>
        </litem>
        <litem>
          <b><i>Maximize Cohesion</i></b><br/>
          Things that are grouped together should be related in function and be focused 
          on a single objective.
          <ind>
            C++ classes have a fairly low syntactic overhead, so it is practical to create
            small cohesive classes.
          </ind>
        </litem>
        <litem>
          <b><i>Minimize Coupling</i></b><br/>
          When a component changes, everything it’s coupled to may need to change.
          Try to couple only to interface, not implementation.
          Try to minimize “assumption” coupling and “need to know” coupling as well as 
          data coupling.
          <ind><u>References:</u><br/>
            C++ supports passing and returning references from functions.  This greatly 
            reduces the need to pass pointers into and out of functions, making them
            much less susceptible to client miss-use.
            <p/><u>Polymorphism:</u><br/>
            C++ supports dynamic binding with virtual functions, providing strong support
            for building loosely coupled systems.  The client of a base class need know only
            the protocol provided by the base and need not know the details that distinguish
            one derived class from another.
          </ind>
        </litem>
      </olist>
    </block>
  </section>
  
  <section title="Examples:">
    <olist>
      <litem>
        The <ifile title="tok module">../code/semi/tok.h</ifile>, in 
        <ifile title="semi project folder">../code/semi</ifile> is responsible for 
        extracting tokens from a stream.
      </litem>
      <litem>
        tok contains three classes:
        <ulist>
          <litem>
            codeDelimiter is responsible for defining delimiters when parsing C or C++ code.
          </litem>
          <litem>
            xmlDelimiter is responsible for defining delimiters when parsing xml.
          </litem>
          <litem>
            toker is responsible for extracting tokens.
          </litem>
        </ulist>
      </litem>
    </olist>
  </section>
  
  </visible>
</courses>
