Difference between revisions of "OOP Class6"

esse quam videri
Jump to: navigation, search
(Pair Programming)
(Pair Programming)
Line 217: Line 217:
 
I would like you and your paired partner to create and demonstate classes in c# from the diagram below.
 
I would like you and your paired partner to create and demonstate classes in c# from the diagram below.
 
   
 
   
 +
 +
==Homework==
 +
 +
use Pair Programming to make tests and classes fo rthe followong UML
  
 
[[OOP Students Classes Diagram]]
 
[[OOP Students Classes Diagram]]
 +
 +
Create a UML Diagram of your c# classes (not the tv and radio yeah the pong machine and ninja and kungfumonkey and stuff)

Revision as of 23:01, 1 March 2006

What is UML

UML 
Unified Modeling Language.
"A modeling language is a language whose vocabulary and rules focus on the conceptual and physical representation of a system"

The Unified Modeling Language User Guide, Booch Rumbaugh Jacobson ACM Press, Addison Wesley 1999 ISBN 0201571684 The Unified Modeling Language User Guide

Simple Notation

Class notation in UML

The name of the Class should go inside of a box

Class Name


Then Two lines are added. The first line separates Attributes. The second line separates Operations. Attributes are the equivalent of fields or properites in c# and Operations are the same as methods.

Class Name
 
 
<--Class Name
<--Attributes
<--Opertaions


A Rectagle Class might look like this

Rectangle
height
width
area()
add()
move()
copy()
isEmpty()

You can also specify Attribute types with a :

Rectangle
height : Float
width : Float
area()
add()
move()
copy()
isEmpty()

Default vlaues are specified with =

Rectangle
height : Float = 6.0
width : Float = 4.0
area()
add()
move()
copy()
isEmpty()


Operator return type are also specifed with a :. Opertor parameter signatures are specified by ( name : Type )

Rectangle
height : Float = 6.0
width : Float = 4.0
area() : Float
add()(r:Rectangle)
move()
copy() :Rectangle
isEmpty() : Boolean = true

UML Resources

Dia A Drawing Program

Dia for windows

Dog Diagrams with Dia

Dog Exmaples

Simple Dog Class from week 5 DogSimple.cs - source
DogSimple.png <csharp>using System;

//Dog simple class definition public class Dog {

	public string Name;		// the dog's name

public int Age; // the dog's age public int Weight; // the dog's weight public string BarkSound; // the sound of the dog's bark

public Dog() { BarkSound = "Woof!!!"; }

public void Bark() { //put bark code here } public void Eat() { //put eat code here } }</csharp>


Dog UML with Types

Dog Class with Types from week 4 DogWithTypes.cs - source

DogWithTypes.png <csharp>using System;

//Dog simple class definition public class Dog {

	public string Name;		// the dog's name

private int Age; // the dog's age public int Weight; // the dog's weight public string BarkSound; // the sound of the dog's bark private int barkCount; //The number of time the dog has barked public Dog() { BarkSound = "Woof!!!"; }

public string Bark() { string strBark = this.BarkSound;

       barkCount ++;
       return strBark;

}

public void Eat() { //put eat code here } }</csharp>

In class

Discuss Dog Diagram

OOP Full Dog Diagram

Pair Programming

Pair Programming

We are going to pair off to do our next assignment. Many of the paired programming principles come from XP (http://www.extremeprogramming.org/ Extreeme Progamming)

Pairs are good because

  • Pairs keep each other on track
  • A partner can help when you are stuck
  • Keep each other accountable


Some XP Principles

Fail - If you are having trouble succeeding fail.

Baby Steps - Do the smallest thing that you possible can that moves you in the right direction

If you do decide to dive and conqure the problem please remember that integration process is unpredictable and can be quite difficult. Try to integrate your code often. Try posting up your code and emailing or plan on meeting several times.

When topair programmers are together one you should sit a one computer (yeah that right two of you at one computer) and one should type while the other watches and reflects. Feel free to slide the keyboard back and forth when someone get tired, stuck or has a new idea.

I would like you and your paired partner to create and demonstate classes in c# from the diagram below.


Homework

use Pair Programming to make tests and classes fo rthe followong UML

OOP Students Classes Diagram

Create a UML Diagram of your c# classes (not the tv and radio yeah the pong machine and ninja and kungfumonkey and stuff)