Jump to content

Looking for some application design guidance


Simonss

Recommended Posts

Hi All,

New to php freaks and also fairly new to PHP.

Here is what im up to;

Im creating a fairly beefy application that involves probably around 60% updating to 40% querying of a database.

What I dont currently know is the best practices' I should be applying to this application.  My experience of Java and JSP, OO design etc has brought me to this.

The Three layers
Top: Displaying of objects to user - basic objects that display info in the way a user would expect
Middle: Holding Classes that are used to maintain information for specific instance of classes - these classes only really have getters and setters, nothing fancy.
Bottom: Database interaction, queries and updates - each of these classes is used to create instances of the Middle layer class associated to it.  For example TemplateSQL is used to create a Template instance class.

Am I on the right track with this?  Is this poor design?

If anyone can give some hints, tips, books/articles that relate to this type of thing it would be much appreciated.

Hopefully as I get some more experience with this and further projects I can start helping other people rather than just turning up here and asking away!

TIA,

Simon
Link to comment
Share on other sites

What you're describing is a Three-tier architecture. There is nothing "wrong" about it. You'll need some pretty well thought through interfaces for the tiers to interact.

If you're more or less in the dark on implementing this architectural design pattern, may I suggest the MVC as an alternative. Some might argue that n-Tier achitecture is more applicable to webdevelopment due it's linear nature, at least the MVC has plenty of resources relevant to php.

There not ALL that different. Check out the resources sticky.
Link to comment
Share on other sites

Well Ive had a further day of development and have already started to apply the MVC pattern.

While it can seem like a long winded way to go about things sometimes I know that in the end this is going to help me out.  Have now got three groups of classes.

Model classes interact with the DB and this is also the category I would put the standard classes (getter and setter classes).

View classes just call for the appropiate data and output it.  Most of the work to generate the html is done in the Controller classes.  Currently these classes also use a short switch statement to determine what function should be called.  Eg an Event can be created, edited or deleted hence the action variable ($_GET) is checked and used to determine the function called.

Controller classes hold everything together. Do most of the work etc.

One point im slightly unsure about - I read a little about in another thread but this is slightly different.
Is there anything wrong with the switch statement in the view? Is there a better method that I should be using?

Thanks,
Simon
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.