All in the <head>

– Ponderings & code by Drew McLellan –

– Live from The Internets since 2003 –

About

Class structure

18 November 2003

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?

- Drew McLellan

Comments

  1. § Matt: Here’s my $.02:

    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.
  2. § Dysfunksional.Monkey: I’d put it in the fridge.

    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.
  3. § Drew: Matt - wouldn’t two copies cause maintenance issues?

    Monkey - 8 mins in the microwave?
  4. § Dysfunksional.Monkey: Yea, if you’re looking for a hot solution which will burn the fingers of anyone who needs to get at your code! ;)

    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.
  5. § Drew: Yup, I’ve been fully LOAF compliant for weeks. Didn’t you notice?

    The comments system itself uses a LOAF subset - something I call a Simple LOAF Interactive Communications Enabler.
  6. § vlad: what’s loaf?
  7. § Drew: Check out the LOAF Wiki.
  8. § Dysfunksional.Monkey: That subset sounds interesting. I’m wondering now whether it’ll work with a wrapper technology I’ve been working on which i’ve dubbed Binded Unifying Transaction-Transparent E-commerce Resource.

    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.
  9. § Drew: We could always run that through a Transient Object-Applied Salient Transformation Error Rectifier to make it really kick arse.
  10. § george: Hmmm,
    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
  11. § Paul: I was just wondering whether you would like the Multi Architectural Realtime Modelling Algorithm in a Local Application Development Environment to use on your LOAF system?
  12. § Dysfunksional.Monkey: Is that a derivative of Object Related Algorithm-Negotiating Generic E-commerce System?
  13. § jason: I prefer to use the Java Application Module with LOAF.
    Specifically to interface with my custom Generic Rapid Application Processing Environment.

Photographs

Work With Me

edgeofmyseat.com logo

At edgeofmyseat.com we build custom content management systems, ecommerce solutions and develop web apps.

Recent Links

Affiliation

  • Web Standards Project
  • Britpack
  • 24 ways

About Drew McLellan

Photo of Drew McLellan

Drew McLellan has been hacking on the web since around 1996 following an unfortunate incident with a margarine tub. Since then he’s spread himself between both front- and back-end development projects, and now is Director and Senior Web Developer at edgeofmyseat.com in Maidenhead, UK (GEO: 51.5217, -0.7177). Prior to this, Drew was a Web Developer for Yahoo!, and before that primarily worked as a technical lead within design and branding agencies for clients such as Nissan, Goodyear Dunlop, Siemens/Bosch, Cadburys, ICI Dulux and Virgin.net. Somewhere along the way, Drew managed to get himself embroiled with Dreamweaver and was made an early Macromedia Evangelist for that product. This lead to book deals, public appearances, fame, glory, and his eventual downfall.

Picking himself up again, Drew is now a strong advocate for best practises, and stood as Group Lead for The Web Standards Project 2006-08. He has had articles published by A List Apart, Adobe, and O’Reilly Media’s XML.com, mostly due to mistaken identity. Drew is a proponent of the lower-case semantic web, and is currently expending energies in the direction of the microformats movement, with particular interests in making parsers an off-the-shelf commodity and developing simple UI conventions. He writes here at all in the head and, with a little help from his friends, at 24 ways.