Any idea how to do it right?



Help! Too much classes :)

I hit the brick wall when designing something. It seams I can't find the way to solve a problem in elegant way.

I have multiple classes that use database to access or validate data. To manage creating the database connection and fetching data I use database abstraction layer
class. Everything is fine when I instantiate classes directly:

$s = new ClassName();

In this case I can design class to take database object as a constructor parameter or define method of the class that takes database abstraction object and makes class aware of database.

The problem arises when I use aggregate class (composite class?) that encapsulates many other objects that may use different databases. How to pass database connection settings or database abstraction layer object to objects being part of aggregate object?

Ralph
.



Relevant Pages

  • Re: Relational database & OO
    ... The RDB Data Model and the solution's Class Model will typically be different for non-CRUD/USER applications because they need to be optimized differently. ... all the business systems I've participated coding or designing spent little production time changing data. ... Given statistics like these it makes little sense to design your application or OO model before designing your database. ... And OO Class Models are routinely normalized as part of the basic paradigm methodology. ...
    (comp.object)
  • Re: Writing a DAL with TDD
    ... will use the database - which is what you advocated elsewhere. ... designing some new algorithm for a particular business scenario. ... you'll say that we "just" mock those things... ... talented developers, coupled with the strongest ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Writing a DAL with TDD
    ... will use the database - which is what you advocated elsewhere. ... designing some new algorithm for a particular business scenario. ... you'll say that we "just" mock those things... ... talented developers, coupled with the strongest ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: relationship vss join
    ... A AAZ ... B BCJ ... into the database initially, nor one on which referential integrity could be ... In the process of designing a database, ...
    (microsoft.public.access.queries)
  • Re: Writing a DAL with TDD
    ... naive to drive a database design from the point of view of the code that will use the database - which is what you advocated elsewhere. ... The benefits of TDD seem readily apparent - to me anyway - when applied to things like developing an application framework or parsing engine, or designing some new algorithm for a particular business scenario. ... or ASP.NET Web application, where a lot of code MUST interact with external systems or be dependent on things like ASP.NET Application state, Session state, or the HTTP request pipeline, then we're forced to make our unit tests depend on external things like the HTTP request pipeline or an external database. ... Let me see you mock the HTTP Request pipeline and unit test some code that overrides ASP.NET's Application.Init method. ...
    (microsoft.public.dotnet.languages.csharp)