Names, Names, Names

Not for 'how-to' coding questions but PHP theory instead, this forum is here for those of us who wish to learn about design aspects of programming with PHP.

Moderator: General Moderators

User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Names, Names, Names

Post by neophyte »

What would you call a class that contained methods that output some sort of html ( selects, pagination, links, tables )?

class html
class view
class components

ideas?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Re: Names, Names, Names

Post by alex.barylski »

neophyte wrote:What would you call a class that contained methods that output some sort of html ( selects, pagination, links, tables )?

class html
class view
class components

ideas?
Depends...

Is this class capable of outputting everything that HTML supports? If not, HTML is likely to vague...

View is also vague as it tells you nothing, other than it's purpose...

Components is to specific, unless your class is simply outputing SELECT with it's array of OPTION's???

Perhaps a compound name would make better sense...

Is it an article builder or form builder?

- CHtmlArticle
- CHtmlForm

Are two which come to mind :)
User avatar
Oren
DevNet Resident
Posts: 1640
Joined: Fri Apr 07, 2006 5:13 am
Location: Israel

Re: Names, Names, Names

Post by Oren »

neophyte wrote:( selects, pagination, links, tables )
Well, I think I'd break it down into 4 classes: selects, pagination, links, tables; not 100% sure though.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

There wouldn't be one class to do it all.
So I probably would call the numerous, small classes after their DOM representation.
HTMLDocument, HTLMElement->HTLMForm/HTMLImage ....
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

HTMLGenerator.
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

Ok clearly, we all have different ideas of what it is your trying to do :P

Perhaps you should explain more, as one thing none of us are, is mind readers :P
User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

What is a table? It's made up of cells (of different types) organized into rows. But things are never just tables, usually, it's a list of database rows or an array of objects. In the latter case, we're clearly in the Model area.

So, if we want to transform that into html, we'd have to read the objects, get the fields in the object we want, format them in HTML, etc, etc, etc. But what if we transformed the array of objects into a Table composed of Rows composed of Cells? Then, the HTMLGenerator_Table takes these and turns them into HTML (or TextGenerator turns them into an ASCII table). This way, the code for generating tables (which can be pretty complicated), is generalized, so any list of objects can be transformed accordingly.

Actually, I don't really know. Whatever happened to templating?
alex.barylski
DevNet Evangelist
Posts: 6267
Joined: Tue Dec 21, 2004 5:00 pm
Location: Winnipeg

Post by alex.barylski »

^^^ In regards to templating...

It's exactly why I was under the impression he was building some kind of FORM builder class like the one in PEAR... :?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Sorry for letting you guys hang for so long.

The html methods are a series of "utilities" for that simple gallery thing of mine. In no way is it intended to be a total HTML solution or any major segment of it. It's just away of separating the view logic and html. Here's a list of method names. That'll give you an idea of what they do.

message
gallery_name
set_navigation (pagination)
next_image
previous_image
image_search
format_string
make_select
make_switch
bytes_to_kb
bread_crumb
set_footer
get_image_descrip
make_querystr (makes links)

I've got it penciled in as html right now. How bout html_utilities .... I dunno.

Suggestions?
alvinphp
Forum Contributor
Posts: 380
Joined: Wed Sep 21, 2005 11:47 am

Post by alvinphp »

I agree with Ambush Commander in that I would call the class html_generator though I personally don't like classes creating html as that should be seperated from your model. (unless I am misunderstanding what you are trying to do)
User avatar
sweatje
Forum Contributor
Posts: 277
Joined: Wed Jun 29, 2005 10:04 pm
Location: Iowa, USA

Post by sweatje »

alvinphp wrote:I agree with Ambush Commander in that I would call the class html_generator though I personally don't like classes creating html as that should be seperated from your model. (unless I am misunderstanding what you are trying to do)
Meaning classes can only participate in the Model portion of your application?
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I went with html_generator. I think it will suffice for my simple application.

Here's the general map in brief:

gg_init: initializes objects and calls the correct module class
gg_modulename_module: contains the view logic. Makes calls to file_data class and sends data to the html_generator methods
gg_html_generator: Takes the data makes the html and sends the output to gg_view
gg_view: Then outputs the view directly or returns the output in a variable.

What do you think?
alvinphp
Forum Contributor
Posts: 380
Joined: Wed Sep 21, 2005 11:47 am

Post by alvinphp »

sweatje wrote:
alvinphp wrote:I agree with Ambush Commander in that I would call the class html_generator though I personally don't like classes creating html as that should be seperated from your model. (unless I am misunderstanding what you are trying to do)
Meaning classes can only participate in the Model portion of your application?
For me the Classes is my Model. If the html was in your database though then my classes would be dealing with html in that it needs to grab the html from the database and then pass it to my controller.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

neophyte wrote: message
gallery_name
set_navigation (pagination)
next_image
previous_image
image_search
format_string
make_select
make_switch
bytes_to_kb
bread_crumb
set_footer
get_image_descrip
make_querystr (makes links)
That is a strange list. It seems to have everything from helper functions like bytes_to_kb to library classes like a pagination to View stuff like gallery_name. What do you see as the orginazation of these things?
(#10850)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Your right aborint it is a strange Franksteinish list of methods. Most of these are helpers of some sort or other. But most of them create/return a string with HTML tags. Should I further segment them? I'm not sure. That's been the problem with this app for sooooo long -- that is how should rolls be divided. So here they are again with some brief explanation. I've indicated on a few that they should be moved.

message -- returns a string with paragraph tags for some information to the user
gallery_name -- returns a the title of the gallery with h2 tags
set_navigation (pagination) -- creates pagination (html links)
next_image returns a link to the next image
previous_image returns a link to the previous image
format_string -pulls underscores out of directory and image names
make_select - generates html selector
make_switch - generates more different html selector
bread_crumb -generates html link string
set_footer - generates an html string
make_querystr (makes links) -- makes links

These should probably be else where.

image_search - looks though the entire file list for a matching image. (This one is moving -- file_data class?)
get_image_descrip -- pulls file data in (should probably move to file_data class)
bytes_to_kb -helper no html output (Might this belong in the file_data class?)
Post Reply