PDA

Click to See Complete Forum and Search --> : Names for my Classes...?


tomcatexodus
Aug 23rd, 2010, 10:40 AM
Hello!

I'm revamping a set of classes that I created some time ago for simple HTML document templating, and wanted to give it a bit of a linguistic touch-up. Here are the current names of, and functional purpose of each class. If someone can help me determine a logical and non-clashing set of names, that would be great.

abstract class Template- The root uninstantiatable class from which all other templating objects extend. Contains basic inheritable variables and methods.

class Page - The main source document.

class Component - An "included" document.

class Region - A section of a Page or Component defined for repetition.

class View - A section of a Region, that is repeated based on parameters.

The largest name conflict I see arising is with View, as I intend on using this set of classes in a simple MVC framework I'm constructing. Of course I could prepend each of the class names with something, but in terms of the names reflecting functionality, what should I change?

kows
Aug 23rd, 2010, 11:10 AM
if you're developing for PHP >= 5.3, you could put all of these classes in the namespace "templates" and then not really have to worry about them. in my framework, the helpers namespace has a few classes named after a model or controller class, each residing in their respective namespaces.

If you can't do this, then you could just name your view class RegionSection. or just Section.

tomcatexodus
Aug 23rd, 2010, 12:27 PM
I like that better kows, Section that is...

What about Component? I originally named it such for it's common use in my apps as a way of including things like Flash applications and other 'widgets'. Is there a more accurate name that could be given to such an object? (Not widget :rolleyes:)

kows
Aug 23rd, 2010, 06:09 PM
if a "component" is something like flash objects, then name it Asset. I have an Assets class that is used for loading CSS and JavaScript files. I don't like the name component or widget.

tomcatexodus
Aug 24th, 2010, 10:08 AM
It's not specifically for flash objects, nor CSS; an example of it's use could be for a simple front controller:

$page = new Page("default.html");
switch($_GET['page']){
case "":
$page->add_component("main", "home.html");
//do more stuff to the component
break;
case "news":
$page->add_component("main", "news.html");
//do more stuff to the component
break;
case "about":
$page->add_component("main", "about.html");
//do more stuff to the component
break;
}

This allows you to set parameters of the component, and even add further objects to the component (such as more components)

This can easily be used to add things like files containing flash objects, or anything for that matter. I mentioned flash objects because it works well to set parameters for the flash object element in the tag.

$page = new Page("default.html");
$page->add_component("flash_object", "flash.html");
$page->node["flash_object"]->set("bkg_color", "blue");
$page->node["flash_object"]->set("source", "some_file.flv");

Anyways, in short, its an "advanced" way of including external, partial files.

kows
Aug 24th, 2010, 10:18 AM
those things could still be considered assets. if you don't like that then I've got nothing -- try resource.

it's kind of hard to name a random thing you didn't make.

tomcatexodus
Aug 25th, 2010, 01:23 AM
Thanks kows. I do appreciate your answers. I'll probably stick with Component for now and just alias functions if necessary in the future (thankfully no direct object instantiation is available)