Posts

Showing posts from August, 2017

IOC(Inversion Of Control)

What is IOC(Inversion Of Control): Allowing your clients to define and use dependency of your service instead you defining it. Example You are creating a service called TextEditor and you want to use an open source library for spell check.  Client ----> Service ----> Dependency There are two ways you can do this. Define dependency in you service and let client do not worry about that. Create Instance on Dependency and let client decide which dependency to use. Let's understand each way through code snippet along with pros and cons.  1. Define dependency in you service and let client do not worry about that: Service: Service will look like public class TextEditor { private SpellChecker checker; public TextEditor() { this.checker = new SpellChecker(); } } Client: Client will use service like TextEditor textEditor = new TextEditor(); Pros: Your client does not need to worry or know about spell checker. Cons ...