Onion vs. N-Layered Architecture

Adding facades are really the first step in building an onion architecture out of an n-layered architecture. So, yes, you can get many of the benefits right away. Testing is still problematic as you need to invert the dependency control. Controlling what has the facade is pointing to needs to move to the consumer, not … Read more

What is AOP, Dependency Injection and Inversion Of Control in Simple English

I understand your confusion and it took me some time to understand how these concepts were related together. So here is my (somehow personal) explanation of all this: 1. Inversion of Control Inversion of control is a design principle rather generic that refers to the decoupling of the specification of a behavior from when it … Read more

Should logging infrastructure be injected when using IoC/DI if logging facade is used?

Logging is just infrastructure. Injecting it is overkill. I personally don’t even use an abstraction layer. I use the static classes that the library provides directly. My motivation is that it’s unlikely that I’ll switch logging library in a current project (but might switch for the next project). However, you are using controllers in your … Read more

How do you reconcile IDisposable and IoC?

You definitely do not want to call Dispose() on an object that was injected into your class. You can’t make the assumption that you are the only consumer. Your best bet is to wrap your unmanaged object in some managed interface: public class ManagedFileReader : IManagedFileReader { public string Read(string path) { using (StreamReader reader … Read more

Koin how to inject outside of Android activity / appcompatactivity

There is the KoinComponent which comes to the rescue. In any class you can simply: class SampleClass : KoinComponent { val a : A? by inject() val b : B? by inject() } Extending KoinComponent gives you access to inject() method. Remember that usually it’s enough to inject stuff the usual way: class SampleClass(val a … Read more

About multiple containers in spring framework

From the Spring Official Website: The interface org.springframework.context.ApplicationContext represents the Spring IoC container and is responsible for instantiating, configuring, and assembling the aforementioned beans. The container gets its instructions on what objects to instantiate, configure, and assemble by reading configuration metadata. The configuration metadata is represented in XML, Java annotations, or Java code. Again from … Read more

Spring: Using builder pattern to create a bean

You may try to implement FactoryBean interface: public class HttpFactoryBean implements FactoryBean<HttpClient>{ private String host; private int port; public HttpClient getObject() throws Exception { return new StdHttpClient.Builder() .host(host) .port(port) .build(); } public Class<? extends HttpClient> getObjectType() { return StdHttpClient.class; } public boolean isSingleton() { return true; } public void setHost(String host) { this.host = host; … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)