Refactoring & SOFA Flashcards
What is SOFA?
Short - method short. You can figure out what it does by looking at it.
One Thing - does one thing.
Few arguments - generally helps with one thing.
Abstraction - is abstraction consistent.
Why is lots of arguments bad?
Hard to get good testing coverage
Hard to mock/stub
If you have a boolean flag then you might know that you have a a code smell.
What is Quantitative ABC Complexity?
Square the number of assignments, branches, and conditions.
Score = square root(assigments^2 + branches^2 + conditions^2)
Gov. Standard is <= 20/module. Use Flog in Rails
What is Cyclomatic Complexity?
Edges, Nodes, Connected Components. Use a Graph.
E - N + 2P/s
Government Standard <= 10/module. Use Saikuro in Rials
What is ratio of code to test code?
You should have twice as much test code as your normal code.
Which SOFA guideline is most important for Unit Testing?
Have Few Arguments.
What is refactoring?
We want to modify code. Has the same behavior, but we transform the code to get rid of its smells.
What are the goals of refactoring?
Reduce Code Complexity
Eliminate Code Smells
Improve Testability
Eliminating bugs is NOT one of them
How much do plane and document spend on maintenance?
P&D spends ⅓ on development and ⅔ on maintenance. Customers pay 10% of software cost per year for maintenance.
Difference between development and maintenance?
Working with customer and responding to change. You can’t break the already in production code.
Agile vs Plan & Document in Maintenance?
Customer Changes request: P&D you submit a change request form. In Agile you make user stories.
Time Estimate/Cost: P&D Manager decides. Agile uses points by development team.
Triage of Change Requests: P&D Change Control Board. Agile has development team with customer participation.
Fix these statements about P&D:
Cost of Maintenance ___ the cost of development in P$D.
Agile equivalent to P&D change request Stories is _____.
Agile equivalent to P&D change request cost estimates is ____
Agile equivalent to P&D releases are _________.
Agile lifecycle of maintenance is similar to P&D maintenance in __________.
- exceeds.
- User Stories
- Points
- Iterations
- Enhancing working software product, collaborating with customer vs. negotiating by contract, and continuously respond to change.
What are the main objectives of refactoring?
Usually results in fewer lines of code.
Should not cause existing tests to fail
Addresses explicit vs. implicit customer requirements.
Does not make usually make any changes to the test suite.