All in the <head> – Ponderings and code by Drew McLellan –

Class structure

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?