Automatic code refactoring

Ingo Oeser ioe-news at rameria.de
Thu Aug 9 10:22:49 PDT 2007


Robert Fraser wrote:
> Ingo Oeser Wrote:
>> > - Inline a function (either a single invocation of it or everywhere
>> > it's used).
>> Let the compiler do that. Always! Everything else just asks for long
>> function bodies, if junior programmers try to "optimise" code.
> I wasn't thinking about optimization... sometimes you want to change only
> part of a function and for whatever reason (it's in a library or someone
> else's code, it would only be useful in that one invocation, etc.), you
> don't want to add another parameter.

Then do that in the library, abstract out the common code and
use it in both functions.

That one was missing: Find duplicate code in a module and suggest abstract
version of it.

If it's someone else' code, just contact him (e.g. send a patch, open a 
ticket) and implement the it the way you need it 
in a private function/method directly above the use case 
with the TODO comment, that it will be deleted later.

Copy'n'Paste programming is a major source of maintenance problems,
starting by duplicating bugs, code size increase and performance problems,
due to code duplication. Please don't encourage that bad practise!

The only valid use of Copy'n'Paste for the programmer is copying 
identifiers.

> Imports are private by default now (I hink that was changed just before
> 1.0).

Oh! Didn't know that :-)

I wonder why tango does explicit private imports then...


Best Regards

Ingo Oeser



More information about the Digitalmars-d mailing list