When naming in code, being more ___________ tends to reduce reusability.
application specific
Basic Name Examples
A customer record read from a file
input_record
customer_record
Number of products in the current order
NP
___________
CurrentOrderProducts
NumberOfProductsInCurrentOrder
nProducts
Standard Name Parts
Adopt a small set and then BE CONSISTENT
Examples:
Number, Nmbr, Num, N, No, Count, Tally
ID
Amount, Amt
Total, Tot, Totl, Ttl, Sum
Avg, Min, Max
Make exceptions where ___________
it makes sense
Some_Names_Are_Just_Too_Long
EvenIfWrittenThisWay
Names that are too long reduces ___________
___________-___________ characters is a good average (with quite a few shorter and some larger)
readability
Names to ___________
Temporary variables (Work, Temp, Scratch, ...)
Status variables (Flag, Status, Switch, Option, ...)
Series variables (Total1, Total2, Total3, ...)
Related, generic names (Category, Type, Code, Group, ...)
avoid, modify, or use sparingly
Constants, name them
No ___________ number in the code
magic
A useful idea, but don't ___________ global variables or points
overuse
Refactoring- A change made to the internal structure of software to make it: ___________
Easier to understand and cheaper to modify, WITHOUT CHANGING ITS OBSERVABLE BEHAVIOR
Refactoring is NOT: ___________
Performance improvement (no functional change, but often increases complexity).
Defect removal.
Function addition.
As software evolves, it tends to decay, and some software is low quality when it is released. Refactoring is an investment to counter ___________.
"The Cardinal Rule of Software Evolution is that evolution should improve the internal quality of the progra
the decay and initial poor quality
Indicators of a Need to Refactor: ___________.
*Note that these "indicators" are not rules. There are no clearly quantified measures for decision. Mostly, its a matter of judgement.
Code is duplicated.
A routine is too long.
A loop is too long or too deeply nested.
A class has poor cohesion.
A class interface does not provide a consistent level of abstraction.
A parameter list has too many parameters.
A class does too much
A class do
Refactoring is Good
___________ code decay (Helps avoid additional decay)
___________ overall design (by cumulative effect)
Improves understanding (Deeper knowledge for the person refactoring and improved readability for the future)
Helps locate defects (
Undoes
Improves
Improves future maintenance
Why People Don't Refactor
Refactoring has ___________ (defects can be introduced)
Refactoring takes ___________ (managers/clients may not be supportive)
Refactoring does not "need" to be done (the software works without refactoring)
Cost vs. Benefit (Cost
risk
time
Refactoring Process
Keep refactoring steps ___________ (___________ after every step; Commit changes as you work)
Use compiler warnings (at the most stringent/strict level)
Review refactoring as you would any change (no change is too small to introduce an
small
Test
When to Refactor
___________- which is always
Not in large doses (Refactor continually as part of routine work; Large refactorings are more error prone)
While making other changes (But keep refactoring as a separate task)
Whenever it's needed
Refactoring Strategy
There is always more refactoring that you could do
Refactor as ___________.
(When fixing a defect; When adding a feature; But separate the changes from refactoring).
Focus on parts likely to ___________ (e.g., error prone modules, hig
you work in parts of the code
benefit most
Gradually isolate and reduce the messiest parts of the system
What to include in defect reports?
Observed behavior
Expected behavior
Steps to reproduce
Stack traces
Test cases
Severity
___________ (e.g., status: abandoned, status: in progress, type: bug, type: enhancement, priority: critical, priority: low)
Useful feature for finding subsets of issues
Default structure provides some ideas, but not much structure
Create a structure for y
Defect Labels