Talk:Code refactoring

This is an old revision of this page, as edited by 130.225.159.2 (talk) at 08:45, 4 December 2006. The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

Latest comment: 18 years ago by Pdemb

Can anyone help me on the following sentence? "After a certain point, it becomes clear that functions can benefit from using functions themselves."

I am translating this article to Chinese, but I can't catch it. Thanks.--202.99.60.155 02:11, 17 Jan 2005 (UTC)

It means that it is often useful to break a complex function into calls of less-complex functions. For example, a complex function that reads weather sensors, computes the wheather for next week and produces maps could be broken into three smaller functions that are called in sequence.

--Stephan Leclercq 09:04, 17 Jan 2005 (UTC)

In software engineering, refactoring is *strictly* bound to object oriented code. The term comes from 'factorization'. In OO design, 'to factorize' means 'to distribute responsibilities among classes and objects'.

If you want to talk about behaviour-preserving transformations in structural programs, (or in assembly code or declarative code or whatever) there are other terms, such as 'to restructurize' or 'to reengineer' or similar. Leave refactoring to OOP.

-- [Peter]

I disagree. Refactoring is not strictly bound to OOP. Refactoring is about behavior-preserving transformations, cleaning code, etc. Concepts that are common to all languages. It is true that some types of refactorings are more or less tied to OO concepts, but refactoring as a whole is not. --Henrik S. Hansen 16:16, 22 October 2005 (UTC)Reply
AFAIK the word 'to refactor' comes from 'to factorize', which means 'to distribute responsibilities between objects and classes'. --Pdemb 11:55, 8 January 2006 (UTC)Reply
"To factorize" means to express something as a product of factors. You can factorize a number, a polynomial, a matrix. It does not imply a distribution of responsibilities among objects, although often that's what it achieves. For example, if you factorize a positive-definite matrix into the product of two triangular matrices, the responsibility of solving the associated system of linear equations is distributed to the two triangular matrices as forward substitution and backward substitution, respectively. --SergioPi 15.03, 29 July 2006.
In software engineering, the term 'factorization' was introduced by Peter Deutsch. I don't have the source paper right now, but I believe that he defined factorization to be the distribution of responsibilities among classes in object-oriented software system. So, refactorization should mean re-distribution of these responsibilities. Pdemb 19:46, 17 September 2006 (UTC)Reply

Which type of testing ensures that refactoring does not change the behavior of the code

Unit tests, especially automated ones in the context of test-first or test-driven development, ensure that refactoring does not change the behavior of the code. The Rod 18:53, 30 September 2005 (UTC)Reply

Tools

Would it be appropriate to add information about tools that support refactoring, in this page? (For example, Eclipse etc) --peterl 01:43, 4 August 2006 (UTC)Reply

Factorization example

The factorization example given in the text has no relevance whatsoever to the fine art of refactoring. Please refactor this paragraph. Stud. polyt. Kalle Hagen 09:44 4 December 2006