-A code refactoring is any change to a computer program’s code which improves its readability or simplifies its structure without changing its results.
- Refactoring neither fixes bugs nor adds new functionality.
- Refactoring improves the understandability of the code.
- Changes its internal structure and design, and removes dead code, to make it easier for human maintenance in the future.
Examples of refactoring
- Change a variable name into something more meaningful.
- Complex refactoring is to turn the code within an if block into a subroutine.
- More complex refactoring is to replace an if conditional with polymorphism.
Types of refactoring
-Extract Method (to turn part of a larger method into a new method. By breaking down code in smaller pieces, it is more easily understandable. This is also applicable to functions)
-Rename Method (changing the name of a method into a new one that better reveals its purpose).
-Programming style refers to a set of rules or guidelines used when writing the source code for a computer program. It is often claimed that following a particular programming style will help programmers quickly read and understand source code conforming to the style as well as helping to avoid introducing faults.
Elements of good style
- Code appearance
-Indenting
-Vertical alignment
-Spacing
-Naming ,logic and higher techniques
-Appropriate variable names
-Boolean values in decision structures
-Left-hand comparisons
-Looping and control structures
-Lists
2 Comments so far
Leave a comment
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>
Can any of the refactorings you mentioned be applied to the Appt module – sample Java code?
Comment by nalaka November 30, 2007 @ 12:47 pmIf so, which ones?
You mentioned “naming” as part of programming style? Are there standard naming conventions?
Comment by nalaka December 2, 2007 @ 10:28 am