Swen


pbl3
November 28, 2007, 1:18 pm
Filed under: findings, group

 -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

- Encapsulate Field

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

 -Generalize Type

   -Pull Up

-Push Down

-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

Can any of the refactorings you mentioned be applied to the Appt module – sample Java code?
If so, which ones?

Comment by nalaka

You mentioned “naming” as part of programming style? Are there standard naming conventions?

Comment by nalaka




Leave a comment
Line and paragraph breaks automatic, e-mail address never displayed, HTML allowed: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>