PHP Classes

Putting Html code in php is the worst thing a serious program...

Recommend this page to a friend!

      CRUD Class  >  All threads  >  Putting Html code in php is the...  >  (Un) Subscribe thread alerts  
Subject:Putting Html code in php is the...
Summary:Package rating comment
Messages:3
Author:andrea
Date:2007-12-15 15:03:09
Update:2008-01-06 11:22:28
 

andrea rated this package as follows:

Utility: Good
Consistency: Bad
Examples: Insufficient

  1. Putting Html code in php is the...   Reply   Report abuse  
Picture of andrea andrea - 2007-12-15 15:03:09
Putting Html code in php is the worst thing a serious programmer should do.
Classe don't have a getter and/or a setter method for reading/writing attributes (no information hiding, a thing on wich oop is based)
upper case characters are used for class attributes.
DocComment is neither well formed nor used for every method.
Programming style is linear but not standard.
However the package should be really useful.

  2. Re: Putting Html code in php is the...   Reply   Report abuse  
Picture of Cesar D. Rodas Cesar D. Rodas - 2007-12-15 16:29:55 - In reply to message 1 from andrea
Can u explain why put HTML is worst? If you don't understand HTML that's your problem ;). This did this class like this for save time at the time of made a CRUD (the most common task for almost every programmer). What I'll do is generate the template the first time. Then the programmer will be able to modify the template.

And all what you wrote are only conventions, my code is not wrong if I break some of them ;). Example, the class doesn't need a setter or getter because all parameters are set in the constructor.

Use setter/getter for hide information is for PHP5 and greater (private, public), you can do that, but almost all my projects are PHP4 compatible.

"Upper case characters are used for class attributes" this is java convention.

"DocComment is neither well formed nor used for every method." I'll fix this.

"Programming style is linear but not standard." I don't understand this point, could you clarify please?

Thank your comments, I'll take time this weekend to made the code more readable.

best regards.

  3. Re: Putting Html code in php is the...   Reply   Report abuse  
Picture of andrea andrea - 2008-01-06 11:22:28 - In reply to message 2 from Cesar D. Rodas
Sorry I almost forgot the discussion!
I'm talking about having presentation into behavioral code, if your class should be used in a different environment the class shouldn't return any output but error messages (raising exceptions or using error codes for template-side error management).

In my opinion, in an application, the code shouldn't know about the final rapresentation of it's behavior.

So keep html and php (as well html and css, and html and javascript) separated.

The same is for example with html and css, html describes just how the document is made, css describes how the document should be seen.

Imagine two people, a designer which works only with html and a programmer that should only work with php.
If the designer wants to add something to the output he MUST NOT see the php code because he's a designer (and even doesn't know what the code does), he works only with visual representation of what code does.
and equal, if a programmer have to path something, he must not have presentation code into behavioral code.
It make sense of thinking about a designer that modify the behavior of the application for editing it's representation.

this is my point of view.


Php4 is gone, switch to php5 as soon as possible :D

Yep the rest are just conventions, so do everything you want :)
I've noticed you don't have a real standard way to write code, so i found different styles of programming within the same file.

Sorry for my english :P