Unformatted text preview:

Contracts With special reference to RabbitHunt Multi person projects Except for coursework it is rare for a single person to write an entire program Each programmer has to know what the other programmers are doing In addition each programmer has to let the others know what he she is doing BUT In order to maintain control of code it is necessary to hide details of the implementation Contracts A contract specifies the rights and responsibilities of each party to the contract In programming a contract spells out what other programmers are allowed to depend on in my code When I write a contract I have these responsibilities I must provide enough information so that others can make use of my code my classes and methods I must not arbitrarily change what I offer I also have these rights I can change the code however I like so long as it continues to meet the terms of the contract I can provide additional functionality javadoc In Java the javadoc comments or just doc comments typically provide the contract In BlueJ you can read these more easily by choosing Interface from the pull down menu in the upper right corner If you have not read The contract portion of the RabbitHunt assignment you should do so Rule 89 Program by contract is also relevant The RabbitHunt contract What is most important about the RabbitHunt contract is the information I do not provide I provide a number of constants such as Model N Model MIN DIRECTION and Model FOX but I do not specify the numerical values of those constants I did not specify the size of the field but in the improved version I provide the additional constants NUMBER OF ROWS and NUMBER OF COLUMNS If you read the assignment you already know that we may grade your program with different values for these constants This is relevant to your grade Magic numbers A magic number is a constant such as 20 that appears sometimes without explanation in the code Magic numbers are poor style Named constants such as NUMBER OF ROWS have two advantages They provide some documentation for the meaning of the constant If you decide to change the constant you need only do so in one place rather than many Zero and one are typically not considered to be magic numbers The End


View Full Document

Penn CIT 591 - Contracts Lecture Notes

Documents in this Course
Stacks

Stacks

11 pages

Arrays

Arrays

30 pages

Arrays

Arrays

29 pages

Applets

Applets

24 pages

Style

Style

33 pages

JUnit

JUnit

23 pages

Java

Java

32 pages

Access

Access

18 pages

Methods

Methods

29 pages

Arrays

Arrays

32 pages

Methods

Methods

9 pages

Methods

Methods

29 pages

Vectors

Vectors

14 pages

Eclipse

Eclipse

23 pages

Vectors

Vectors

14 pages

Recursion

Recursion

24 pages

Animation

Animation

18 pages

Animation

Animation

18 pages

Static

Static

12 pages

Eclipse

Eclipse

23 pages

JAVA

JAVA

24 pages

Arrays

Arrays

29 pages

Animation

Animation

18 pages

Numbers

Numbers

21 pages

JUnit

JUnit

23 pages

Access

Access

18 pages

Applets

Applets

24 pages

Methods

Methods

30 pages

Buttons

Buttons

20 pages

Java

Java

31 pages

Style

Style

28 pages

Style

Style

28 pages

Load more
Loading Unlocking...
Login

Join to view Contracts Lecture Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Contracts Lecture Notes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?