Re: How to I access a logging class from any other class.
- From: CarmineM <carmine@xxxxxxxxxxxx>
- Date: Mon, 28 Nov 2005 22:42:54 +0100
ssg31415926 ha scritto:
I want to be able to write log data. How can I access my logging class from any class in the app, without passing a reference to it?
SH
Just my $0.02: Try investigate for:
1- Inversion Of Control 2- Dependency Injection 3- Service Locator
About 1 and 2 there's a widely known article from Martin Fowler, as well as heaps of stuff scattered over the net.
As of now, I'm quite enjoying reading about these subjects, and I think they could solve your problem.
I understand that Service Locator are containers where you can register services that client code can use later.
Something like:
myServices.Register(MyFavouriteLoggerType) myServices.Register(MyApplicationConfigType) .... .... myMarvelousClient.logger = myServices.getInstanceOf(MyFavouriteLoggerType) ....
Hope that helps.
Regards, Carmine .
- Prev by Date: Re: Model-View-Presenter (MVP) question
- Next by Date: Re: Decouple SQL queries from class in OOP design
- Previous by thread: Help on choosing a valid pattern: composite or not?
- Next by thread: How to generate statecharts from C code
- Index(es):