Jump to content

Classes: keeping views from the business logic


mopardude

Recommended Posts

I was watching Stefan's vids on beginning class progamming over at the killerphp.com site. I get what he means about keeping the view code seperate from the business logic when creating classes. So does that mean it would be frowned upon to create a class that filled in table data for example? I mean I realize it is possible to program this, but like he said it is possible non-coders might have to make changes to the page like css or whatever. What would be the right way to handle this situation?

Link to comment
Share on other sites

I think that's a situation that falls somewhere in the middle. It isn't frowned upon -- CodeIgniter has a HTML Table class that I have used often, and it's quite useful. http://codeigniter.com/user_guide/libraries/table.html

 

I think the goal is to ensure that the class doesn't generate any unnecessary/excess markup (unnecessary inline styling, classes/ids that are set by the class and aren't easily editable, etc.) If you need a way to set CSS classes on the table/table columns or rows, make those easy to edit by calling a function within the class, rather than having the PHP class itself set that data.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...