Jump to content

What exactly is Refactoring?


Recommended Posts

hehe ....

Especially if its java.... its not the most readable language at the best of times...

AHHH ... Perl.

Course Perl looks ugly to the machine but its relatively simple to make the source human readable, at least compared to java or c++ .... I guess thats just the nature of the beasts..

Link to comment
Share on other sites

"Refactoring is a technique to restructure code in a disciplined way."

 

http://www.refactoring.com/

 

google rules!  :thumbs:

my simple understanding of refactoring is revamping of code for optimization and removal of code nuisances (anti-pattern, code smells, bugs, etc.)

 

in layman's terms, take a code and make it better. :)

 

ciao!

Link to comment
Share on other sites

my simple understanding of refactoring is revamping of code for optimization and removal of code nuisances (anti-pattern, code smells,  bugs, etc.)

I didn't know refactoring.

But highly optimized code is generally difficult to read.

What's nice code ? Well there is a lot of opinion about what is nice code and how to make it easy to read and maintain.

Here is some rules:

- names are important, Edit-Search is a important programmer's tool,

- make global scope names (global variables, global functions, macros) very explicite, don't hesitate to make them long to write. for example if you declare a globale variable with the name "n" you may have trouble when the program get bigger,

- minimum use of global definitions,

- if you have to use a global value, better create a function that just return it,

- maximum use of local variables (reentrant),

- a function must not be too long: one page, two pages max,

- adopt a rule for names: example me: macro names = all upper case: _AUTO_BYTESIZE, types start with upper case: AutoPort, variables start wit lower case: comBuff,

- one variable for one use. for example if you declare i for an iteration, better not reuse it in the function: declare int i,j,k;

- one module for each task,

- avoid dependencies between modules. define a little API for comunication between modules so that you can change a module without having to change others,

- try to optimize using the right algorithm. Don't try to optimize on the implementation. modern compilers take care of that quite well for you,

- optimize when it's necessary. most of te task don't need speed,

 

many other things but:

1- comment your code,

2- comment your code,

3- comment your code.

me, I generally start to create the header, declare the functions, comment them before any real coding. That way you made the specs and a good part of the doc.

 

hope this help

 

roland

Link to comment
Share on other sites

"Refactoring is a technique to restructure code in a disciplined way."

 

http://www.refactoring.com/

 

google rules!  :thumbs:

my simple understanding of refactoring is revamping of code for optimization and removal of code nuisances (anti-pattern, code smells, bugs, etc.)

 

in layman's terms, take a code and make it better. :)

 

ciao!

What on earth is a code smell?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...