There's the database then there's the presentation of the data from the database. But then there's this glue-code, so to speak, that inserts data into the database. Integrity must be kept between the different parts of the database. This integrity is kept by the "glue-code". So it'd be ideal to make this glue-code universal, global, and reusable. So should I put this glue-code or controller code in a separate file as a class or something? What directory structure is ideal for organizing my classes? Do you (as a developer) put your glue-code in a separate interface, whether it be a class or a collection of functions? If so, then where do you put these files in your directory model/architecture/design?
Just to clarify what I mean by glue-code in this post: It's the code that takes data, checks if it's valid, and inserts it into the database. It's the code that basically keeps the database the way it should be. It's PHP in this case, 'cause it's the server-side language I use.
All I want to know is the file structure for organizing files. I find that file organization is one of the least talked about things in web development, unless I just don't know where to look. If anyone could point me to some good resources on web site files organization, that would be nice. But my question is on where do I put my php class files?
Thanks for reading. All help is so very much appreciated.
Controller
Moderator: General Moderators
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Controller
I think the word that is confusing you is 'database' because there is no such thing in your code. From your description, it sounds like you are describing a Model class, or the Domain Model in general.JellyFish wrote:There's the database then there's the presentation of the data from the database. ...
Just to clarify what I mean by glue-code in this post: It's the code that takes data, checks if it's valid, and inserts it into the database. It's the code that basically keeps the database the way it should be.
Most architectures these days are 3-Tier. At the top is the Presentation Layer that deals with the Request and Response; in the middle is the Domain Layer (sometimes called Business) that contains the Models of the things in your application; and at the bottom is the Data Source layer that is responsible for moving data back and forth between the Domain Model objects and any datasources being used.
(#10850)
Re: Controller
@arborint: I'm not sure if I understand any of what you said. I know you where talking about an architecture in your second paragraph, but I didn't quite fully grasp the architecture you described.
I never meant to say that there is a database within my code. Of course there must be a interface within my code to communicate with the database, which is what I meant. The glue-code that I was talking about was the code that interfaces with the database.
I think I need to clarify my OP. When I came to post I was at a problem. Where should I put these class files that I'm going to make? I know I could put it anywhere that I wish, but then I got to wondering what is the more de facto standard for where to put such files. I figured I'd post and ask where to put these files, but then I didn't know if anyone actually has such files in there projects. So the question for this post is: Where would you recommend me putting my php class files; where do you put them?
I never meant to say that there is a database within my code. Of course there must be a interface within my code to communicate with the database, which is what I meant. The glue-code that I was talking about was the code that interfaces with the database.
I think I need to clarify my OP. When I came to post I was at a problem. Where should I put these class files that I'm going to make? I know I could put it anywhere that I wish, but then I got to wondering what is the more de facto standard for where to put such files. I figured I'd post and ask where to put these files, but then I didn't know if anyone actually has such files in there projects. So the question for this post is: Where would you recommend me putting my php class files; where do you put them?
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Controller
I would recommend looking at a couple of PHP frameworks to see how they organize the files. They are all fairly similar.JellyFish wrote:So the question for this post is: Where would you recommend me putting my php class files; where do you put them?
(#10850)