Earlier quoted context omitted.
It's really bad practice. We all want to get stuff done, but don't complain when you end up in spagethi code hell. Some people are going to see that and think that's an ingenious use of comments, and then start to do the same in everything they write soon after. If you ever seen Preprocessor abuse in C++ you know what I mean.
give us a pointer to an example please.
PHP Annotations Are a Horrible Idea
91–100 of 127 posts
Re: PHP Annotations Are a Horrible Idea
#92However I do also acknowledge that putting important information into comments can be somewhat dangerous. Doctrine does support storing metadata in yaml and xml files too, but in that case you need to ensure that changes to your model class get reflected in the mapping file.
Re: PHP Annotations Are a Horrible Idea
#93Re: PHP Annotations Are a Horrible Idea
#94This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…
> ...because I have other shit I need to do. Ironically, that's often also the attitude of programmers who don't use comments in their code (in any language).
* Comments that describe what the code does are a complete waste of time. The code already tells you what it does.
* Comments that describe why the code was written has more merit, but I cannot see how the following is any real improvement over the first point:
// Investments of this type have always added the interest
// to the principle. Who are we to question convention?
$balance = $principle + $interest;
I am one of those poor commenters, so I really have no idea what could be said about that line that isn't already known. If you say not everything needs to be commented, then where does the line get drawn? In most cases, the vast majority of your code should be no less obvious than this.* Some suggest the method signature and invariants should be documented, but that seems like just another exploitation of comments to deal with limitations of the language and is no better than putting annotations in the comments.
* I've seen code examples for using a given method in the comments, but that is better left to your test suite. Not only then can the reader see the example, but you can verify your method works at the same time without cluttering up the original codebase to boot.
If you are doing something weird, then yes, I am with you that comments are a big deal. However, if you are doing weird things on a regular basis I have to question your reasons for doing so. You shouldn't have to do weird things 99% of the time.
With that, teach us wise one. How can we all become great commenters so that we do not have to brush it off as something we do not have time for?
Re: PHP Annotations Are a Horrible Idea
#95This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…
That of course, leads to the issue of having your configuration separate from your implementation/code.
Re: PHP Annotations Are a Horrible Idea
#96This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…
Any editor that starts with comments collapsed is going to hide the functionality buried in comments. But that's a minor issue. Comments are exactly that - comments. They are not intended to be executed and can be changed or removed at will. They are not necessary . They exist to provide further explication for code that is not self-documenting (or just plain programmer wankery). This changes the deal. This means tha…
public class Sample { }
I think that's a better approach as it makes the annotations an actual language construct and keeps them out of comments.Re: PHP Annotations Are a Horrible Idea
#97Earlier quoted context omitted.
Some people don't like 4 space indentations, some don't like using tabs, and in most cases there's just an icky feeling behind it. Who's right? In your own post, you give a reason for why you think (and not feel) it is wrong, and that's the right way to do. Icky feelings aren't. Maybe people saying that it feels wrong are crossing a line too?
You can be intuitively against something, but not be able to work out why. A few hours later, you often realize the rational reasons behind your original feeling.
Re: PHP Annotations Are a Horrible Idea
#98Earlier quoted context omitted.
give us a pointer to an example please.
That's a silly thing to require a citation for unless you're unfamiliar with preprocessor directives.
You could have pointed out all the things that are done in the C obfuscation code contests, to illustrate your point, but maybe this is silly. Also, you start your point from the spaghetti code hell that C macros let people fall into (I guess you where thinking about #ifdef conditionals), but I don't see how annotations could generate that problem. Imho, your point is flawed.
C macros are useful, and when not misleadingly used, very effective at abstracting things in order to get the important structures apparent. That is what annotations attempt to provide. Regarding PHP annotations, the problem here is that it's difficult and time consuming to parse a PHP script, whereas comments are an easy target. SensioLabs went the easy road, perhaps also in the hope that someday annotations would find their way in PHP, and people would just have to remove the comments around them to be compliant.
Re: PHP Annotations Are a Horrible Idea
#99This is pure horse pucky. First of all PHP isn't about elegance and I find it a teeth grinding experience when people complain about it not being so. PHP is about getting stuff done. He doesn't offer one good valid technical reason why not to use comments for meta-programming PHP other than "it just feels wrong" and an "icky feeling" which is entirely subjective. "Reliance on Yet Another Library"? C'mon. The fact tha…
Re: PHP Annotations Are a Horrible Idea
#100Earlier quoted context omitted.
by escaping them? Some annotations are meant to affect the code, some aren't. Those who do and need to be given as pure comments need to be escaped.
So now you have a system for putting comments inside your comments ? Are you going to eventually start putting meta-annotations inside your meta-comments, and inventing meta-meta-comments so you can comment on the meta-annotations?
In other words, there is no need for some kind of elaborate escapes-upon-escapes method here, all you have to do is not start a comment line with *@.