<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://wiki.inthewings.net/index.php?action=history&amp;feed=atom&amp;title=CIS_3020_Part_2</id>
	<title>CIS 3020 Part 2 - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://wiki.inthewings.net/index.php?action=history&amp;feed=atom&amp;title=CIS_3020_Part_2"/>
	<link rel="alternate" type="text/html" href="http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;action=history"/>
	<updated>2026-05-06T07:25:59Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;diff=1834&amp;oldid=prev</id>
		<title>Jka: /* Using the new class */</title>
		<link rel="alternate" type="text/html" href="http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;diff=1834&amp;oldid=prev"/>
		<updated>2007-02-21T16:28:33Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Using the new class&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 16:28, 21 February 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l523&quot; &gt;Line 523:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 523:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;} // End Class DrawSquare5&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;} // End Class DrawSquare5&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Continue with [[CIS 3020 Part 3]]&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;==Continue with [[CIS 3020 Part 3]]&lt;ins class=&quot;diffchange diffchange-inline&quot;&gt;==&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jka</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;diff=1833&amp;oldid=prev</id>
		<title>Jka: /* Using the new class */</title>
		<link rel="alternate" type="text/html" href="http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;diff=1833&amp;oldid=prev"/>
		<updated>2007-02-21T16:28:19Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Using the new class&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 16:28, 21 February 2007&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l523&quot; &gt;Line 523:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 523:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;} // End Class DrawSquare5&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;} // End Class DrawSquare5&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;/pre&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class=&#039;diff-marker&#039;&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;==Continue with [[CIS 3020 Part 3]]&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Jka</name></author>
		
	</entry>
	<entry>
		<id>http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;diff=1831&amp;oldid=prev</id>
		<title>Jka at 16:27, 21 February 2007</title>
		<link rel="alternate" type="text/html" href="http://wiki.inthewings.net/index.php?title=CIS_3020_Part_2&amp;diff=1831&amp;oldid=prev"/>
		<updated>2007-02-21T16:27:35Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Characteristics of Object Oriented Programming==&lt;br /&gt;
