PHP Refactoring - Lez. 4: Extraction of code and elimination of temporary variables
Often we find in the methods of a class of code that can be reused in various parts of the same, or we see that put in that position does not give any intuitive meaning.
An improvement in the readability of the object is to extract this group of rows with a common meaning and place in a method that is invoked whenever the need is present.
Another problem is the presence of temporary variables, which do nothing but increase the risk of bugs and may be replaced by self-explanatory code, in the form of a private method of the class.
The following is an example to better clarify the concept:











Recent Comments