Thoughts, comments, anything?
P.S Read it till the end before posting here
Edit: The link I've posted was pointing to the second page of the topic - by mistake. I fixed that and now it points to the first page
Moderator: General Moderators
Adam A Flynn wrote:On the subject of comments, I would always opt for better comments over system performance. There is certainly a point where comments can just be cumbersome (and I think that point depends on the individual developer), but, we're talking about a few milliseconds in the difference here. Buying a stick of RAM for $100 is way cheaper than me wasting a few hours trying to figure my way through poorly documented code at $50/hr.
Code: Select all
if ($bob){
// bob
}
else {
// no bob
}Code: Select all
if (!$bob){
// no bob
}
else {
// bob
}I actually try to avoid using ! by itself if possible, not for performance, but because it makes the code more readable if you do a direct comparison (and if you can do "===" or "!==" then bonus points for more readable code that *improves* performance). A lone ! can easily get lost in the mix when you are scanning code.Xoligy wrote:and even if it went against logical thinking you shouldn't use the '!'.
Code: Select all
if ($bob !== false)
{
// bob
}
else
{
// no bob
}One of the reasons it is silly is that comments is only one part of maintainability, but often gets conflated as maintainability. There are a number of issues, which I might break into a few broad categories: code quality, good design, documentation, unit tests. Comments are only a subset of documentation. I think I would prefer good design and code quality (i.e. consistency, quality of naming, algorithm choice, modularity, etc.) to comments if given a choice. I might even say that reasonable external documentation covering architecture, design decisions, etc might be more helpful. And unit tests are both the best kind of documentation and something that provides confidence when making changes.Ambush Commander wrote:I think the whole debate on comments is silly.