Boost logo

Boost :

From: Terje Slettebø (tslettebo_at_[hidden])
Date: 2003-04-24 04:19:21


Just to add some to my previous posting.

Also, from a maintenance POV, having variables that doesn't change
throughout a function (or program), tends to make it easier to understand.
Having functions which change their arguments goes rather against that.

One exception is input stream operators, where it's really no other way of
doing it than first declaring a variable, then streaming into it.

For example:

const some_type valueA=...;

const some_type valueB = f(valueA);

// Possibly many lines of code here

// What is valueA and valueB here? Answer: The same as when they were
declared.

Yes, I know it may be a massive undertaking to start making a program, which
wasn't designed that way, const correct. However, it may be one of the
better refactorings to do. It also highlights all the points where something
may be changed, and where further refactorings (such as those in the
previous posting) may be appropriate.

Regards,

Terje


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk