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

Post by neophyte »

BTW I'm pulling next_image and previous image into the file_data class.
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Post by Christopher »

Just a quick cut at your list (and probably wrong) but here is what they seem like to me.

View/View Helper (application specific)
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_footer - generates an html string

Library Classes (general purpose)
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
make_select - generates html selector
make_switch - generates more different html selector
bread_crumb -generates html link string
make_querystr (makes links) -- makes links

Helper Function
format_string -pulls underscores out of directory and image names
(#10850)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

Is there any danger that a library or helper class might devolve into "smelly code"? How do you know when it has crossed the line?


Library Classes (general purpose)
Are you suggesting separate classes for these functionalities?
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:Are you suggesting separate classes for these functionalities?
Not for each one, but Pagination, HTML Form FIeld, URL and Bread Crumb classes are very common. I have seen many different programmers build/use them and they are pretty similar from my experience.
(#10850)
User avatar
neophyte
DevNet Resident
Posts: 1537
Joined: Tue Jan 20, 2004 4:58 pm
Location: Minnesota

Post by neophyte »

I'm starting to see the rational. So "html_generator" is too broad because it doesn't really generate all html. So better to brake them into small classes or functions. At least their names will mean a bit more that way. Hmmmm, I think I like. Certainly no one pointed the "God Class" finger at a small class with a single purpose.
Post Reply