CIS 234: Project 1 Issues Dr. Ralph D. Westfall April, 2010.

Slides:



Advertisements
Similar presentations
Variables in C Amir Haider Lecturer.
Advertisements

DONT PANIC!! Lots of new notions coming in these slides Dont worry if not all of it makes perfect sense Well meet most of this stuff again in detail later.
Programmer-defined classes Part 2. Topics Returning objects from methods The this keyword Overloading methods Class methods Packaging classes Javadoc.
Composition CMSC 202. Code Reuse Effective software development relies on reusing existing code. Code reuse must be more than just copying code and changing.
Chapter 2: Using Objects Part 1. To learn about variables To understand the concepts of classes and objects To be able to call methods To learn about.
Lecture Set 4 Data Types and Variables Part B – Variables, Constants, Expressions Conversion Rules Options Strict, Option Explicit Scope of Definition.
Internal Documentation Conventions. Kinds of comments javadoc (“doc”) comments describe the user interface: –What the classes, interfaces, fields and.
 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Bellevue University CIS 205: Introduction to Programming Using C++ Lecture 3: Primitive Data Types.
CIS 234: Using Data in Java Thanks to Dr. Ralph D. Westfall.
1 Generics and Using a Collection Generics / Parameterized Classes Using a Collection Customizing a Collection using Inheritance Inner Classes Use of Exceptions.
Terms and Rules Professor Evan Korth New York University (All rights reserved)
1 Fall 2007ACS-1903 Chapter 6: Classes Classes and Objects Instance Fields and Methods Constructors Overloading of Methods and Constructors Scope of Instance.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Algorithm Programming Coding Advices Bar-Ilan University תשס " ו by Moshe Fresko.
The Ruby Programming Language
Classes and Objects. Topics The Class Definition Declaring Instance Member Variables Writing Instance Member Methods Creating Objects Sending Messages.
Lecture Set 5 Control Structures Part D - Repetition with Loops.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
4.1 Instance Variables, Constructors, and Methods.
The Java Programming Language
Introduction to Java Applications Part II. In this chapter you will learn:  Different data types( Primitive data types).  How to declare variables?
CSCI-383 Object-Oriented Programming & Design Lecture 13.
School of Computer Science & Information Technology G6DICP - Lecture 9 Software Development Techniques.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Programming for Beginners Martin Nelson Elizabeth FitzGerald Lecture 5: Software Design & Testing; Revision Session.
CIS 338: Classes and Modules Dr. Ralph D. Westfall May, 2011.
C++ Basics C++ is a high-level, general purpose, object-oriented programming language.
Reformatted slides from the textbook, C++ How to Program, 6/e Pearson Education, Inc. All rights reserved Chapter 3. [Lecture 02] Introduction to.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
10-Nov-15 Java Object Oriented Programming What is it?
CS 376b Introduction to Computer Vision 01 / 23 / 2008 Instructor: Michael Eckmann.
Copyright Curt Hill Variables What are they? Why do we need them?
Programmeren 1 6 september 2010 HOORCOLLEGE 2: INTERACTIE EN CONDITIES PROGRAMMEREN 1 6 SEPTEMBER 2009 Software Systems - Programming1 Programming.
CS0007: Introduction to Computer Programming Classes: Documentation, Method Overloading, Scope, Packages, and “Finding the Classes”
Programming with Java © 2002 The McGraw-Hill Companies, Inc. All rights reserved. 1 McGraw-Hill/Irwin Chapter 5 Creating Classes.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Top-down approach / Stepwise Refinement & Procedures & Functions.
A FIRST BOOK OF C++ CHAPTER 6 MODULARITY USING FUNCTIONS.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
Variables 1. What is a variable? Something whose value can change over time This value can change more than once over the time period (no limit!) Example:
Data Design and Implementation. Definitions Atomic or primitive type A data type whose elements are single, non-decomposable data items Composite type.
1 Week 5 l Primitive Data types l Assignment l Expressions l Documentation & Style Primitive Types, Assignments, and Expressions.
計算機程式語言 Lecture 03-1 國立台灣大學生物機電系 林達德 3 3 Introduction to Classes and Objects.
04/02/ Procedures Top-down approach / Stepwise Refinement & Sub Procedures.
1 Project 2: Using Variables and Expressions. 222 Project 2 Overview For this project you will work with three programs Circle Paint Ideal_Weight What.
CIS 234: Project 2 Issues Dr. Ralph D. Westfall May, 2010.
BIT 115: Introduction To Programming Professor: Dr. Baba Kofi Weusijana (say Doc-tor Way-oo-see-jah-nah, Doc-tor, or Bah-bah)
COP 2551 Introduction to Object Oriented Programming with Java Topics –Introduction to the Java language –Code Commenting –Java Program Structure –Identifiers.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Chapter 4: More Object Concepts. Objectives Understand blocks and scope Overload a method Avoid ambiguity Create and call constructors with parameters.
Variables in C Topics  Naming Variables  Declaring Variables  Using Variables  The Assignment Statement Reading  Sections
CMSC 104, Version 8/061L09VariablesInC.ppt Variables in C Topics Naming Variables Declaring Variables Using Variables The Assignment Statement Reading.
CIS 338: VB Variables Dr. Ralph D. Westfall April, 2011.
JAVA Practical Unary operators 2. Using Reals 3. Conversions 4. Type Casting 5. Scope 6. Constants.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Lecture 3: More Java Basics Michael Hsu CSULA. Recall From Lecture Two  Write a basic program in Java  The process of writing, compiling, and running.
Working with Java.
Introduction to Classes and Objects
Testing and Debugging.
University of Central Florida COP 3330 Object Oriented Programming
Interfaces.
Variables ICS2O.
Chapter 1: Computer Systems
T. Jumana Abu Shmais – AOU - Riyadh
Java Programming Function Introduction
Chap 2. Identifiers, Keywords, and Types
Java Programming Function Introduction
Variables in C Topics Naming Variables Declaring Variables
Presentation transcript:

