Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "CIS 234: Project 1 Issues Dr. Ralph D. Westfall April, 2010."— Presentation transcript:

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

2 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?

3 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

4 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

5 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

6 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

7 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)

8 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()

9 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)

10 More Naming Issues capitalization is important: ownerwages != ownerWages

11 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

12 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

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

14 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);

15 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

16 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

17 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

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

19 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?)

20 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

21 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

22 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

23 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

24 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

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

26 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

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

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

29 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

30 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

31 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

32 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

33 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

34 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


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

Similar presentations


Ads by Google