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:
Continue reading ...
As regards the methods of a class, also applies in this case the naming convention previously exposed to the properties of the class itself. We repeat them below for convenience:
- If consists of a single word, all lowercase, for example, currency ();
- If made of many words the first letter of each, starting from the second, in uppercase, all lowercase other, for example, addElement ();
- The method name should be self explanatory.
Continue reading ...
Today we will discuss the properties consist of a class or property containing an array.
We saw in the previous lesson ( PHP Refactoring - Lez. 1: properties of a class ) how to write simple properties of a class.
As regards the properties of composite rules apply naming convention introduced in the previous tutorial, except the methods of access to the same. Below the standard to follow at the class level.
Continue reading ...
Recent Comments