CIS 234: Project 1 Issues Dr. Ralph D. Westfall April, 2010

What Is Feedback? comments and suggestions designed to help you improve your skills much of the information in this presentation should be relevant to Project 2 What is feed-forward?

Specifications Are King always do projects based on what requirements say if disagree with requirements, discuss with client client may agree to change if she understands that what you want to do is better

General Requirements put statement that code is own work, AND that you have protected security of code at top, followed by S-signatureS-signature only one zip file, only one Word file don't put zip files inside zip files.java files shouldn’t be submitted as.txt Word and zip files must be named with last name before 1 st name

Missing Parts many students didn't do the Excel file will be in Project 2 and will cost 5 points if missing UML diagram also missing in many projects not in Project 2, but may be in Project 3 output missing in a few projects

Documentation in Code comment anything unusual or "tricky" don't need to comment very obvious things I look for comments on complicated things don't repeat comments for same thing avoid "wordy" comments incomplete sentences, bad grammar ok comments should relate to code get rid of "instructional" comments

Documentation in Code - 2 use multiple line comment feature for long comments, and at start of program /* */ use line breaks to improve readability to separate self-contained blocks (similar to paragraphs in an essay)

Identifier Naming Convention variables, methods, classes and objects Class name starts with a capital letter all others have a lower case 1st letter, upper case for other words ("camel case"), as in iPhone, iPod, iMac, eBay (others?)camel case capitalize initial letter of each added word in all identifiers e.g., SpeechFormatter, joeThePlumber kangasPerYear, calcPrintResults()

Other Naming Issues use all capitals for constants use underscores (_) in constants, not in other identifiers use meaningful variable and object names shoesQuantity is better than shoes subtotal1 is NOT meaningful Class name needs to be same as its java filename (won't run if it isn't)

More Naming Issues capitalization is important: ownerwages != ownerWages