These characteristics were first developed by [[Alan Kay]].&lt;br /&gt;
====A program consists of a set of objects====&lt;br /&gt;
* Computation is performed through the interaction of the objects with each other&lt;br /&gt;
* The objects tell each other what to do through messages&lt;br /&gt;
* A message consists of:&lt;br /&gt;
** A request&lt;br /&gt;
** The data necessary to serice that request&lt;br /&gt;
====When a program is executing, everything is an object====&lt;br /&gt;
* The object stores data, and you can &amp;quot;make requests&amp;quot; of that object - ask it to perform operations on itself&lt;br /&gt;
* Note: Java violates this rule by having non-object &amp;quot;primitives&amp;quot;: boolean, byte, short, int, long, double, float, and char&lt;br /&gt;
====Each object has its own memory or state====&lt;br /&gt;
* Consists of references to other objects (and/or primitives, in Java)&lt;br /&gt;
* The object &amp;#039;&amp;#039;encapsulates&amp;#039;&amp;#039; (contains/controls) the state&lt;br /&gt;
====Each object is an instance of a single class====&lt;br /&gt;
* A class is a grouping of objects having similar:&lt;br /&gt;
** State&lt;br /&gt;
** Behaviors - which the object also encapsulates&lt;br /&gt;
====The class defines the state and behaviors====&lt;br /&gt;
* All instances of a class perform the same actions - respond to the same set of messages&lt;br /&gt;
* Each instance behaves similarly, but not necessarily identically&lt;br /&gt;
====Classes are organized into a single rooted inheritance hierarchy (or tree)====&lt;br /&gt;
* States and behaviors associated with a particlar class are accessible to descendant classes&lt;br /&gt;
&lt;br /&gt;
==Unified Modeling Language==&lt;br /&gt;
Graphical notation used to describe object-oriented software systems&lt;br /&gt;
====Rules====&lt;br /&gt;
* In computer science trees are drawn with the root at the top and leaves at the bottom&lt;br /&gt;
* As you move up the tree, you generalize&lt;br /&gt;
* As you move down you specialize&lt;br /&gt;
* Each class can define its own behaviors but also inherits the behaviors of its superclasses or ancestors&lt;br /&gt;
* In Java, all classes are derived from the class &amp;#039;&amp;#039;Object&amp;#039;&amp;#039;&lt;br /&gt;
==Simple Program==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Program1 {&lt;br /&gt;
  public static void main(String[] arg) {&lt;br /&gt;
    // statements to execute&lt;br /&gt;
  }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
* All programs consist of at least one class&lt;br /&gt;
* The start and end of a class definition are encapsulated in curly braces ( &amp;quot;{&amp;quot; and &amp;quot;}&amp;quot; )&lt;br /&gt;
* Line two above is a method that defines the driver program&lt;br /&gt;
* The start and end of the program are also encapsulated in curly braces&lt;br /&gt;
* Actual statements of the program go inside these braces&lt;br /&gt;
** NOTE: The &amp;quot;//&amp;quot; is a comment, and comments are critical to understanding a program&lt;br /&gt;
* White space and carriage returns or line feeds (CRLF&amp;#039;s) do not matter&lt;br /&gt;
&lt;br /&gt;
The above is the same as:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class Program1 {Public static voide main(String[] arg){&lt;br /&gt;
//statements to execute&lt;br /&gt;
}}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Real Program==&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class RectangleDemo {&lt;br /&gt;
    public static void main (String[] arg) {&lt;br /&gt;
	//create an island and a turtle and associate them&lt;br /&gt;
	Island hawaii = new Island(400,400);&lt;br /&gt;
	Turtle tina = new Turtle();&lt;br /&gt;
	hawaii.putTurtleAtCenter(tina); //faces east&lt;br /&gt;
	//instruct turtle to draw rectangle&lt;br /&gt;
	tina.tailDown();&lt;br /&gt;
	tina.move(10.0);&lt;br /&gt;
	tina.turnLeft(90.0);&lt;br /&gt;
	tina.move(30.0);&lt;br /&gt;
	tina.turnLeft(90.0);&lt;br /&gt;
	tina.move(10.0);&lt;br /&gt;
	tina.turnLeft(90.0);&lt;br /&gt;
	tina.move(30.0);&lt;br /&gt;
    } //end main()&lt;br /&gt;
} //end class RectangleDemo&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
==Terminology==&lt;br /&gt;
* Operation:&lt;br /&gt;
** Behavior which is invoked by a request&lt;br /&gt;
** The abstract description of what is done&lt;br /&gt;
* Method:&lt;br /&gt;
** A specific implementation of an operation&lt;br /&gt;
** The actual code implementation&lt;br /&gt;
* Operation&amp;#039;s signature consist of:&lt;br /&gt;
** Name&lt;br /&gt;
** Parameters&lt;br /&gt;
** The returned value&amp;#039;s type&lt;br /&gt;
* Interface:&lt;br /&gt;
** A set of related operation signatures&lt;br /&gt;
* Type:&lt;br /&gt;
** A named interface&lt;br /&gt;
* Object&amp;#039;s Interface:&lt;br /&gt;
** The set of all operations supported by that object&lt;br /&gt;
** Defined by the class of which the object is an instance&lt;br /&gt;
* An object is an instance of a single class&lt;br /&gt;
==Software Life Cycle==&lt;br /&gt;
The Iterative Waterfall Model:&lt;br /&gt;
&lt;br /&gt;
* Marketing - Requirements&lt;br /&gt;
* Analysis - Specifications&lt;br /&gt;
* Design - Architecture&lt;br /&gt;
* Implementation - Untested Software&lt;br /&gt;
* Testing - Product&lt;br /&gt;
* Maintenance&lt;br /&gt;
&lt;br /&gt;
Any of the above can relegate the software back up the chain however many steps are necessary if something needs to be fixed that was not thought of before. The further up the chain the software needs to be relegated (number of hops) for a single problem, the larger the problem and the bigger the mistake in the first place.&lt;br /&gt;
==Traditional Software Life Cycle costs==&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Phase || % of Effort&lt;br /&gt;
|-&lt;br /&gt;
| Requirements Definition || 3%&lt;br /&gt;
|-&lt;br /&gt;
| Specification || 15%&lt;br /&gt;
|-&lt;br /&gt;
| Implementation (Coding) || 14%&lt;br /&gt;
|-&lt;br /&gt;
| Testing || 8%&lt;br /&gt;
|-&lt;br /&gt;
| Maintenance || 60%&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
==Important Issues in the Real World==&lt;br /&gt;
Note:&lt;br /&gt;
* Recent graduate working at [[Intel]] identified:&lt;br /&gt;
** Six months spent on analysis and design&lt;br /&gt;
** Two weeks for implementation&lt;br /&gt;
* Documentation is &amp;#039;&amp;#039;not&amp;#039;&amp;#039; mentioned&lt;br /&gt;
** Is an on-going process&lt;br /&gt;
** Occurs throughout the entire software lifecycle&lt;br /&gt;
* Software Prototyping&lt;br /&gt;
** Don&amp;#039;t develop the entire system at once&lt;br /&gt;
** Develop a rough prototype that does not have complete functionality&lt;br /&gt;
** Test this prototype with user to verify it meets all of the required specifications&lt;br /&gt;
** Therefore, early changes can be made reducing modifications in the maintenance phase - saving time and cost.&lt;br /&gt;
* Maintenance&lt;br /&gt;
** Code is continually being modified, rewritten, and improved.&lt;br /&gt;
** Much of your effort will be in maintenance&lt;br /&gt;
** Important to develop code that is:&lt;br /&gt;
*** Well structured&lt;br /&gt;
*** Readable&lt;br /&gt;
*** Well documented&lt;br /&gt;
==Problem Solving Methodology==&lt;br /&gt;
===Analysis:===&lt;br /&gt;
* Examine the problem statement (do you &amp;#039;&amp;#039;really&amp;#039;&amp;#039; know what you need to do?)&lt;br /&gt;
* Work the problem by hand with a simple set of data to verify you understand what needs to be done&lt;br /&gt;
* Describe the input, output, constraints, assumptions, and relationships&lt;br /&gt;
===Design:===&lt;br /&gt;
* Design a solution based upon the analysis&lt;br /&gt;
===Implementation:===&lt;br /&gt;
* Translate the design into code&lt;br /&gt;
===Testing:===&lt;br /&gt;
* Thoroughly test the solution with data&lt;br /&gt;
* Pay close attention to boundary cases&lt;br /&gt;
===Analysis===&lt;br /&gt;
Abstract from the problem statement the data and their relationships&lt;br /&gt;
* Read the problem statement CAREFULLY&lt;br /&gt;
* Identify:&lt;br /&gt;
** Inputs: the data provided to solve the problem&lt;br /&gt;
** Output(s): the desired solution to the problem&lt;br /&gt;
*** Return values (eg cash from ATM)&lt;br /&gt;
*** Side effects (eg change in account balance)&lt;br /&gt;
** Constraints: requirements that limit the solution&lt;br /&gt;
** Relationships: relationships between the inputs and outputs given the constraints (eg new balance = previous balance - withdrawn amount)&lt;br /&gt;
** Assumptions: information not explicit in problem statement that were used to develop relationships - make as few as possible&lt;br /&gt;
* When reading the problem statement, underline the phrases that identify the inputs, outputs, and constraints&lt;br /&gt;
===Example===&lt;br /&gt;
Problem: Given the weight of a set of apples and the price per pound of apples, compute the price of those apples.&lt;br /&gt;
&lt;br /&gt;
Underline the phrases identifying inputs, outputs, and constraints.&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!What are the inputs?!!What are the constraints?!!What are the outputs?&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
# Weight of apples&lt;br /&gt;
# Price per pound of apples&lt;br /&gt;
|&lt;br /&gt;
# None&lt;br /&gt;
|&lt;br /&gt;
# Price of apples&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
; What are the relationships? : Abstractly phrased: Price = Weight X Price / Weight &lt;br /&gt;
: Price of Apples = weight of apples X price per lb of apples&lt;br /&gt;
&lt;br /&gt;
; How do we identify relationships?&lt;br /&gt;
: Look for an abstract relationship&lt;br /&gt;
: Rephrase the problem&amp;#039;s terminology&lt;br /&gt;
&lt;br /&gt;
; What are the assumptions?&lt;br /&gt;
: The weight will be given in lbs&lt;br /&gt;
==Design==&lt;br /&gt;
* Once we have performed an analysis of the problem, we can construct a design&lt;br /&gt;
* Top Down Design/Analysis:&lt;br /&gt;
** Decompose the problem into subproblems until each subproblem is trivial to solve&lt;br /&gt;
** Note: A subproblem is a problem, therefore break it down into subproblems&lt;br /&gt;
* Example: Writing a term paper&lt;br /&gt;
** Create a list of topics to cover&lt;br /&gt;
** Take each topic in turn and outline it&lt;br /&gt;
==Object Oriented Design==&lt;br /&gt;
* Identify the existing class that apply to the domain&lt;br /&gt;
* Identify and reuse existing classes that can be adapted to the solution using:&lt;br /&gt;
** Aggregation&lt;br /&gt;
*** Use one or more instances of class(es) working together to solve problem&lt;br /&gt;
*** example: make a cart from board, wheels, etc.&lt;br /&gt;
** Inheritance&lt;br /&gt;
*** Create a specialized version of existing class&lt;br /&gt;
*** Add new behaviors and/or modify the state&lt;br /&gt;
* Write a new class from scratch&lt;br /&gt;
** This is not preferred... don&amp;#039;t reinvent the wheel!&lt;br /&gt;
==UML - Revisited==&lt;br /&gt;
* Unified Modeling Language&lt;br /&gt;
* Graphical notation used to describe object-oriented software system&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Class Name&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
State (attributes)&lt;br /&gt;
|-&lt;br /&gt;
|&lt;br /&gt;
Operations&lt;br /&gt;
|}&lt;br /&gt;
===Turtle Class===&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
!Turtle!!Class Name&lt;br /&gt;
|-&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
| Attributes of class&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;&amp;lt;constructor&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| Operations of class&lt;br /&gt;
|-&lt;br /&gt;
| + Turtle()&lt;br /&gt;
| Used to create instance of class&lt;br /&gt;
* always has same name as class&lt;br /&gt;
* initializes the starting state of the instance&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;&amp;lt;pen status&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| Stereotype: provides descriptive information&lt;br /&gt;
|-&lt;br /&gt;
| + tailUp(): void&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| + tailDown(): void&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;&amp;lt;movement&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| + move(Distance:double): void&lt;br /&gt;
| UML Signature of an operation&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;&amp;lt;&amp;lt;orientation&amp;gt;&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| + faceEast(): void&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
|-&lt;br /&gt;
| + turnLeft(Change:double): void&lt;br /&gt;
| double is equivalent to real number&lt;br /&gt;
|-&lt;br /&gt;
| + turnRight(Change:double): void&lt;br /&gt;
| &amp;amp;nbsp;&lt;br /&gt;
|}&lt;br /&gt;
==Problem==&lt;br /&gt;
Display a &amp;#039;&amp;#039;&amp;#039;picture&amp;#039;&amp;#039;&amp;#039; consisting of a &amp;#039;&amp;#039;&amp;#039;square with a side length of 75 units&amp;#039;&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
; What is our first step?&lt;br /&gt;
: underline phrases identifying inputs, outputs, and constraints&lt;br /&gt;
&lt;br /&gt;
; Analysis&lt;br /&gt;
: In this problem, if we consider 75 as an input, we will produce a general solution, but if we consider it a constraint, we get a specific solution&lt;br /&gt;
&lt;br /&gt;
{| &lt;br /&gt;
! What items must we identify in our analysis?&lt;br /&gt;
|-&lt;br /&gt;
| Inputs&lt;br /&gt;
| Side Length&lt;br /&gt;
|-&lt;br /&gt;
| Outputs&lt;br /&gt;
| Picture of a square&lt;br /&gt;
|-&lt;br /&gt;
| Constraints&lt;br /&gt;
| Canvas must be large enough&lt;br /&gt;
|-&lt;br /&gt;
| Relationships&lt;br /&gt;
| Square has the side length&lt;br /&gt;
|-&lt;br /&gt;
| Assumptions&lt;br /&gt;
| None&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
; Design&lt;br /&gt;
: Assumption: We will use existing Turtle and Island classes to solve problem&lt;br /&gt;
&lt;br /&gt;
Here we describe and detail our algorithm. A computational process typically decomposes into:&lt;br /&gt;
# Initialization&lt;br /&gt;
# Do the required work&lt;br /&gt;
# Clean up&lt;br /&gt;
&lt;br /&gt;
It is often helpful to try the task by hand to make sure you know what to do&lt;br /&gt;
; Design of the Algorithm&lt;br /&gt;
:&lt;br /&gt;
# Initialization&lt;br /&gt;
## Create an island&lt;br /&gt;
## Create a turtle&lt;br /&gt;
## Put the turtle on the island&lt;br /&gt;
# Do the work: tell turtle to draw square&lt;br /&gt;
## Put down the tail&lt;br /&gt;
## Draw first side&lt;br /&gt;
### Move forward 75 units&lt;br /&gt;
## Draw second side&lt;br /&gt;
### Turn left&lt;br /&gt;
### Move forward 75 units&lt;br /&gt;
## Draw third side&lt;br /&gt;
### Turn left&lt;br /&gt;
### Move forward 75 units&lt;br /&gt;
## Draw fourth side&lt;br /&gt;
### Turn left&lt;br /&gt;
### Move forward 75 units&lt;br /&gt;
# Cleanup&lt;br /&gt;
## Point in the starting direction&lt;br /&gt;
### Turn left&lt;br /&gt;
## Pick tail up&lt;br /&gt;
&lt;br /&gt;
; Note: Sometimes one or more of these steps will require refinement. Just repeat the Analysis &amp;amp; Design process for each of these.&lt;br /&gt;
==Implementation==&lt;br /&gt;
===Implementation 1===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class DrawSquare1 {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    // Initialization&lt;br /&gt;
    Island maui = new Island(200,200);&lt;br /&gt;
    Turtle tim = new Turtle();&lt;br /&gt;
    maui.putTurtleAtCenter(tim);&lt;br /&gt;
    &lt;br /&gt;
    // Do the work - Draw Square&lt;br /&gt;
    tim.tailDown();&lt;br /&gt;
    // Draw first side&lt;br /&gt;
    tim.move(75.0);&lt;br /&gt;
    // Draw second side&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.move(75.0);&lt;br /&gt;
    // Draw third side&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.move(75.0);&lt;br /&gt;
    // Draw fourth side&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.move(75.0);&lt;br /&gt;
    &lt;br /&gt;
    // Cleanup&lt;br /&gt;
    // Face in starting direction and pickup tail&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.tailUp();&lt;br /&gt;
  } // End main()&lt;br /&gt;
} // end class DrawSquare1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Improvements for Reusability===&lt;br /&gt;
* To improve the reusability of the code, use symbolic values instead of manifest constants&lt;br /&gt;
* This allows the code to be reused more easily&lt;br /&gt;
* If we wish to change the size, we update the code in only one location!&lt;br /&gt;
===Implementation 2===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class DrawSquare2 {&lt;br /&gt;
  public static void main(String args[]) {&lt;br /&gt;
    // The length of the side is now a symbolic&lt;br /&gt;
    // value: len&lt;br /&gt;
    double len = 75.0;&lt;br /&gt;
    // Initialization&lt;br /&gt;
    Island maui = new Island(200,200);&lt;br /&gt;
    Turtle tim = new Turtle();&lt;br /&gt;
    maui.putTurtleAtCenter(tim);&lt;br /&gt;
    &lt;br /&gt;
    // Do the work - Draw Square&lt;br /&gt;
    tim.tailDown();&lt;br /&gt;
    // Draw first side&lt;br /&gt;
    tim.move(len);&lt;br /&gt;
    // Draw second side&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.move(len);&lt;br /&gt;
    // Draw third side&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.move(len);&lt;br /&gt;
    // Draw fourth side&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.move(len);&lt;br /&gt;
    &lt;br /&gt;
    // Cleanup&lt;br /&gt;
    // Face in starting direction and pickup tail&lt;br /&gt;
    tim.turnLeft(90);&lt;br /&gt;
    tim.tailUp();&lt;br /&gt;
  } // End main()&lt;br /&gt;
} // end class DrawSquare2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Next Improvement for Reusability===&lt;br /&gt;
* Code allows one specific turtle, tim, to draw a square&lt;br /&gt;
* Better to define a specialized Turtle class that supports drawing squares&lt;br /&gt;
* Changes:&lt;br /&gt;
** Initialization no longer needed&lt;br /&gt;
** Since we do not know who the turtle will be, &amp;quot;tim&amp;quot; is replaced with &amp;quot;this&amp;quot; which references the current instance of the class (i.e. whichever turtle is being told to draw the square)&lt;br /&gt;
===Tempting, but wrong!===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class GeoTurtle extends Turtle {&lt;br /&gt;
  public void drawSquare() {&lt;br /&gt;
    // same code as before dropping the&lt;br /&gt;
    // initialization section and replacing &amp;quot;tim&amp;quot;&lt;br /&gt;
    // with &amp;quot;this&amp;quot;&lt;br /&gt;
    double len = 75.0;&lt;br /&gt;
    &lt;br /&gt;
    // Draw Square&lt;br /&gt;
    this.tailDown();&lt;br /&gt;
    // Draw first side&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    // Draw second side&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    // Draw third side&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    // Draw fourth side&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    &lt;br /&gt;
    // Cleanup&lt;br /&gt;
    // Face in starting direction and pickup tail&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.tailUp();&lt;br /&gt;
  } // End drawSquare()&lt;br /&gt;
} // end class GeoTurtle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Implementation 3 - the right way!===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class GeoTurtle extends Turtle {&lt;br /&gt;
  public void drawSquare( double len ) {&lt;br /&gt;
    // same code as before dropping the&lt;br /&gt;
    // initialization section and replacing &amp;quot;tim&amp;quot;&lt;br /&gt;
    // with &amp;quot;this&amp;quot;&lt;br /&gt;
    &lt;br /&gt;
    // Draw Square&lt;br /&gt;
    this.tailDown();&lt;br /&gt;
    // Draw first side&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    // Draw second side&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    // Draw third side&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    // Draw fourth side&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.move(len);&lt;br /&gt;
    &lt;br /&gt;
    // Cleanup&lt;br /&gt;
    // Face in starting direction and pickup tail&lt;br /&gt;
    this.turnLeft(90);&lt;br /&gt;
    this.tailUp();&lt;br /&gt;
  } // End drawSquare()&lt;br /&gt;
} // end class GeoTurtle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Using the new Class===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class DrawSquare3 {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Initialization&lt;br /&gt;
    Island maui = new Islans(200,200);&lt;br /&gt;
    GeoTurtle tim = new GeoTurtle();&lt;br /&gt;
    maui.putTurtleAtCenter(tim);&lt;br /&gt;
    &lt;br /&gt;
    // Draw the square&lt;br /&gt;
    tim.drawSquare(75.0);&lt;br /&gt;
  } // End main&lt;br /&gt;
} // End Class DrawSquare3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Final Improvement for Reusability===&lt;br /&gt;
* It is likely that we will need to draw other shapes than squares&lt;br /&gt;
* For example, a rectangle&lt;br /&gt;
* Since a square is a general case of a rectangle (width=height) we could use the drawRectangle method to implement drawSquare&lt;br /&gt;
===Implementation 4===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class SquareDrawingTurtle extends RectangleDrawingTurtle {&lt;br /&gt;
  public void drawSquare( double len) {&lt;br /&gt;
    this.drawRectangle(len,len);&lt;br /&gt;
  } // end drawSquare() method&lt;br /&gt;
} // end SquareDrawingTurtle&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Using the new Class===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class DrawSquare4 {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Initialization&lt;br /&gt;
    Island maui = new Island(200,200);&lt;br /&gt;
    SquareDrawingTurtle tim = new SquareDrawingTurtle();&lt;br /&gt;
    maui.putTurtleAtCenter(tim);&lt;br /&gt;
    &lt;br /&gt;
    // Draw the square&lt;br /&gt;
    tim.drawSquare(75.0);&lt;br /&gt;
  } // End main&lt;br /&gt;
} // End Class DrawSquare4&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Implementation 5===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class GeoTurtle extends Turtle {&lt;br /&gt;
  public void drawSquare( double len ) {&lt;br /&gt;
    this.drawRectangle(len,len);&lt;br /&gt;
  } // end drawSquare() method&lt;br /&gt;
&lt;br /&gt;
  public void drawRectangle ( double sideA, double sideB ) {&lt;br /&gt;
    // code to implement drawRectangle&lt;br /&gt;
  } // end drawRectangle() method&lt;br /&gt;
} // end GeoTurtle class&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
===Using the new class===&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
class DrawSquare5 {&lt;br /&gt;
  public static void main(String[] args) {&lt;br /&gt;
    // Initialization&lt;br /&gt;
    Island maui = new Island(200,200);&lt;br /&gt;
    GeoTurtle tim = new GeoTurtle();&lt;br /&gt;
    maui.putTurtleAtCenter(tim);&lt;br /&gt;
    &lt;br /&gt;
    // Draw the square&lt;br /&gt;
    tim.drawSquare(75.0);&lt;br /&gt;
  } // End main&lt;br /&gt;
} // End Class DrawSquare5&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Jka</name></author>
		
	</entry>
</feed>