Page 1 of 1

Can't find this anywhere...

Posted: Wed Aug 03, 2005 1:50 pm
by Jr
Ok... I've been working on this Class stuff for a while now and I can't find ANYthing on ANY site that shows any kind of a 'standard' for a page class format. I realize that there are a million ways to do anything in any programming language but every site I look at is different from the last.

Basically I'm trying to figure out when creating new pages do I just extend the 'page' class that lays out the 'format' for the pages? Say I want some pages with a "right or left nav" and some without... how do I use multiple classes together sometimes and sometimes not while still keeping the origional 'page' class as the formating for all of it?

I think I have all of the ideas for this stuff pretty much down. I think I'm just getting hung up on the syntax at this point. Can someone help again... please?

Thanks,
Jr-

P.S. If there are any good referances to this topic (other then 'the manual') please feel free to post a link... as always, much appriciated...

Re: Can't find this anywhere...

Posted: Wed Aug 03, 2005 1:58 pm
by timvw
Jr wrote:Ok... I've been working on this Class stuff for a while now and I can't find ANYthing on ANY site that shows any kind of a 'standard' for a page class format. I realize that there are a million ways to do anything in any programming language but every site I look at is different from the last.
What do you consider a page? Is it only presentation? Does it handle user input?

An example: You have a script that generates a form with inputfields, afterwards the form can be submitted. If everything goes well, the script shows a thank you message, else it displays the form again.

Do you consider the thank html and the form html as the same page? Or are they different pages in the same script?
Jr wrote: Basically I'm trying to figure out when creating new pages do I just extend the 'page' class that lays out the 'format' for the pages? Say I want some pages with a "right or left nav" and some without... how do I use multiple classes together sometimes and sometimes not while still keeping the origional 'page' class as the formating for all of it?
It depends on how you see it. If you have a page that has something extra, you usually choose for composition. So you have a ExtraPage which has one (or more) instances of a Page.

If you have a page that behaves differently, you choose for inheritance (So you only have to code the things that work differently).

Posted: Wed Aug 03, 2005 2:09 pm
by Jr
say you have a 'page' class the formats the header, left side, content, right side and footer. I would assume that all the "formating" for that would be in one class.

Then you have another class that defines the header, another that defines the footer (and so on) so you can change those accordingly OR choose whether to even use them on the pages that you want or not.

Then you have another class that defines the 'content' for each page with case statements (for forms, etc. if needed) and that is what changes from section to section of the site.

On top of that you can have classes to build tables, layout small sections for different pages and break it up a little more. I'm not sure if this is the best way to do this but this seems like it would make the site more flexable. Thus easier to change later. Am I on the right track?

Posted: Wed Aug 03, 2005 2:50 pm
by timvw
Jr wrote:say you have a 'page' class the formats the header, left side, content, right side and footer. I would assume that all the "formating" for that would be in one class.
So you have a page that has components/subpages like header, leftside, content, rightside and footer.
Jr wrote: Then you have another class that defines the header, another that defines the footer (and so on) so you can change those accordingly OR choose whether to even use them on the pages that you want or not.
Again, you have a page that has components/subpages.
Jr wrote: Then you have another class that defines the 'content' for each page with case statements (for forms, etc. if needed) and that is what changes from section to section of the site.
So basically, this class is again a page, but with a different content component/subpage?
Jr wrote: On top of that you can have classes to build tables, layout small sections for different pages and break it up a little more.
So you are saying, that you want a page that has different components/subpages that generate html.
Jr wrote: I'm not sure if this is the best way to do this but this seems like it would make the site more flexable. Thus easier to change later. Am I on the right track?
Just build what you have in mind and give it a try. If requirements change, count how long it would take to refactor/change the code so the new requirements are fullfilled. Compare with the cost of starting from scratch, and choose the least expensive. Then you will be able to say if the code was really flexible.

I use a MVC framework which allows me to handle user-input in a different place than the generation of HTML.

I usually don't divide my pages in subpage classes, i simply use include... But if i need to do some source-highlight trick or so in the page, i do not hesitate to make use of a class like GeSHi.