Hi,
Let's say we have an interface 'IA' for which we have an implementation 'A'. In our application domain, object 'A' never exists without a container object 'X'. So 'A' is never directly operated upon. 'A' aggregates in 'X'.
We don't want to expose 'A' to the outside world. For this we have taken the approach, not to have the public interface 'IA' and directly use implementation 'A' inside 'X'. Somehow I feel this is not the correct way. May be I am missing some fundamental OO concept.
Please opine.
PS: The reason for not providing 'IA' was given as: people might come up with their own random implementation for A and play with the system.
Ok. Let me put the actual problem here. I'm working on a web application. We have several layers - Dao, Doamin, Service, Web. Service layer provides various services on Domain objects through DAOs. We have domain objects - Wire and WireRequest. A WireRequest can have any number of Wires. Corresponding to these domain objects, we have two services - WireService and WireRequestService. WireService is injected in WireRequestService using spring.
When we expose our service.jar to clients they can potentially use the WireService independently and create Wire objects without WireRequest objects. We want to prevent that. Basically we want to control access to some services. (we could do this via authorization spring aspect, but wanted to use some OO way)
-Nayn