Contracts With special reference to RabbitHunt. Multi-person projects Except for coursework, it is rare for a single person to write an entire program.

Slides:



Advertisements
Similar presentations
Intro to CIT 594
Advertisements

Internal Documentation Conventions. Kinds of comments javadoc (“doc”) comments describe the user interface: –What the classes, interfaces, fields and.
System Design System Design - Mr. Ahmad Al-Ghoul System Analysis and Design.
Documentation 1 Comprehending the present – Investing in the future.
Utilities (Part 3) Implementing static features 1.
11-Jun-15 Using the Java API
Intro to CIT 594
Introduction to Analysis of Algorithms
Intro to CIT 594
16-Jun-15 javadoc. 2 Javadoc placement javadoc comments begin with /** and end with */ In a javadoc comment, a * at the beginning of the line is not part.
Arrays. A problem with simple variables One variable holds one value –The value may change over time, but at any given time, a variable holds a single.
18-Jun-15 Arrays. 2 A problem with simple variables One variable holds one value The value may change over time, but at any given time, a variable holds.
Designing Classes How to write classes in a way that they are easily understandable, maintainable and reusable.
Using the Java API
26-Jun-15 Beginning Style. 2 Be consistent! Most times, you will enter an ongoing project, with established style rules Follow them even if you don’t.
From Module Breakdown to Interface Specifications Completing the architectural design of Map Schematizer.
1 Doc Comment Conventions. 2 Write for your audience Rule 32: Write documentation for– those who must use your code Users should not need to care how.
Arrays. A problem with simple variables One variable holds one value –The value may change over time, but at any given time, a variable holds a single.
29-Jun-15 Using the Java API
Modules, Hierarchy Charts, and Documentation
DRY. 11: DRY—Don’t Repeat Yourself Every piece of knowledge should have a single, unambiguous, authoritative representation within a system Duplication.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.3 The Class String.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
Contracts With special reference to RabbitHunt. Multi-person projects Except for coursework, it is rare for a single person to write an entire program.
Adding First, you need to know… Associative Property of Addition When: (a + b) + c = a + (b + c) Commutative Property of Addition When: a + b= b + a.
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
Overview Coding Practices Balancing standards Configuration Management Providing Change Control Software Estimation Reasons why Programmers and Managers.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
CISC6795: Spring Object-Oriented Programming: Polymorphism.
4 th European Project Management Conference, London, 6-7 June 2001 Resource Critical Path Approach to Project Schedule Management Vladimir Liberzon, PMP.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
1 Understanding Inheritance COSC 156 C++ Programming Lecture 8.
(1) Coding Standards Philip Johnson Collaborative Software Development Laboratory Information and Computer Sciences University of Hawaii Honolulu HI
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Recap (önemli noktaları yinelemek) from last week Paradigm Kay’s Description Intro to Objects Messages / Interconnections Information Hiding Classes Inheritance.
07 Coding Conventions. 2 Demonstrate Developing Local Variables Describe Separating Public and Private Members during Declaration Explore Using System.exit.
1 Relational Expressions Relational expressions: –Expressions that compare operands –Sometimes called conditions –Evaluated to yield a result –Typically.
17-Dec-03 Intro to CIT 594 ~matuszek/cit594.html.
Classes CS 21a: Introduction to Computing I First Semester,
Methods and Models Choice of methods for Development of IT related products and systems SVINGSVING Conference held in Gothenburg, Sweden, October 2000.
Java is an object oriented programming language In this model of programming all entities are objects that have methods and fields Methods perform tasks.
23-Oct-15 Abstract Data Types. 2 Data types A data type is characterized by: a set of values a data representation, which is common to all these values,
6 Chapter 61 Looping Programming Logic and Design, Second Edition, Comprehensive 6.
Everything Is an Object Manipulate objects with references The identifier you manipulate is actually a “reference” to an object. Like a television.
Documentation and Programming Style Appendix A © 2015 Pearson Education, Inc., Hoboken, NJ. All rights reserved.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
10-Nov-15 Java Object Oriented Programming What is it?
Documentation javadoc. Documentation not a programmer's first love lives in a separate file somewhere usually a deliverable on the schedule often not.
Javadoc A very short tutorial. What is it A program that automatically generates documentation of your Java classes in a standard format For each X.java.
Software Development p Data structure p A collection of data organized so that the data can be accessed using a set of specific techniques p Object-oriented.
Documentation. Your documentation must fit the needs of your audience. It’s always better to say one thing that is useful, as opposed to many things that.
 All calls to method toString and earnings are resolved at execution time, based on the type of the object to which currentEmployee refers.  Known as.
Intro to CIT 594
Solving Systems of Equations Algebraically Chapter 3.2.
Lesson 6 – Libraries & APIs Libraries & APIs. Objective: We will explore how to take advantage of the huge number of pre-made classes provided with Java.
Computer Science 209 Software Development Handing Errors and Creating Documentation.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
M1G Introduction to Programming 2 3. Creating Classes: Room and Item.
1 Program Development  The creation of software involves four basic activities: establishing the requirements creating a design implementing the code.
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
1 b Boolean expressions b truth tables b conditional operator b switch statement b repetition statements: whilewhile do/whiledo/while forfor Lecture 3.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Printed Reports Analysis questions –Who will use the report? –What is the purpose of the report? –When or how often is the report needed? –Where does the.
More Sophisticated Behavior
Chapter 11 Object-Oriented Design
COS 260 DAY 11 Tony Gauvin.
Arrays 6-Dec-18.
Intro to CIT 594
Classes CS 21a: Introduction to Computing I
Chapter 4: Writing and Designing a Complete Program
Presentation transcript:

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 see the doc comments 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, instead I provide the additional constants NUMBER_OF_ROWS and NUMBER_OF_COLUMNS It is important to know both: –What you can depend on to remain the same –What you cannot assume will remain the same

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 Numbers that “everybody knows” and that “never change” are not usually considered to be magic –However, adding or subtracting 1 will make it “magic” –Example: for(int day = 0; day < 8; day++) {... } Zero and one are typically not considered to be magic numbers

Summary In the “real world,” programmers almost always work in teams –You have to let others know how to use your code –You cannot afford to guarantee you will never change your implementation –You need to know how to use other people’s code –It’s dumb to depend on the details of their implementation It’s important to distinguish interface from implementation –Programs that are too interdependent are hard to change –Programs that cannot be changed are doomed

The End