Output Format include formatting required in specifications (can add if not specified but makes sense) title, line labels (underlining?) column alignment (#s right justified) sub- and grand totals aligned appropriately spelling correct

Declarations declare all variables at the start of their methods don't bury declarations below among action statements use appropriate data types don't use integers for dollar amounts don't use double or float for quantities (e.g., # of items) or counts

Declarations - 2 declare (and initialize) first, calculate later int shoesPerYear; // other declarations // imperative ("action") code shoesPerYear = yearDays*shoesPerDay;

Declarations - 3 whenever possible, declare objects first, then instantiate them later in imperative code Employee daBoss; // other declarations // imperative ("action") code daBoss = new Employee(Inputs.getBossWages);

Getters and Setters represent the implementation of the concept of encapsulation ("data hiding") purpose of a set (and often a constructor) is to allow another class to store a value in an object purpose of a get is to allow another class to read the value of a variable in an object

Get and Set a get should always return a value a set should always store a value usually don't have a return statement in a set method, except possibly when a boolean is returned to show it worked OK declare variables at top of class, not in their own set or get methods

All Data in Inputs.java File almost every data item used in StoreApplication.java needs to be declared in Inputs.java also need getter methods there to return each value to StoreApplication.java except could put private final int YEAR_MONTHS = 12; in StoreApplication.java

Calculations in StoreApplication.java Inputs.java file is designed to just be used for supplying data put calculations in StoreApplication.java file instead

Practice what is wrong with the following code? public void setNumber(int num) { int number = num; } what is the scope of number? (where is its value available?)

Access to Variables variables used by another class need to be (explicitly) private never read or change their values directly from outside, use get and set instead always access them directly inside class don't use class's own get or set methods inside the class

Access to Variables - 2 private int number; public void setNumber(int num) { number = num; } note that this set method directly writes values to this variable in its class other methods in this class can directly write values to this variable in its class also other classes must use its set method

Coding Issues don't "hard code" values in code that came from outside of your code or were calculated outside of your code use variables instead example: multiply by a price variable instead of by the literal price shoesPerYear= yearDays*shoesPerDay; //OK shoesPerYear=362*shoesPerDay; //not OK

Coding Issues - 2 avoid "dead code" dead code is a method that is never called by another method in the project or code that is "commented out" ok if set or get are not called, because they may be used in future

Coding Issues - 3 avoid unnecessary gets example: a method may use a set method to store a value in an object don't have to then use a get method if already have this value in the class that called the set method

Coding Issues - 4 mortgage payment calculations monthly payment must be annualized interest rate must be decimal, not percent (0.065 rather than 6.50%)

Coding Issues - 5 recycle previously calculated values rather than repeating calculations kangaPerYear = Inputs.getKangas() *Inputs.getDaysPerYear; kangaIncome = kangaPerYear * Inputs.getKangaPrice(); kangaCost = kangaPerYear * … rather than repeating calculation

Coding Issues - 6 don’t do calculations in a println statement makes code hard to debug or update System.out.println("total: " + (totalIncome - totalExpenses))

Appendix following slides don't really apply to the Project 1 we used in this class

Constructor don't forget to include a constructor in a class that will be used to create objects use a constructor method to set individual values that the objects will have instead of initializing these values in declarations

Constructor - 2 private int numHanboks = 2; // OK in a class just used for its variables, where other classes will use same values private double wages; Employee(double wage) {this.wages = wages; } // use a constructor if will create objects

Access to Variables - 3 storing calculated values in an object if a value changes, anything derived from it almost always should recalculate it example: if a total is stored as a variable, it should change any time any variable that is part of the total changes a value's set method could call a calculate method to update values derived from the value

Coding Issues don't use too many methods if doing same thing often, make one generic method that can be used again e.g., calculating withholding for different salary levels should always make method private except if methods in other classes will use it

Coding Issues - 4 if a data adjustment is only necessary in some situations, make adjustments in the code where the problem occurs (interface), not in a general class store good data in variables rather than fixing bad data in a get

Software Development Analyses an analysis is different from a plan need most detail on critical issues for calculations, need to indicate formulas for output, need to provide information on layout identify anything unusual less detail on minor issues long write-ups are not good in business