I read Uncle Bob's book - "Clean Architecture". There is one chapter written by Simon Brown. He revised a few types of architecture. He offers to incapsulate implementations in packages.
If I bring the packages back and mark (by graphically fading) those types where the access modifier can be made more restrictive, the picture becomes pretty interesting (Figure 34.8)
I implemented one approach with spring DI:
com.my.service
public interface OrderService {
List<Order> getOrders();
}
and implementation:
com.my.service.impl
@Service
class OrderServiceImpl implements OrderService {
//...
}
It works fine because Spring finds OrderServiceImpl
marked @Service
annotation. OrderServiceImpl
is encapsulated as on the (Figure 34.8.)
But how can I repeat this without Spring annotation configuration? For example, if I use Spring java configuration, I should create a bean like this:
@Configuration
public class AppConfig {
@Bean
OrderService orderService(){
return new OrderServiceImpl();
}
}
But OrderServiceImpl
has a package modifier.
If I don't use Spring, what should I do to repeat this approach?