Closed GoogleCodeExporter closed 9 years ago
Thanks for the coding tips.
You say that using constants in classes is bad, but you haven't given any
reasons. Is there an article somewhere that you could point me to that might
shed some more light on this notion?
| Any why all of your methods are "final"?
I declared them as final because it allows me to be sure that I can change
things without worrying about affecting some extending class. Now that I think
about it, final is actually redundant on private functions. I will probably
remove the final from private functions soon.
| And why you use "private" but not "protected"?
See above.
| And why do you write... but not just...
I think it is easier to read.
Also, PLEASE DON'T USE ALL CAPS EVER. This is very bad!
Original comment by joe.lencioni
on 29 Jul 2010 at 1:32
Hi Joe!
Thank you for your answer, and sorry for my CAPS :)
> You say that using constants in classes is bad, but you haven't given any
reasons. Is there an article somewhere that you could point me to that might
shed some more light on this notion?
1. Because constant names are global, and there may be a problem if some
project already use constants with names like in your lib. There is one issue
http://thedeployer.com/2009-04-why-should-we-use-php-constants-inside-classes
but:
2. Some developers will want to use > 1 instances of library in one PHP-process
but with different configs. In this case it will be impossible if configuration
is realized by any constants.
> I declared them as final because it allows me to be sure that I can change
things without worrying about affecting some extending class. Now that I think
about it, final is actually redundant on private functions. I will probably
remove the final from private functions soon.
1. As I see in class SLIR all method are "final". Don't you think that it will
be much better just to define class SLIR as final and forget about "final"
methods? Like this:
final class SLIR {
// ...
}
2. But anyway much better if there will be some public/protected
interface-methods that users can override like they need.
3. Talking about using "private" but not "protected", just take a look to this
article
http://www.leftontheweb.com/message/My_privates_are_not_public_they_are_protecte
d may be you will change your mind.
Original comment by barbushin
on 29 Jul 2010 at 1:56
This issue was closed by revision r123.
Original comment by joe.lencioni
on 21 Dec 2010 at 6:58
Original issue reported on code.google.com by
barbushin
on 29 Jul 2010 at 4:59