Roboguice – Best dependancy Injection framework

Instead of creating dependancies on your own, use the third party or framework to do your job.

DI is used to move the responsibility of creating an object outside the main code and  give you back the reference to be used in your code. So very less from your end and DI has to handle it. So how to achieve this in android. we have lot of third party frameworks such as ButterKnife, Dagger 2, Android Annotations, Roboguice. These are popular DI framework libs used by most android developers. I have used Roboguide 3.0 for my project and quite appreciate the use of Roboguice DI framework.

Basically, Ideas being the DI is to avoid your class create objects on its own. instead get the object passed so you avoid tight coupling of your app.

Screen Shot 2016-05-12 at 2.15.16 pm

Voila!!…no need to do findViewByID everytime to load the widget. your code looks clean and neat.

for more info, refer Roboguice Wiki

Happy Coding 🙂

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s