120 likes | 133 Views
CIS 234: Project 2 Issues. Dr. Ralph D. Westfall May, 2010. Avoid Copy and Paste Reuse. don't copy and paste code to do something very similar with different data put repeated code in a method, then call that method with different data
E N D
CIS 234: Project 2 Issues Dr. Ralph D. Westfall May, 2010
Avoid Copy and Paste Reuse • don't copy and paste code to do something very similar with different data • put repeated code in a method, then call that method with different data • method may be in same class, or in a different class (e.g., FICA/Medicare calculations work like FIT calculations)
Repeat This With Me • "If I'm copying and pasting code, and then changing it slightly,I'm probably doing something wrong." • all together • left side of the room say the green text, then middle say blue text, and finally right side say red text (then 3-part harmony?) • the more lines x often, the more wrong
Avoid Duplicated Activities • data • don't get same data again and again • store value in a variable the first time, then use that instead of going back to source • calculations • don't repeat them • store value in a variable the first time, and then recycle that as needed
Separate Data & Calculations • put ALL data in a separate class e.g., Inputs. java • possibly with the exception of trivial items such as MONTHS_IN_YEAR • don't do any calculations in the class that holds the data
Inheritance • when a class inherits from another class, you can (and should) use the new class to do what the previous one did • a class named NuEmployee that inherits from Employee should now do the income tax (FIT) calculations that Employee did • do NOT create objects from both, and use Employee class objects to calculate FIT
Excel File • intended to check calculations in Java • if just plug output data into it, without any formulas, nothing gets checked • all subtotals and totals should be calculated in Excel • formulas should also multiply items per day times days per year time prices, and times costs
Code • appropriately formatted with skipped lines • put all declarations before any of the action code in a method • no redundant items e.g., { } • use comments where necessary, delete ones that are unnecessary or are no longer appropriate
Follow the Requirements • Excel file missing in a lot of projects • pseudocode too • a few zip or Word files weren't named with last and first name • output needs to be pasted in Word file • code needs to be pasted into Word file • JOptionPane should be in Inputs class
Requirements Really Do Count • several students didn't make the output show the kangas and hanboks per day, or missed other requirements for output • some didn't use a separate class to calculate Other Operating Expense • a few didn't notice that some data items had been updated (red font)
Use Feedback • Project 1 grading identified problems with Mortgage calculations • a few students still didn't convert monthly payment to annual occupancy expense • at least one student still used the percentage value (6.5) instead of the decimal value (0.065) in the calculation
Variable Names • should make it clear what the data is • total and subtotal aren't good, because they could apply to a lot of different things • instead use names such as: incomeTotal, productCostSubtotal, kangasPerYear, employeeExpenseSubtotal, • use naming convention: lower case for first word, Upper Case to start each added one