SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2008
    Location
    UK
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    advice for oop novice

    could you offer some advice on the best way of handling dbase connections with oop?

    i have a mysql wrapper class. i create an object, a database connection, at the start of the page and pass it through to any other classes that need it - which is a lot of them.

    Similarly, i have a session class that i pass through to endless other classes.

    Is that the best way of doing it?

  2. #2
    SitePoint Guru bronze trophy TomB's Avatar
    Join Date
    Oct 2005
    Location
    Milton Keynes, UK
    Posts
    988
    Mentioned
    9 Post(s)
    Tagged
    2 Thread(s)
    There are three main options:

    -Passing dependencies manually through the constructor
    -A central registry to access the shared objects
    -A Dependency Injection Container

    Dependency injection is nicer because the dependency is visible in the class API.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •