Pergunta

Why do people rely on comments as business logic ? (example CakePHP, Doctrine)

Doctrine example (from their docs, doctrine is relying on the comments as much as the code itself):

/**
 * @Entity @Table(name="products")
 **/
class Product
{
    /** @Id @Column(type="integer") @GeneratedValue **/
    protected $id;
    /** @Column(type="string") **/
        protected $name;
...

A few weeks ago I had to do a change in a CakePHP app and I had a problem where a callback was not called, only digging deep in their guts I found out that I need to put a docblock comment before the function definition for it to be recognized an called, I was in sock. Unfortunately I don't have the code now to give you an example.

I used many programing languages, but I find this trend that I only saw in PHP to be very annoying, and I think breaks the rules of programming.

Maybe somebody can shed some light on it, in my opinion this is a very bad practice, but I look forward to hear you opinion.

Thank you

Foi útil?

Solução

Its a relatively easy way (nice or not) to bring third party respectively new functions to a programming language without cause compiler errors. But you are right search for errors is sometimes annoying.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top