Jump to content

First Application. Need help with code structure


scrubbicus

Recommended Posts

So I've finished up the basic framework and all the functionality of this application here and now I'm thinking the next step is going through the code and refining it because it was very neat at the beginning but gradually got less neat. All my other side project applications haven't really gotten to this step so I'm kind of at a loss.

 

I don't quite know what I'm looking for, just some direction I suppose. I don't know if my overview will even help or if it makes any sense but any help is appreciated. Thanks!

 

I'm trying to get myself acquainted to building object oriented application and I think I have the idea of how OOP is suppose to work. Anyway what I have is the main application class that handles the core of the application.

 

Extra Classes

I have other side classes like an encryption object, an object that handles POST data and SQL updates/insert queries and a class that handles sessions and the login/register/forgot password templates. All these classes are require() in through the main class constructor and initialized as a protected variable. Should I be initializing them like this?

 

Template Views

I've come to like the idea of using HTML/PHP template views for all my pages and then including them in through a function. I have a whole folder of the page templates I use and the way I use them is calling something like $application->get('template' , 'login'), that function include() the template then prints $html. Each template has PHP and HTML and is all combined into the $html variable, I find it easier to do whatever I need to do with that view if it's encompassed in a single variable.

 

Main View

I have an admin.php and public.php that just has the basic template of the website, these are just the index.php files for each of those modes. These are include() through the main class constructor.

 

Actions

I'm not sure if this is what it would be generally called but my main class constructor handles all these when they are isset(), then it goes through with calling functions to get the data put wherever it needs to be put. These are basically just any $_GET or $_POST information that the application needs to move forward.

 

Installation

The main class constructor redirects to setup if certain things aren't met. I have another class entirely for this that goes through the process and template views that are included through it.

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.