1,105,344 Community Members

I'm Not Sure What it's Called

Member Avatar
mattyd
Posting Maven
2,677 posts since Oct 2006
Reputation Points: 76 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
Featured
 
0
 

I call it "Compartmentalization", that is, taking a long .php file and breaking it down into smaller components; Seperate .php files.

This will keep everything tidier, cleaner, more organized, reusable and I believe, more secure.

Example (Not my code - Maybe not a perfect example of this idea, but for illustration sake):

<?php

$server = "";
$dbuser = "";
$dbpass = "";
$database = "";

?>

What is this called?

Can anyone direct me to an online resource detailing this? Best practices. I need to do this and I need to do it correctly.

Thank you in advance!
Matthew

Member Avatar
pritaeas
mod_pritaeas
11,313 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
1
 

It's a modular approach. However, perhaps since you are redesigning anyway, you can try an Object Oriented approach.

Member Avatar
mattyd
Posting Maven
2,677 posts since Oct 2006
Reputation Points: 76 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 0 [?]
Featured
 
0
 

I just viewed your link on the OO approach. Very nice and educational.

I am trying to envision how this would work with my project. Not sure yet.

Although I am having some issues with the coding, the project is not as large on the back-end as people may assume. I will be storing much data, but the actual processing is simple.

One of my main concerns is security (A topic for a later time).

I will have to keep in mind your fine example of the keycard/lock. How does this relate to this project? (Rhetorical)

I believe this approach may be good when handling the registration of new Users, a process more complex than people think. Plus, I'm building my own, advanced Captcha system, so the OO approach may work there great. Also, I'm designing a security-bot; More on that in the future.

Thank you for your help!
Matthew

Member Avatar
pritaeas
mod_pritaeas
11,313 posts since Jul 2006
Reputation Points: 1,420 [?]
Q&As Helped to Solve: 1,835 [?]
Skill Endorsements: 155 [?]
Moderator
Featured
Sponsor
 
1
 

If you do not want to go OOP just yet, you can divide your code into logical functions and separate them into include files. Basically that's the first step, whether you use functions or classes.

You
This article has been dead for over three months: Start a new discussion instead
Post:
Start New Discussion
Tags Related to this Article