If you’re working with .NET, maybe you’re already familiar with the concepts of dependency injection and MVVM (Model-View-ViewModel) pattern. Some of popular dependency injection containers for .NET are Castle Windsor, Ninject or Unity… They are all good frameworks, it just depends on which you prefer. For example, I use Castle Windsor at company and Ninject at home so that I can understand and use both of frameworks. It’s just the matter of favorite. The MVVM pattern was introduced years ago when WPF came to market. This pattern makes use of data binding structure of WPF and helps programmer to separate the view completely from logic layer. For more details about this pattern you can read some articles on my site about MVVM. Today, I will discuss again about these concepts, however not for .NET application, but I would like to show how we can apply these concepts into Android app. The example I use in this post is a De-De-Dictionary app. In this app, I can add German vocabulary with his explanation (also in German :)) through a user interface or look up for a vocabulary. Nothing special than a real dictionary book.
Nowadays Design Patter is not only the task of software architects but also the necessary knowledge of programmers. Only by having a thorough grasp of design pattern the programmers can implement the complex software without causing a lot of bugs which will require a lot of time to fix at the maintaining period. Dependency Injection is a well-known pattern used frequently in developing environment. I think you did use this pattern already just don’t know its name. You can find a lot of books out there discussing about it, for example this Dependency Injection book. In this small blog I do not intend to write a long, loong, looong research about this pattern. I just give some code to demonstrate what Dependency Injection is.