Here’s a web application architecture question to throw out to the floor. I have a small group of related tables, which together hold the data for one module of an application. I’m writing a class to handle writing to and reading from these tables in a nice OO way. Without exception, the reading is performed on the ‘public’ side of the app, and the writing on the ‘admin’ side. The admin side also needs to read. So the question. Where to I keep my class file?
I don’t wish to split the class into two, because it is conceptually one object. Splitting it would compromise its integrity. Plus many of the methods are shared.
The answer seems obvious – put it in a central location that both systems can access, right? In this case that means placing it somewhere in the public site structure and linking to it from the admin site. This is ugly because it creates a dependency between the two systems. If either file structure changes, something’s going to break. That’s probably still the best solution, but I wondered if anyone else had any better ideas?



Comments
Keep the class file in both locations; public and private. But, in order to enforce the read-only business requirement, have some sort of app config variable that you can set to allow/block write access within your class.
And/Or, you can set it so that the two sides, admin and public, use two different db usernames to access (which I always do anyway). That way, you can grant execute permissions (for procs) or table-level access properly for each username. Priciple of least priveledge and all that.
Pop it in, let it chill-out till tomorrow, and you’ll end up with a nice fresh answer.
Personally, I keep everything in an ”application folder”, which has a class directory, www dir, and any other dir I need. The www dir is set live, everything else is then outside this, and relativly secure.
Monkey - 8 mins in the microwave?
I’d take the plunge and split it into two. They’re essentially seperate entities anyway. One reads, the other writes. One part of your app neads to read [include read], the other needs to read and write [include both]. If they’re written well you can use them for other applications too.
Oh, by the way - have you made it LOAF compatible? Or your site? Looks set to over-take XML in the standards arena. I’d use either the XSL or PHP version.
The comments system itself uses a LOAF subset - something I call a Simple LOAF Interactive Communications Enabler.
This system works as part of a web-service i’ve also developed; Personal E-commerce Notification and Unit Tracker.
It might be worth seeing what will happen if we use a Knowledge-based Network-Indepentant Formatting Environment to slap what I’ve done on to what you’ve done. You never know, we might end up with something quite satisfying.
I think I would create a superclass and then 2 subclasses, which inherit will inherit from the superclass. After all they share many of the same data members and methods. Now if only you could use interfaces in PHP
george
Specifically to interface with my custom Generic Rapid Application Processing Environment.