2011/3/7 Jerome Renard <jerome.ren...@gmail.com>: > Hi there, > > I would propose a small addition to the naming conventions. > > A list of recommended names is already provided in > http://incubator.apache.org/zetacomponents/community/implementation.html#general-guidelines > however there is nothing proposed for variables like arrays. > > As an example you can compare the two following snippets > > Without "List" variable: > $rows = fetchSomeRows(); > foreach($rows as row) > [....] > > With "List' variable: > $rowList = fetchSomeRows(); > foreach($rowList as $row) > [....] > > The rationale for such variable names is that adds a bit more > semantics on what the variable > is supposed to contains. It should also help to avoid typos which > makes debugging harder. > > What do you think ?
Regarding your example, I generally prefer using the plural form or "$row" being "$rows" than adding extra semantics. Being too verbose sometimes leads to: $messageString = "Hello World"; $ultimateAnwserInteger = 42; instead of: $message = "Hello World"; $ultimateAnwser = 42; There is nothing wrong being explicit about the content of the variable, but I would refrain from using types like "Array", "List", "Integer",... My 2 cents, Patrick