Dagger 2 Android. Defeat the Dahaka" Garima

Size: px
Start display at page:

Download "Dagger 2 Android. Defeat the Dahaka" Garima"

Transcription

1 Dagger 2 Android Defeat the Dahaka" Garima

2 Garima

3 Garima

4 Garima

5 Garima

6 Garima

7 Garima

8

9 Dagger 2 Testing DataBinding

10 Dagger 2 Android Defeat the Dahaka" Garima

11 POP QUIZ Dagger2? Dagger Android Prince

12 ABOUT THE TALK

13 Theme: Prince of Persia Prince uses Dagger Dagger can reverse time Dahaka, (guardian of timeline) Dahaka comes to kill the Prince.

14 Analogy Prince = Us Dagger = Dagger Dahaka (Enemy) = Generated Code, Complexity

15 Analogy Developer uses Dagger Developer starts backtracking the generated code Developer is chased by the Dahaka (complexity of generated code)

16 Agenda Brief Introduction - Codes of Time Scopes - Face of the Scopes Custom Scopes Component Dependencies - Unleash the Beast Demo App Dependent Component Subcomponent Intermediate Concepts - Defeat the Dahaka Dagger Android - Befriend the Beast

17 Who? Assumption : Basic familiarity with Dagger Intermediate

18 INTRODUCTION CODES OF TIME

19 Droid

20 Droid of Asia public UserManager() { this.service =

21 Dependency Creation Disadvantages

22

23 Dagger 1 Advantages Testable

24 Dagger 1 Disadvantages Reflection Runtime Graph Composition God Module Difficult to

25 Dagger 1 Disadvantages

26 Dagger 2 Advantages No Reflection Compile-time Graph Composition Traceable code Better

27 SCOPES FACE OF THE DAHAKA

28 Scope Annotation from javax.inject package How long a scoped instance lives What happens if : No Scope specified? Annotation is specified?

29 @Singleton Another annotation from javax.inject package Scope of dependency is throughout the application Two ways to re-use dependencies : Annotate Provider methods Annotate the Dependency class itself

30

31 = public interface AppComponent { Application application();

32 = public interface AppComponent { Application application(); AppComponent

33 CASE 1 DEPENDENCY

34 public class AppModule { private final Application application; public AppModule(Application application) { this.application = annotation Application applicationprovider() { return application;

35 public class AppModule { private final Application application; public AppModule(Application application) { this.application = annotation Application applicationprovider() { return application;

36 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = AppModule_ApplicationFactory.create(builder.appModule);

37 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = AppModule_ApplicationFactory.create(builder.appModule);

38 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = AppModule_ApplicationFactory.create(builder.appModule);

39 CASE 2 DEPENDENCY

40 public class AppModule { private final Application application; public AppModule(Application application) { this.application Application applicationprovider() { return application;

41 public class AppModule { private final Application application; public AppModule(Application application) { this.application Application applicationprovider() { return application;

42 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = DoubleCheck.provider( AppModule_ApplicationFactory.create(builder.appModule));

43 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = DoubleCheck.provider( AppModule_ApplicationFactory.create(builder.appModule));

44 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = DoubleCheck.provider( AppModule_ApplicationFactory.create(builder.appModule));

45 DaggerAppComponent public final class DaggerAppComponent implements AppComponent { private Provider<Application> applicationprovider; /** other code **/ private void initialize(final Builder builder) { this.applicationprovider = DoubleCheck.provider( AppModule_ApplicationFactory.create(builder.appModule));

46 DoubleCheck (dagger.internal) Memoizes value using Double-Check idiom.

47 DoubleCheck (dagger.internal) Memoizes value using Double-Check idiom. public T get() { Object result = instance; if (result == UNINITIALIZED) { synchronized (this) { result = instance; if (result == UNINITIALIZED) { result = provider.get(); Object currentinstance = instance; // other code instance = result; provider = null; return (T) result;

48 DoubleCheck (dagger.internal) Memoizes value using Double-Check idiom. public T get() { Object result = instance; if (result == UNINITIALIZED) { synchronized (this) { result = instance; if (result == UNINITIALIZED) { result = provider.get(); Object currentinstance = instance; // other code instance = result; provider = null; return (T) result;

49 DoubleCheck (dagger.internal) Memoizes value using Double-Check idiom. public T get() { Object result = instance; if (result == UNINITIALIZED) { synchronized (this) { result = instance; if (result == UNINITIALIZED) { result = provider.get(); Object currentinstance = instance; // other code instance = result; provider = null; return (T) result;

50 Take Aways DONT Scope All the Things! Scoping has overheads. By-default no Scope. Scope only when needed Like for Heavy Mutable Objects

51 @ragdroid

52 @Reusable Limit the instantiation. Use when Exact same instance not needed. Not tied to any component or subcomponent. Can Have multiple sub-components caching different instances. Use for heavy immutable dependencies.

53 = ReusableModule.class) public interface ReusableComponent { SomeObject someobject();

54 = ReusableModule.class) public interface ReusableComponent { SomeObject someobject();

55 public class SomeObject public SomeObject() {

56 DaggerReusableComponent public final class DaggerReusableComponent implements ReusableComponent { /** other code **/ Provider<SomeObject> someobjectprovider; private void initialize(final Builder builder) { this.someobjectprovider = SingleCheck.provider(SomeObject_Factory.create());

57 DaggerReusableComponent public final class DaggerReusableComponent implements ReusableComponent { /** other code **/ Provider<SomeObject> someobjectprovider; private void initialize(final Builder builder) { this.someobjectprovider = SingleCheck.provider(SomeObject_Factory.create());

58 DaggerReusableComponent public final class DaggerReusableComponent implements ReusableComponent { /** other code **/ Provider<SomeObject> someobjectprovider; private void initialize(final Builder builder) { this.someobjectprovider = SingleCheck.provider(SomeObject_Factory.create());

59 SingleCheck (dagger.internal) Memoizes value using simple lazy initialization and caching

60 SingleCheck (dagger.internal) Memoizes value using simple lazy initialization and caching public T get() { Provider<T> providerreference = provider; if (instance == UNINITIALIZED) { instance = providerreference.get(); provider = null; return (T) instance;

61 SingleCheck (dagger.internal) Memoizes value using simple lazy initialization and caching public T get() { Provider<T> providerreference = provider; if (instance == UNINITIALIZED) { instance = providerreference.get(); provider = null; return (T) instance;

62 @Singleton Heavy mutable object Heavy immutable object

63 GOD

64 App AppComponent = public interface AppComponent { Application public class AppModule { private final

65 Big App AppComponent = public interface AppComponent { Application public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() {

66 Big App AppComponent = public interface AppComponent { Application public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() {

67 God App AppComponent = public interface AppComponent { Application public class AppModule { private final Application applicationprovider() { Application applicationprovider() { return application; Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() {

68 God App Module How

69 God App Module Splitting

70 Splitting App AppComponent ApiModule = public interface AppComponent { Application public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() {

71 Splitting App AppComponent = public interface AppComponent { Application public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { return

72 Splitting App AppComponent = public interface AppComponent { Application modules = AppModule.class, public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { return

73 Splitting App Module modules = AppModule.class, ApiModule.class) OR public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { return

74 Splitting App Module modules = AppModule.class, ApiModule.class) AppModule includes = ApiModule.class) public class AppModule { private final Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { Application applicationprovider() { return

75 Splitting

76 How to Improve? Better Scope Management More modularity Custom @ragdroid

77

78 Custom Scopes

79 Multiple Components 1. Dependent Components 2. Sub-Components

80 COMPONENT DEPENDENCIES

81

82 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Fragments Fragments

83 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Fragments Fragments Launch

84 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Launch pikachu Login Fragments Fragments

85 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Launch pikachu Login Fragments Inventory Fragments

86 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Launch pikachu Login Fragments Inventory Log-Out Fragments

87 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Launch pikachu Login Fragments Inventory Log-Out jigglypuff Fragments

88 Application AppComponent UserComponent Login Home Component Items Component Login Component Home Component Items Component Launch pikachu Login Fragments Inventory Log-Out jigglypuff Fragments Inventory

89 Pokemon App

90 SUB COMPONENT VS

91 @Singleton <<interface>> AppComponent schedulerprovider

92 @Singleton <<interface>> AppComponent schedulerprovider AppComponentImpl schedulerprovider() usermanager Sub Component

93 @Singleton <<interface>> AppComponent schedulerprovider AppComponentImpl schedulerprovider() UserComponentImpl schedulerprovider pokemon Dependent Component Sub Component

94 @Singleton <<interface>> AppComponent schedulerprovider AppComponentImpl schedulerprovider() UserComponentImpl schedulerprovider pokemon Dependent Component Sub Component

95

96 AppComponent = arrayof(appmodule::class, ApiModule::class)) interface AppComponent { fun loginbuilder(): LoginComponent.Builder fun schedulerprovider(): BaseSchedulerProvider

97 AppComponent = arrayof(appmodule::class, ApiModule::class)) interface AppComponent { fun loginbuilder(): LoginComponent.Builder fun schedulerprovider(): BaseSchedulerProvider

98 AppComponent = arrayof(appmodule::class, ApiModule::class)) interface AppComponent { fun loginbuilder(): LoginComponent.Builder fun schedulerprovider(): BaseSchedulerProvider

99

100 DahakaApplication class DahakaApplication : Application() { override fun oncreate() { super.oncreate() appcomponent = DaggerAppComponent.builder().application(this).build()

101 DahakaApplication class DahakaApplication : Application() { override fun oncreate() { super.oncreate() appcomponent = DaggerAppComponent.builder().application(this).build()

102 DEPENDENT COMPONENTS

103

104 = arrayof(appcomponent::class), modules = interface UserComponent interface Builder fun pokemon(pokemon: Pokemon): Builder

105 = arrayof(appcomponent::class), modules = interface UserComponent interface Builder fun pokemon(pokemon: Pokemon): Builder

106 = arrayof(appcomponent::class), modules = interface UserComponent interface Builder fun pokemon(pokemon: Pokemon): Builder

107 Binding Pokemon Two ways of Providing / Binding Pokemon to graph 1. UserModule Constructor

108 UserModule public abstract class UserModule { private final Pokemon pokemon; public UserModule(Pokemon pokemon) { this.pokemon public Pokemon providepokemon() { return pokemon;

109 UserModule public abstract class UserModule { private final Pokemon pokemon; public UserModule(Pokemon pokemon) { this.pokemon public Pokemon providepokemon() { return pokemon;

110 UserModule public abstract class UserModule { private final Pokemon pokemon; public UserModule(Pokemon pokemon) { this.pokemon public Pokemon providepokemon() { return pokemon;

111 = arrayof(appcomponent::class), modules = interface UserComponent interface Builder fun pokemon(pokemon: Pokemon): Builder

112 UserComponent = arrayof(appcomponent::class), modules = interface UserComponent interface Builder fun pokemon(pokemon: Pokemon): Builder

113

114 class constructor(private val service: PokemonService) { var usercomponent: UserComponent? = null private set public fun createusersession(pokemon: Pokemon) { usercomponent = DaggerUserComponent.builder().appComponent(DahakaApplication.app.appComponent).pokeMon(pokemon).build()

115 class constructor(private val service: PokemonService) { var usercomponent: UserComponent? = null private set public fun createusersession(pokemon: Pokemon) { usercomponent = DaggerUserComponent.builder().appComponent(DahakaApplication.app.appComponent).pokeMon(pokemon).build()

116 class constructor(private val service: PokemonService) { var usercomponent: UserComponent? = null private set public fun createusersession(pokemon: Pokemon) { usercomponent = DaggerUserComponent.builder().appComponent(DahakaApplication.app.appComponent).pokeMon(pokemon).build()

117 (Generated) DAGGER

118 DaggerUserComponent (Generated) public final class DaggerUserComponent implements UserComponent { private Provider<BaseSchedulerProvider> schedulerprovider; private void initialize(final Builder builder) { this.schedulerprovider = new AppComponent_schedulerProvider(builder.appComponent); private static class AppComponent_schedulerProvider implements Provider<BaseSchedulerProvider> { private final AppComponent public BaseSchedulerProvider get() { return appcomponent.schedulerprovider();

119 DaggerUserComponent (Generated) public final class DaggerUserComponent implements UserComponent { private Provider<BaseSchedulerProvider> schedulerprovider; private void initialize(final Builder builder) { this.schedulerprovider = new AppComponent_schedulerProvider(builder.appComponent); private static class AppComponent_schedulerProvider implements Provider<BaseSchedulerProvider> { private final AppComponent public BaseSchedulerProvider get() { return appcomponent.schedulerprovider();

120 DaggerUserComponent (Generated) public final class DaggerUserComponent implements UserComponent { private Provider<BaseSchedulerProvider> schedulerprovider; private void initialize(final Builder builder) { this.schedulerprovider = new AppComponent_schedulerProvider(builder.appComponent); private static class AppComponent_schedulerProvider implements Provider<BaseSchedulerProvider> { private final AppComponent public BaseSchedulerProvider get() { return appcomponent.schedulerprovider();

121 DaggerUserComponent (Generated) public final class DaggerUserComponent implements UserComponent { private Provider<BaseSchedulerProvider> schedulerprovider; private void initialize(final Builder builder) { this.schedulerprovider = new AppComponent_schedulerProvider(builder.appComponent); private static class AppComponent_schedulerProvider implements Provider<BaseSchedulerProvider> { private final AppComponent public BaseSchedulerProvider get() { return appcomponent.schedulerprovider();

122 DaggerUserComponent (Generated) public final class DaggerUserComponent implements UserComponent { private Provider<BaseSchedulerProvider> schedulerprovider; private void initialize(final Builder builder) { this.schedulerprovider = new AppComponent_schedulerProvider(builder.appComponent); private static class AppComponent_schedulerProvider implements Provider<BaseSchedulerProvider> { private final AppComponent public BaseSchedulerProvider get() { return appcomponent.schedulerprovider();

123 DaggerUserComponent (Generated) public final class DaggerUserComponent implements UserComponent { private Provider<BaseSchedulerProvider> schedulerprovider; private void initialize(final Builder builder) { this.schedulerprovider = new AppComponent_schedulerProvider(builder.appComponent); private static class AppComponent_schedulerProvider implements Provider<BaseSchedulerProvider> { private final AppComponent public BaseSchedulerProvider get() { return appcomponent.schedulerprovider();

124 SUB COMPONENTS

125

126 LoginComponent = arrayof(loginmodule::class)) interface LoginComponent interface Builder fun loginactivity(loginactivity: LoginActivity): Builder

127 LoginComponent = arrayof(loginmodule::class)) interface LoginComponent interface Builder fun loginactivity(loginactivity: LoginActivity): Builder

128 LoginComponent = arrayof(loginmodule::class)) interface LoginComponent interface Builder fun loginactivity(loginactivity: LoginActivity): Builder

129 LoginComponent = arrayof(loginmodule::class)) interface LoginComponent interface Builder fun loginactivity(loginactivity: LoginActivity): Builder

130 LoginComponent = arrayof(loginmodule::class)) interface LoginComponent interface Builder fun loginactivity(loginactivity: LoginActivity): Builder

131

132 LoginActivity class LoginActivity { private lateinit var logincomponent: LoginComponent override fun initdagger(appcomponent: AppComponent) { logincomponent = appcomponent.loginbuilder().loginactivity(this).build()

133 LoginActivity class LoginActivity { private lateinit var logincomponent: LoginComponent override fun initdagger(appcomponent: AppComponent) { logincomponent = appcomponent.loginbuilder().loginactivity(this).build()

134 (Generated) DAGGER

135 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { return new LoginComponentBuilder(); ; private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

136 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { return new LoginComponentBuilder(); ; private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

137 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { ; return new LoginComponentBuilder(); private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

138 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { return new LoginComponentBuilder(); ; private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

139 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { return new LoginComponentBuilder(); ; private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

140 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { return new LoginComponentBuilder(); ; private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

141 DaggerAppComponent (Generated) public final class DaggerAppComponent implements AppComponent { this.loginbuilderprovider = new Factory<LoginComponent.Builder>() public LoginComponent.Builder get() { return new LoginComponentBuilder(); ; private final class LoginComponentBuilder implements LoginComponent.Builder { private final class LoginComponentImpl implements LoginComponent { private LoginComponentImpl(LoginComponentBuilder builder) { assert builder!= null; initialize(builder);

142 SUB COMPONENT VS

143 @Singleton <<interface>> AppComponent fun schedulerprovider()

144 @Singleton <<interface>> AppComponent fun schedulerprovider() DaggerAppComponent schedulerprovider() usermanager

145 @Singleton <<interface>> AppComponent fun schedulerprovider() DaggerAppComponent schedulerprovider() usermanager Sub Component LoginComponent accesses any dependencies of DaggerAppComponent directly as inner class can access outer class members.

146 @Singleton <<interface>> AppComponent fun schedulerprovider() DaggerAppComponent schedulerprovider() DaggerUserComponent schedulerprovider pokemon Sub Component LoginComponent accesses any dependencies of DaggerAppComponent directly as inner class can access outer class members. Dependent Component UserComponent accesses any dependencies of DaggerAppComponent via an interface of AppComponent.

147 @Singleton <<interface>> AppComponent fun schedulerprovider() DaggerAppComponent schedulerprovider() DaggerUserComponent schedulerprovider pokemon Sub Component LoginComponent accesses any dependencies of DaggerAppComponent directly as inner class can access outer class members. Dependent Component UserComponent accesses any dependencies of DaggerAppComponent via an interface of AppComponent.

148 Custom Scope Advantages Dependency Lifecycle Management

149 Some Limitations Repetitive Injection code Class knows about it

150 Some Limitations Dagger

151 INTERMEDIATE CONCEPTS DEFEAT THE DAHAKA

152 @ragdroid

153 public class AppModule BaseSchedulerProvider providerschedulerprovider(schedulerprovider provider) { return provider;

154 public class AppModule BaseSchedulerProvider providerschedulerprovider(schedulerprovider provider) { return public abstract class AppModule abstract BaseSchedulerProvider providerschedulerprovider(schedulerprovider provider);

155 @ragdroid

156 MultiBinding String - String - String - How are you?

157 String String String - How are you?

158 MultiBinding Set<String> { Hello, Hi, How are you?

159 <<interface>> Contract.Presenter MapPresenter JustPresenter TakePresenter

160 MultiBinding MapPresenter JustPresenter TakePresenter takepresenter

161 TakePresenter takepresenter

162 @Provides @Provides @Provides TakePresenter takepresenter

163 MultiBinding Map<Class, Contract.Presenter> { mappresenter, justpresenter, takepresenter

164 DAGGER 2 ANDROID BEFRIEND THE BEAST

165

166 DahakaApplication class DahakaApplication : Application(), HasActivityInjector internal lateinit var activityinjector: DispatchingAndroidInjector<Activity> override fun activityinjector(): AndroidInjector<Activity> { return activityinjector

167 DahakaApplication class DahakaApplication : Application(), HasActivityInjector internal lateinit var activityinjector: DispatchingAndroidInjector<Activity> override fun activityinjector(): AndroidInjector<Activity> { return activityinjector

168 DahakaApplication class DahakaApplication : Application(), HasActivityInjector internal lateinit var activityinjector: DispatchingAndroidInjector<Activity> override fun activityinjector(): AndroidInjector<Activity> { return activityinjector

169 DahakaApplication class DahakaApplication : Application(), HasActivityInjector internal lateinit var activityinjector: DispatchingAndroidInjector<Activity> override fun activityinjector(): AndroidInjector<Activity> { return activityinjector

170 HasActivityInjector public interface HasActivityInjector { AndroidInjector<Activity> activityinjector();

171 HasActivityInjector public interface HasActivityInjector { AndroidInjector<Activity> activityinjector(); A simple interface. Implementing class Has ActivityInjector. ActivityInjector = AndroidInjector<Activity>.

172 HasActivityInjector <<interface>> HasActivityInjector fun activityinjector() : AndroidInjector<Activity>

173 HasActivityInjector <<interface>> HasActivityInjector fun activityinjector() : AndroidInjector<Activity> DahakaApplication activityinjector : DispatchingAndroidInjector<Activity>

174 HasActivityInjector <<interface>> HasActivityInjector fun activityinjector() : AndroidInjector<Activity> <<interface>> AndroidInjector<Activity> fun inject(activity instance) DahakaApplication activityinjector : DispatchingAndroidInjector<Activity>

175 HasActivityInjector <<interface>> HasActivityInjector fun activityinjector() : AndroidInjector<Activity> <<interface>> AndroidInjector<Activity> fun inject(activity instance) DahakaApplication activityinjector : DispatchingAndroidInjector<Activity> DispatchingAndroidInjector<Activity> inject(activity activity) injectorfactories : Map

176 DispatchingAndroidInjector Injects members for Android types : Activity, Fragment, etc Has a Map<Class, Provider<Factory>> injectorfactories.

177 DispatchingAndroidInjector Injects members for Android types : Activity, Fragment, etc Has a Map<Class, Provider<Factory>> injectorfactories. DispatchingAndroidInject<Activity> Class<Activity> Provider<Factory<Activity>> LoginActivity.class Provider<LoginActivitySubcomponent.Builder> gets the Subcomponent.Builder from Map. creates an instance using Builder. calls component.inject(instance) to perform injections.

178 DispatchingAndroidInjector DispatchingAndroidInject<Activity> Class<Activity> LoginActivity.class HomeActivity.class ItemsActivity.class Provider<Factory<Activity>> Provider<LoginActivitySubcomponent.Builder> Provider<HomeActivitySubcomponent.Builder> Provider<ItemsActivitySubcomponent.Builder> DispatchingAndroidInject<Fragment> Class<Fragment> Provider<Factory<Fragment>> ProfileFragment.class MovesFragment.class StatsFragment.class Provider<ProfileFragmentSubcomponent.Builder> Provider<MovesFragmentSubcomponent.Builder> Provider<StatsFragmentSubcomponent.Builder>

179

180 AppComponent = arrayof(appmodule::class, ApiModule::class, AppBindingModule::class, AndroidSupportInjectionModule::class)) interface AppComponent : AndroidInjector<DaggerApplication> {

181 AppComponent = arrayof(appmodule::class, ApiModule::class, AppBindingModule AppBindingModule::class, AndroidSupportInjectionModule::class)) interface AppComponent : AndroidInjector<DaggerApplication> {

182 abstract class AppBindingModule = internal abstract fun loginactivity(): LoginActivity

183 abstract class AppBindingModule = internal abstract fun loginactivity(): LoginActivity

184 abstract class AppBindingModule = internal abstract fun loginactivity(): If your Module is stateless. If your Subcomponent.Builder is simple and doesn t need to bind anything will generate the SubComponent for you. No need to create LoginActivitySubcomponent class in the above case.

185 abstract class AppBindingModule = internal abstract fun loginactivity(): LoginActivity abstract class LoginModule abstract fun provideloginpresenter(loginpresenter: LoginPresenter): LoginContract.Presenter

186 LoginBindingModule = LoginActivitySubcomponent.class) public abstract class @ActivityKey(LoginActivity.class) abstract AndroidInjector.Factory<? extends Activity> bindandroidinjectorfactory( LoginActivitySubcomponent.Builder = public interface LoginActivitySubcomponent extends AndroidInjector<LoginActivity> abstract class Builder extends AndroidInjector.Builder<LoginActivity> {

187 LoginBindingModule = LoginActivitySubcomponent.class) public abstract class @ActivityKey(LoginActivity.class) abstract AndroidInjector.Factory<? extends Activity> bindandroidinjectorfactory( LoginActivitySubcomponent.Builder = public interface LoginActivitySubcomponent extends AndroidInjector<LoginActivity> abstract class Builder extends AndroidInjector.Builder<LoginActivity> {

188 LoginBindingModule = LoginActivitySubcomponent.class) public abstract class @ActivityKey(LoginActivity.class) abstract AndroidInjector.Factory<? extends Activity> bindandroidinjectorfactory( LoginActivitySubcomponent.Builder = public interface LoginActivitySubcomponent extends AndroidInjector<LoginActivity> abstract class Builder extends AndroidInjector.Builder<LoginActivity> {

189 LoginBindingModule = LoginActivitySubcomponent.class) public abstract class @ActivityKey(LoginActivity.class) abstract AndroidInjector.Factory<? extends Activity> bindandroidinjectorfactory( LoginActivitySubcomponent.Builder = public interface LoginActivitySubcomponent extends AndroidInjector<LoginActivity> abstract class Builder extends AndroidInjector.Builder<LoginActivity> {

190 LoginBindingModule = LoginActivitySubcomponent.class) public abstract class @ActivityKey(LoginActivity.class) abstract AndroidInjector.Factory<? extends Activity> bindandroidinjectorfactory( LoginActivitySubcomponent.Builder = public interface LoginActivitySubcomponent extends AndroidInjector<LoginActivity> abstract class Builder extends AndroidInjector.Builder<LoginActivity> {

191 AppComponent = arrayof(appmodule::class, ApiModule::class, AppBindingModule AppBindingModule::class, AndroidSupportInjectionModule AndroidSupportInjectionModule::class)) interface AppComponent : AndroidInjector<DaggerApplication> {

192 = AndroidInjectionModule.class) public abstract class AndroidSupportInjectionModule abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> supportfragmentinjectorfactories(); private public abstract class AndroidInjectionModule abstract Map<Class<? extends Activity>, AndroidInjector.Factory<? extends Activity>> abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> fragmentinjectorfactories();

193 = AndroidInjectionModule.class) public abstract class AndroidSupportInjectionModule abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> supportfragmentinjectorfactories(); private public abstract class AndroidInjectionModule abstract Map<Class<? extends Activity>, AndroidInjector.Factory<? extends Activity>> abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> fragmentinjectorfactories();

194 = AndroidInjectionModule.class) public abstract class AndroidSupportInjectionModule abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> supportfragmentinjectorfactories(); private public abstract class AndroidInjectionModule abstract Map<Class<? extends Activity>, AndroidInjector.Factory<? extends Activity>> abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> fragmentinjectorfactories();

195 = AndroidInjectionModule.class) public abstract class AndroidSupportInjectionModule abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> supportfragmentinjectorfactories(); private public abstract class AndroidInjectionModule abstract Map<Class<? extends Activity>, AndroidInjector.Factory<? extends Activity>> abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> fragmentinjectorfactories();

196 = AndroidInjectionModule.class) public abstract class AndroidSupportInjectionModule abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> supportfragmentinjectorfactories(); private public abstract class AndroidInjectionModule abstract Map<Class<? extends Activity>, AndroidInjector.Factory<? extends Activity>> abstract Map<Class<? extends Fragment>, AndroidInjector.Factory<? extends Fragment>> fragmentinjectorfactories();

197

198 LoginActivity public class LoginActivity LoginContract.Presenter protected void oncreate(bundle savedinstancestate) { AndroidInjection.inject(this);

199 LoginActivity public class LoginActivity LoginContract.Presenter protected void oncreate(bundle savedinstancestate) { AndroidInjection.inject(this); AndroidInjection.inject(LoginActivity)

200 AndroidInjection.inject(LoginActivity)

201 AndroidInjection.inject(LoginActivity) AndroidInjection

202 AndroidInjection.inject(LoginActivity) AndroidInjection DaggerAppComponent

203 AndroidInjection.inject(LoginActivity) AndroidInjection DaggerAppComponent AppBindingModule_LoginActivity DispatchingAndroidInjector

204 AndroidInjection.inject(LoginActivity) AndroidInjection DaggerAppComponent AppBindingModule_LoginActivity DispatchingAndroidInjector

205 AndroidInjection.inject(LoginActivity) AndroidInjection DaggerAppComponent AppBindingModule_LoginActivity ApiModule_ProvideRetrofitFactory ApiModule_ProvideRetrofitFactory AppModule_ProviderSchedulerProviderFactory DispatchingAndroidInjector AppModule_ProviderSchedulerProviderFactory ApiModule_ProvidePokemonServiceFactory ApiModule_ProvidePokemonServiceFactory

206 BEFRIEND THE BEAST You can not change your fate, No

207 AndroidInjection.inject(LoginActivity)

208 AndroidInjection.inject(LoginActivity) LoginActivity activity.getapplication()

209 AndroidInjection.inject(LoginActivity) LoginActivity activity.getapplication() DahakaApplication : HasActivityInjector application.activityinjector()

210 AndroidInjection.inject(LoginActivity) LoginActivity activity.getapplication() DahakaApplication : HasActivityInjector application.activityinjector() DispatchingAndroidInjector : AndroidInjector activityinjector.inject(activity)

211 AndroidInjection.inject(LoginActivity) LoginActivity activity.getapplication() DahakaApplication : HasActivityInjector application.activityinjector() DispatchingAndroidInjector : AndroidInjector activityinjector.inject(activity)

212 DispatchingAndroidInjector.inject(LoginActivity) DispatchingAndroidInjector : AndroidInjector injectorfactories.get(loginactivity.class)

213 DispatchingAndroidInjector.inject(LoginActivity) DispatchingAndroidInjector : AndroidInjector injectorfactories.get(loginactivity.class) Factory<LoginActivity> : LoginSubcomponent.Builder builder.build()

214 DispatchingAndroidInjector.inject(LoginActivity) DispatchingAndroidInjector : AndroidInjector injectorfactories.get(loginactivity.class) Factory<LoginActivity> : LoginSubcomponent.Builder builder.build() LoginSubcomponent component.inject(activity)

215 DispatchingAndroidInjector.inject(LoginActivity) DispatchingAndroidInjector : AndroidInjector injectorfactories.get(loginactivity.class) Factory<LoginActivity> : LoginSubcomponent.Builder builder.build() LoginSubcomponent component.inject(activity)

216 Dagger Boilerplate classes DaggerApplication DaggerActivity DaggerBroadcastReceiver DaggerContentProvider DaggerFragment DaggerIntentService DaggerService

217 TESTING WITH DAGGER

218 LoginActivity public class LoginActivity LoginContract.Presenter protected void oncreate(bundle savedinstancestate) { AndroidInjection.inject(this);

219 LoginActivity public class LoginActivity LoginContract.Presenter protected void oncreate(bundle savedinstancestate) { AndroidInjection.inject(this);

220 public class TestLoginModule LoginPresenter loginpresenter; public TestLoginModule() public LoginContract.Presenter provideloginpresenter() { return loginpresenter;

221 public class TestLoginModule LoginPresenter loginpresenter; public TestLoginModule() public LoginContract.Presenter provideloginpresenter() { return loginpresenter;

222 public class TestLoginModule LoginPresenter loginpresenter; public TestLoginModule() public LoginContract.Presenter provideloginpresenter() { return loginpresenter;

223 Demo Code Dahaka Demo : Branches : dagger-android : Pokemon app using dagger-android (With Tests, Fragments) dagger-android-dependent-comp : dagger-android with Dependent Component dagger-android-dependent-comp-kotlin : In Kotlin subcomponent : UserComponent as subcomponent dependent-component : UserComponent as dependent component dependent-component-kotlin : In Kotlin

224 Dagger 2 Android = Dahaka D A H A K A Dagger Android HasActivityInjector AndroidInjection

225 Dagger 2 Android You can not change your fate, No droid can Let s befriend the

226 Acknowledgements Dagger Recipies : Miroslaw Stanek (@froger_mcs) todo-mvp-dagger : Mike Nakhimovich (@friendlymikhail ) Android Dialogs : Mike Nakhimovich Proof Reading : Ritesh Gupta (@_riteshhh) Migrate to Kotlin : Ravindra Kumar (@ravidsrk)

227 What Next? Dagger Documentation : todo-mvp-dagger : Mike Nakhimovich (@friendlymikhail ) Dagger Example Testing article Dagger and the Dahaka Series :

228 Other References Theme : Prince of Persia Dahaka Dagger Android

229

230 Dagger 2 Android Defeat the Dahaka" Garima

231 Dagger 2 Android Defeat the Dahaka" Garima

About 1. Chapter 1: Getting started with dagger-2 2. Remarks 2. Versions 2. Examples 2. Description and Setup 2. Basic Example 3.

About 1. Chapter 1: Getting started with dagger-2 2. Remarks 2. Versions 2. Examples 2. Description and Setup 2. Basic Example 3. dagger-2 #dagger-2 Table of Contents About 1 Chapter 1: Getting started with dagger-2 2 Remarks 2 Versions 2 Examples 2 Description and Setup 2 Basic Example 3 Android example 4 Learn Dagger2 with simple

More information

Big Modular Java with Guice

Big Modular Java with Guice Big Modular Java with Guice Jesse Wilson Dhanji Prasanna May 28, 2009 Post your questions for this talk on Google Moderator: code.google.com/events/io/questions Click on the Tech Talks Q&A link. 2 How

More information

Кирилл Розов Android Developer

Кирилл Розов Android Developer Кирилл Розов Android Developer Dependency Injection Inversion of Control (IoC) is a design principle in which custom-written portions of a computer program receive the flow of control from a generic framework

More information

Design patterns using Spring and Guice

Design patterns using Spring and Guice Design patterns using Spring and Guice Dhanji R. Prasanna MANNING contents 1 Dependency 2 Time preface xv acknowledgments xvii about this book xix about the cover illustration xxii injection: what s all

More information

Android Application Model I

Android Application Model I Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath Reading: Big Nerd Ranch Guide, Chapters 3, 5 (Activities);

More information

June 27, 2014 EuroClojure 2014 Krakow, Poland. Components. Just Enough

June 27, 2014 EuroClojure 2014 Krakow, Poland. Components. Just Enough June 27, 2014 EuroClojure 2014 Krakow, Poland Components Just Enough Structure @stuartsierra Presentation Business Logic DB SMS Email Presentation Thread Pool Business Logic Queues Public API Private API

More information

Overview of Activities

Overview of Activities d.schmidt@vanderbilt.edu www.dre.vanderbilt.edu/~schmidt Institute for Software Integrated Systems Vanderbilt University Nashville, Tennessee, USA CS 282 Principles of Operating Systems II Systems Programming

More information

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr.

Android Application Model I. CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Android Application Model I CSE 5236: Mobile Application Development Instructor: Adam C. Champion, Ph.D. Course Coordinator: Dr. Rajiv Ramnath 1 Framework Support (e.g. Android) 2 Framework Capabilities

More information

A simple, scalable app architecture with Android Annotations Luke Sleeman Freelance Android developer lukesleeman.com.au

A simple, scalable app architecture with Android Annotations Luke Sleeman Freelance Android developer lukesleeman.com.au A simple, scalable app architecture with Android Annotations Luke Sleeman Freelance Android developer lukesleeman.com.au Image CC: https://flic.kr/p/6oqczb Luke Sleeman - Freelance developer specialising

More information

Leak Canary Intro Jennifer McGee

Leak Canary Intro Jennifer McGee Leak Canary Intro Jennifer McGee 1 Leak Canary What is Leak Canary? Open source library written by Square s Pierre-Yves (PY) Ricau Library which attempts to automatically detect and report memory leaks

More information

Dependency Injection with Guice

Dependency Injection with Guice Author: Assaf Israel - Technion 2013 Dependency Injection with Guice Technion Institute of Technology 236700 1 Complex Dependency Injection Deep dependencies (with no default) A depends on B, which depends

More information

Frontend Web Development with Angular. CC BY-NC-ND Carrot & Company GmbH

Frontend Web Development with Angular. CC BY-NC-ND Carrot & Company GmbH Frontend Web Development with Angular Agenda Questions Some infos Lecturing Todos Router NgModules Questions? Some Infos Code comments from us were made for improving your code. If you ignore them you

More information

Patterns Continued and Concluded. July 26, 2017

Patterns Continued and Concluded. July 26, 2017 Patterns Continued and Concluded July 26, 2017 Review Quiz What is the purpose of the Singleton pattern? A. To advertise to other developers that the object should only be modified by `main()` B.To prevent

More information

Dependency Inversion, Dependency Injection and Inversion of Control. Dependency Inversion Principle by Robert Martin of Agile Fame

Dependency Inversion, Dependency Injection and Inversion of Control. Dependency Inversion Principle by Robert Martin of Agile Fame Dependency Inversion, Dependency Injection and Inversion of Control Dependency Inversion Principle by Robert Martin of Agile Fame Dependency Inversion Principle History Postulated by Robert C. Martin Described

More information

EJB 3.1 vs Contexts and Dependency Injection (CDI) and Dependency Injection for Java in Java EE 6. Jacek Laskowski.

EJB 3.1 vs Contexts and Dependency Injection (CDI) and Dependency Injection for Java in Java EE 6. Jacek Laskowski. EJB 3.1 vs Contexts and Dependency Injection (CDI) and Dependency Injection for Java in Java EE 6 Jacek Laskowski jacek@japila.pl Jacek Laskowski Blogger of http://blog.japila.pl Blogger of http://jaceklaskowski.pl

More information

Programming in Scala Second Edition

Programming in Scala Second Edition Programming in Scala Second Edition Martin Odersky, Lex Spoon, Bill Venners artima ARTIMA PRESS WALNUT CREEK, CALIFORNIA Contents Contents List of Figures List of Tables List of Listings Foreword Foreword

More information

Tishik Int. University / College of Science / IT Dept. This Course based mainly on online sources ADVANCED MOBILE APPLICATIONS / Spring 1

Tishik Int. University / College of Science / IT Dept. This Course based mainly on online sources ADVANCED MOBILE APPLICATIONS / Spring 1 ADVANCED MOBILE APPLICATIONS / 2018-2019 Spring Tishik Int. University / College of Science / IT Dept. Presented By: Mohammad Salim Al-Othman For 4 th Grade Students This Course based mainly on online

More information

ARCHETYPE MODERN ANDROID ARCHITECTURE STEPAN GONCHAROV / DENIS NEKLIUDOV

ARCHETYPE MODERN ANDROID ARCHITECTURE STEPAN GONCHAROV / DENIS NEKLIUDOV ARCHETYPE MODERN ANDROID ARCHITECTURE STEPAN GONCHAROV / DENIS NEKLIUDOV 90seconds.tv 14000+ VIDEOS 1200+ BRANDS 92+ COUNTRIES data class RegisterViewModelStateImpl( override val email: ObservableString

More information

Integrating Angular with ASP.NET Core RESTful Services. Dan Wahlin

Integrating Angular with ASP.NET Core RESTful Services. Dan Wahlin Integrating Angular with ASP.NET Core RESTful Services Dan Wahlin Dan Wahlin https://blog.codewithdan.com @DanWahlin Get the Content: http://codewithdan.me/angular-aspnet-core Agenda The Big Picture Creating

More information

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI

Programming Kotlin. Familiarize yourself with all of Kotlin s features with this in-depth guide. Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Familiarize yourself with all of Kotlin s features with this in-depth guide Stephen Samuel Stefan Bocutiu BIRMINGHAM - MUMBAI Programming Kotlin Copyright 2017 Packt Publishing First

More information

Kotlin for Android developers

Kotlin for Android developers ROME - APRIL 13/14 2018 Kotlin for Android developers Victor Kropp, JetBrains @kropp Kotlin on JVM + Android JS In development: Kotlin/Native ios/macos/windows/linux Links Kotlin https://kotlinlang.org

More information

Data binding. in a Kotlin world. Lisa

Data binding. in a Kotlin world. Lisa Data binding in a Kotlin world Lisa Wray Data binding in a Kotlin world Lisa Wray Data binding in a Kotlin world Lisa Wray Less code is better code 1. Quick tour of The Best Parts of data binding 2. Kotlin

More information

Excel on the Java VM. Generating Fast Code from Spreadsheet Models. Peter Arrenbrecht codewise.ch / Abacus Research AG Submission ID: 30

Excel on the Java VM. Generating Fast Code from Spreadsheet Models. Peter Arrenbrecht codewise.ch / Abacus Research AG Submission ID: 30 Excel on the Java VM Generating Fast Code from Spreadsheet Models Peter Arrenbrecht codewise.ch / Abacus Research AG Submission ID: 30 AGENDA > Problem: Customization Is Hard > Idea: Let Users Use Spreadsheets

More information

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP

Object oriented programming. Encapsulation. Polymorphism. Inheritance OOP OOP Object oriented programming Polymorphism Encapsulation Inheritance OOP Class concepts Classes can contain: Constants Delegates Events Fields Constructors Destructors Properties Methods Nested classes

More information

JavaScript: Sort of a Big Deal,

JavaScript: Sort of a Big Deal, : Sort of a Big Deal, But Sort of Quirky... March 20, 2017 Lisp in C s Clothing (Crockford, 2001) Dynamically Typed: no static type annotations or type checks. C-Like Syntax: curly-braces, for, semicolons,

More information

Kotlin, Start? Start! (pluu) Android Developer GDG Korea Android Organizer

Kotlin, Start? Start! (pluu) Android Developer GDG Korea Android Organizer Kotlin, Start? Start! (pluu) Android Developer GDG Korea Android Organizer Agenda Kotlin Overview Kotlin?? Basic fun main(args: Array): Unit { println("hello, world!") Basic Function Keyword

More information

Introduction to Android

Introduction to Android Introduction to Android http://myphonedeals.co.uk/blog/33-the-smartphone-os-complete-comparison-chart www.techradar.com/news/phone-and-communications/mobile-phones/ios7-vs-android-jelly-bean-vs-windows-phone-8-vs-bb10-1159893

More information

Using Type Annotations to Improve Your Code

Using Type Annotations to Improve Your Code Using Type Annotations to Improve Your Code Birds-of-a-Feather Session Werner Dietl, University of Waterloo Michael Ernst, University of Washington Open for questions Survey: Did you attend the tutorial?

More information

Sample Copy. Not For Distribution.

Sample Copy. Not For Distribution. Angular 2 Interview Questions and Answers With Typescript and Angular 4 i Publishing-in-support-of, EDUCREATION PUBLISHING RZ 94, Sector - 6, Dwarka, New Delhi - 110075 Shubham Vihar, Mangla, Bilaspur,

More information

CSCU9YH Development with Android

CSCU9YH Development with Android CSCU9YH Development with Android Computing Science and Mathematics University of Stirling 1 Android Context 3 Smartphone Market share Source: http://www.idc.com/promo/smartphone-market-share/os 4 Smartphone

More information

Services. service: A background task used by an app.

Services. service: A background task used by an app. CS 193A Services This document is copyright (C) Marty Stepp and Stanford Computer Science. Licensed under Creative Commons Attribution 2.5 License. All rights reserved. Services service: A background task

More information

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks

In this Lecture you will Learn: Design Patterns. Patterns vs. Frameworks. Patterns vs. Frameworks In this Lecture you will Learn: Design Patterns Chapter 15 What types of patterns have been identified in software development How to apply design patterns during software development The benefits and

More information

Nagaraju Bende

Nagaraju Bende AngularJS Nagaraju Bende Blog Twitter @nbende FaceBook nbende http://angularjs.org Agenda Introduction to AngularJS Pre-Requisites Why AngularJS Only Getting Started MV* pattern of AngularJS Directives,

More information

Designing for Modularity with Java 9

Designing for Modularity with Java 9 Designing for Modularity with Java 9 Paul Bakker @pbakker Sander Mak @Sander_Mak Today's journey Module primer Services & DI Modular design Layers & loading Designing for Modularity with Java 9 What if

More information

Implementing MVVM in Real World ArcGIS Server Silverlight Applications. Brandon Copeland LJA Engineering, Inc.

Implementing MVVM in Real World ArcGIS Server Silverlight Applications. Brandon Copeland LJA Engineering, Inc. Implementing MVVM in Real World ArcGIS Server Silverlight Applications Brandon Copeland LJA Engineering, Inc. 1 Agenda / Focused Topics Application Demo Model-View-ViewModel (MVVM) What is MVVM? Why is

More information

DOT NET Syllabus (6 Months)

DOT NET Syllabus (6 Months) DOT NET Syllabus (6 Months) THE COMMON LANGUAGE RUNTIME (C.L.R.) CLR Architecture and Services The.Net Intermediate Language (IL) Just- In- Time Compilation and CLS Disassembling.Net Application to IL

More information

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.

Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings. Hello World Lab Objectives: Create new Android project in Android Studio Add Button and TextView to layout Learn how to use buttons to call methods. Modify strings.xml What to Turn in: The lab evaluation

More information

Native Android Development Practices

Native Android Development Practices Native Android Development Practices Roy Clarkson & Josh Long SpringSource, a division of VMware 1 About Roy Clarkson (Spring Android Lead) @royclarkson 2 About Roy Clarkson (Spring Android Lead) @royclarkson

More information

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi

ACTIVITY, FRAGMENT, NAVIGATION. Roberto Beraldi ACTIVITY, FRAGMENT, NAVIGATION Roberto Beraldi Introduction An application is composed of at least one Activity GUI It is a software component that stays behind a GUI (screen) Activity It runs inside the

More information

Financial. AngularJS. AngularJS.

Financial. AngularJS. AngularJS. Financial http://killexams.com/exam-detail/ Section 1: Sec One (1 to 50) Details:This section provides a huge collection of Angularjs Interview Questions with their answers hidden in a box to challenge

More information

Section 9: Design Patterns. Slides adapted from Alex Mariakakis, with material from David Mailhot, Hal Perkins, Mike Ernst

Section 9: Design Patterns. Slides adapted from Alex Mariakakis, with material from David Mailhot, Hal Perkins, Mike Ernst Section 9: Design Patterns Slides adapted from Alex Mariakakis, with material from David Mailhot, Hal Perkins, Mike Ernst Agenda What are design patterns? Creational patterns review Structural patterns

More information

CE881: Mobile & Social Application Programming

CE881: Mobile & Social Application Programming CE881: Mobile & Social Application Programming, s, s and s Jialin Liu Senior Research Officer Univerisity of Essex 6 Feb 2017 Recall of lecture 3 and lab 3 :) Please download Kahoot or open a bowser and

More information

Financial. AngularJS. AngularJS. Download Full Version :

Financial. AngularJS. AngularJS. Download Full Version : Financial AngularJS AngularJS Download Full Version : https://killexams.com/pass4sure/exam-detail/angularjs Section 1: Sec One (1 to 50) Details:This section provides a huge collection of Angularjs Interview

More information

2 years without Java or reload Android development with Kotlin.

2 years without Java or reload Android development with Kotlin. 2 years without Java or reload Android development with Kotlin KirillRozov@EPAM Who am I? Team Lead in EPAM More than 6 years in Android development Kotlin Evangelist Co-organizer GDG Minsk, Android Academy

More information

CSE 331 Final Exam 6/5/17. Name UW ID#

CSE 331 Final Exam 6/5/17. Name UW ID# Name UW ID# There are 10 questions worth a total of 100 points. Please budget your time so you get to all of the questions. Keep your answers brief and to the point. The exam is closed book, closed notes,

More information

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based.

INTRODUCTION COS MOBILE DEVELOPMENT WHAT IS ANDROID CORE OS. 6-Android Basics.key - February 21, Linux-based. 1 COS 470 - MOBILE DEVELOPMENT INTRODUCTION 2 WHAT IS ANDROID Linux-based Java/Kotlin Android Runtime (ART) System Apps SMS, Calendar, etc. Platform Architecture 3 CORE OS Linux (64 bit) Each app is a

More information

Table of Content. CLOUDCHERRY Android SDK Manual

Table of Content. CLOUDCHERRY Android SDK Manual Table of Content 1. Introduction: cloudcherry-android-sdk 2 2. Capabilities 2 3. Setup 2 4. How to create static token 3 5. Initialize SDK 5 6. How to trigger the SDK? 5 7. How to setup custom legends

More information

Repairing crashes in Android Apps. Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore

Repairing crashes in Android Apps. Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore Repairing crashes in Android Apps Shin Hwei Tan Zhen Dong Xiang Gao Abhik Roychoudhury National University of Singapore Android Repair System Criteria for Android repair system: Could be used by any smartphone

More information

Theme 2 Program Design. MVC and MVP

Theme 2 Program Design. MVC and MVP Theme 2 Program Design MVC and MVP 1 References Next to the books used for this course, this part is based on the following references: Interactive Application Architecture Patterns, http:// aspiringcraftsman.com/2007/08/25/interactiveapplication-architecture/

More information

One Framework. Angular

One Framework. Angular One Framework. Angular Web 2.0 Marc Dangschat Introduction AngularJS (1) released in 2009 Angular (2) released October Short: ng Framework TypeScript, JavaScript, Dart MIT license

More information

& Object-Oriented Programming (POOP) Modified from CS61A Summer 2012 Lecture at UC Berkeley

& Object-Oriented Programming (POOP) Modified from CS61A Summer 2012 Lecture at UC Berkeley & Object-Oriented Programming (POOP) Modified from CS61A Summer 2012 Lecture at UC Berkeley Where We Were: Functional Programming Style of programming One of many programming paradigms where functions

More information

Object Oriented Design and Programming Revision

Object Oriented Design and Programming Revision M.Sc Computer Science Object Oriented Design and Programming Revision Oded Lachish Email: oded@dcs.bbk.ac.uk Web Page: http://www.dcs.bbk.ac.uk/~oded/oodp12/oodp2012.html Question 1 (a) What is the motivation

More information

Android About.me/DavidCorrado Mobile Meetup Organizer

Android About.me/DavidCorrado Mobile Meetup Organizer Android Tips/Tricks @DavidCorrado About.me/DavidCorrado Mobile Meetup Organizer IDE Don t Use Eclipse Use either Android Studio/IntelliJ They are basically the same thing. They are both built off of IntelliJ

More information

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns

Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Lectures 24 and 25 Introduction to Architectural Styles and Design Patterns Software Engineering ITCS 3155 Fall 2008 Dr. Jamie Payton Department of Computer Science University of North Carolina at Charlotte

More information

Advanced concurrent programming in Java Shared objects

Advanced concurrent programming in Java Shared objects Advanced concurrent programming in Java Shared objects Mehmet Ali Arslan 21.10.13 Visibility To see(m) or not to see(m)... 2 There is more to synchronization than just atomicity or critical sessions. Memory

More information

Mobile Computing Fragments

Mobile Computing Fragments Fragments APM@FEUP 1 Fragments (1) Activities are used to define a full screen interface and its functionality That s right for small screen devices (smartphones) In bigger devices we can have more interface

More information

What is it? CMSC 433 Programming Language Technologies and Paradigms Spring Approach 1. Disadvantage of Approach 1

What is it? CMSC 433 Programming Language Technologies and Paradigms Spring Approach 1. Disadvantage of Approach 1 CMSC 433 Programming Language Technologies and Paradigms Spring 2007 Singleton Pattern Mar. 13, 2007 What is it? If you need to make sure that there can be one and only one instance of a class. For example,

More information

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015

Developing Android Applications Introduction to Software Engineering Fall Updated 1st November 2015 Developing Android Applications Introduction to Software Engineering Fall 2015 Updated 1st November 2015 Android Lab 3 & Midterm Additional Concepts No Class Assignment 2 Class Plan Android : Additional

More information

The GoF Design Patterns Reference

The GoF Design Patterns Reference The GoF Design Patterns Reference Version.0 / 0.0.07 / Printed.0.07 Copyright 0-07 wsdesign. All rights reserved. The GoF Design Patterns Reference ii Table of Contents Preface... viii I. Introduction....

More information

A simple, scalable app architecture with Android annotations Luke Sleeman Freelance Android developer lukesleeman.com.au

A simple, scalable app architecture with Android annotations Luke Sleeman Freelance Android developer lukesleeman.com.au A simple, scalable app architecture with Android annotations Luke Sleeman Freelance Android developer lukesleeman.com.au Image CC: https://flic.kr/p/6oqczb Agenda Introduction The architecture - an overview

More information

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml

Understand applications and their components. activity service broadcast receiver content provider intent AndroidManifest.xml Understand applications and their components activity service broadcast receiver content provider intent AndroidManifest.xml Android Application Written in Java (it s possible to write native code) Good

More information

An Introduction to Patterns

An Introduction to Patterns An Introduction to Patterns Robert B. France Colorado State University Robert B. France 1 What is a Pattern? - 1 Work on software development patterns stemmed from work on patterns from building architecture

More information

The Google Web Toolkit (GWT):

The Google Web Toolkit (GWT): 2012 Yaakov Chaikin The Google Web Toolkit (GWT): Advanced MVP: GWT MVP Framework (GWT 2.4 Version) Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/course-materials/gwt.html

More information

Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt. The Builder Pattern

Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt. The Builder Pattern Summer Term 2018 1 Software Engineering Design & Construction Dr. Michael Eichberg Fachgebiet Softwaretechnik Technische Universität Darmstadt Builder Pattern 2 The Builder Pattern Divide the construction

More information

CHAPTER 6: CREATIONAL DESIGN PATTERNS

CHAPTER 6: CREATIONAL DESIGN PATTERNS CHAPTER 6: CREATIONAL DESIGN PATTERNS SESSION III: BUILDER, PROTOTYPE, SINGLETON Software Engineering Design: Theory and Practice by Carlos E. Otero Slides copyright 2012 by Carlos E. Otero For non-profit

More information

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding

Java Class Design. Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding Java Class Design Eugeny Berkunsky, Computer Science dept., National University of Shipbuilding eugeny.berkunsky@gmail.com http://www.berkut.mk.ua Objectives Implement encapsulation Implement inheritance

More information

Angular 2 Programming

Angular 2 Programming Course Overview Angular 2 is the next iteration of the AngularJS framework. It promises better performance. It uses TypeScript programming language for type safe programming. Overall you should see better

More information

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file?

QUIZ on Ch.5. Why is it sometimes not a good idea to place the private part of the interface in a header file? QUIZ on Ch.5 Why is it sometimes not a good idea to place the private part of the interface in a header file? Example projects where we don t want the implementation visible to the client programmer: The

More information

Eclipse 4 Eclipse Day Toulouse 24 mai 2012

Eclipse 4 Eclipse Day Toulouse 24 mai 2012 Eclipse 4 Eclipse Day Toulouse 24 mai 2012 OPC 12 ECD PRE E4A 01 A OPCOACH 2012 Table of contents I - Eclipse 4 5 A. Application Model... 10 B. E4 injection and annotations... 14 C. CSS Styling... 17

More information

Advanced Systems Programming

Advanced Systems Programming Advanced Systems Programming Introduction to C++ Martin Küttler September 19, 2017 1 / 18 About this presentation This presentation is not about learning programming or every C++ feature. It is a short

More information

Writing truly testable code. Anton Rutkevich Juno

Writing truly testable code. Anton Rutkevich Juno Writing truly testable code Anton Rutkevich Juno Why tests? Codebase grows -> chances of making a mistake go up Software gets released -> cost of a mistake goes up -> Fear of introducing modifications!

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Guice. Java DI Framework

Guice. Java DI Framework Guice Java DI Framework Agenda Intro to dependency injection Cross-cutting concerns and aspectoriented programming More Guice What is DI? Dependency injection is a design pattern that's like a "super factory".

More information

ANGULAR2 OVERVIEW. The Big Picture. Getting Started. Modules and Components. Declarative Template Syntax. Forms

ANGULAR2 OVERVIEW. The Big Picture. Getting Started. Modules and Components. Declarative Template Syntax. Forms FORMS IN ANGULAR Hello Cluj. I m Alex Lakatos, a Mozilla volunteer which helps other people volunteer. I want to talk to you today about Angular forms. What s a form you ask? A form creates a cohesive,

More information

Design Patterns. SE3A04 Tutorial. Jason Jaskolka

Design Patterns. SE3A04 Tutorial. Jason Jaskolka SE3A04 Tutorial Jason Jaskolka Department of Computing and Software Faculty of Engineering McMaster University Hamilton, Ontario, Canada jaskolj@mcmaster.ca November 18/19, 2014 Jason Jaskolka 1 / 35 1

More information

Getting Started With Android Feature Flags

Getting Started With Android Feature Flags Guide Getting Started With Android Feature Flags INTRO When it comes to getting started with feature flags (Android feature flags or just in general), you have to understand that there are degrees of feature

More information

A- Core Java Audience Prerequisites Approach Objectives 1. Introduction

A- Core Java Audience Prerequisites Approach Objectives 1. Introduction OGIES 6/7 A- Core Java The Core Java segment deals with the basics of Java. It is designed keeping in mind the basics of Java Programming Language that will help new students to understand the Java language,

More information

Android Activities. Akhilesh Tyagi

Android Activities. Akhilesh Tyagi Android Activities Akhilesh Tyagi Apps, memory, and storage storage: Your device has apps and files installed andstoredonitsinternaldisk,sdcard,etc. Settings Storage memory: Some subset of apps might be

More information

Lab 1: Getting Started With Android Programming

Lab 1: Getting Started With Android Programming Islamic University of Gaza Faculty of Engineering Computer Engineering Dept. Eng. Jehad Aldahdooh Mobile Computing Android Lab Lab 1: Getting Started With Android Programming To create a new Android Project

More information

Wednesday, January 25, 12

Wednesday, January 25, 12 Java EE on Google App Engine: CDI to the rescue! Aleš Justin JBoss by Red Hat Agenda What is GAE and CDI? Why GAE and CDI? Running JavaEE on GAE Other JavaEE technologies Development vs. Production Problems

More information

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented

Subclass Gist Example: Chess Super Keyword Shadowing Overriding Why? L10 - Polymorphism and Abstract Classes The Four Principles of Object Oriented Table of Contents L01 - Introduction L02 - Strings Some Examples Reserved Characters Operations Immutability Equality Wrappers and Primitives Boxing/Unboxing Boxing Unboxing Formatting L03 - Input and

More information

Object-Oriented Design

Object-Oriented Design Object-Oriented Design Lecture 14: Design Workflow Department of Computer Engineering Sharif University of Technology 1 UP iterations and workflow Workflows Requirements Analysis Phases Inception Elaboration

More information

COMPUTER SCIENCE TRIPOS

COMPUTER SCIENCE TRIPOS CST.2003.1.1 COMPUTER SCIENCE TRIPOS Part IA Monday 2 June 2003 1.30 to 4.30 Paper 1 Answer two questions from Section A, and one question from each of Sections B, C, D and E. Submit the answers in six

More information

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8.

OOPs Concepts. 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. OOPs Concepts 1. Data Hiding 2. Encapsulation 3. Abstraction 4. Is-A Relationship 5. Method Signature 6. Polymorphism 7. Constructors 8. Type Casting Let us discuss them in detail: 1. Data Hiding: Every

More information

The New Java Technology Memory Model

The New Java Technology Memory Model The New Java Technology Memory Model java.sun.com/javaone/sf Jeremy Manson and William Pugh http://www.cs.umd.edu/~pugh 1 Audience Assume you are familiar with basics of Java technology-based threads (

More information

IBS Software Services Technical Interview Questions. Q1. What is the difference between declaration and definition?

IBS Software Services Technical Interview Questions. Q1. What is the difference between declaration and definition? IBS Software Services Technical Interview Questions Q1. What is the difference between declaration and definition? The declaration tells the compiler that at some later point we plan to present the definition

More information

Page 1

Page 1 Java 1. Core java a. Core Java Programming Introduction of Java Introduction to Java; features of Java Comparison with C and C++ Download and install JDK/JRE (Environment variables set up) The JDK Directory

More information

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu

CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu CS 528 Mobile and Ubiquitous Computing Lecture 3b: Android Activity Lifecycle and Intents Emmanuel Agu Android Activity LifeCycle Starting Activities Android applications don't start with a call to main(string[])

More information

Careerarm.com. Question 1. Orders table OrderId int Checked Deptno int Checked Amount int Checked

Careerarm.com. Question 1. Orders table OrderId int Checked Deptno int Checked Amount int Checked Question 1 Orders table OrderId int Checked Deptno int Checked Amount int Checked sales table orderid int Checked salesmanid int Checked Get the highest earning salesman in each department. select salesmanid,

More information

Tongbo Luo Cong Zheng Zhi Xu Xin Ouyang ANTI-PLUGIN: DON T LET YOUR APP PLAY AS AN ANDROID PLUGIN

Tongbo Luo Cong Zheng Zhi Xu Xin Ouyang ANTI-PLUGIN: DON T LET YOUR APP PLAY AS AN ANDROID PLUGIN Tongbo Luo Cong Zheng Zhi Xu Xin Ouyang ANTI-PLUGIN: DON T LET YOUR APP PLAY AS AN ANDROID PLUGIN Bio Black Hat Veteran. Principle Security Researcher @ PANW. Mobile Security - Discover Malware - Android

More information

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol

Pro JPA 2. Mastering the Java Persistence API. Apress* Mike Keith and Merrick Schnicariol Pro JPA 2 Mastering the Java Persistence API Mike Keith and Merrick Schnicariol Apress* Gootents at a Glance g V Contents... ; v Foreword _ ^ Afooyt the Author XXj About the Technical Reviewer.. *....

More information

CSE 70 Final Exam Fall 2009

CSE 70 Final Exam Fall 2009 Signature cs70f Name Student ID CSE 70 Final Exam Fall 2009 Page 1 (10 points) Page 2 (16 points) Page 3 (22 points) Page 4 (13 points) Page 5 (15 points) Page 6 (20 points) Page 7 (9 points) Page 8 (15

More information

EINDHOVEN UNIVERSITY OF TECHNOLOGY

EINDHOVEN UNIVERSITY OF TECHNOLOGY EINDHOVEN UNIVERSITY OF TECHNOLOGY Department of Mathematics & Computer Science Exam Programming Methods, 2IP15, Wednesday 17 April 2013, 09:00 12:00 TU/e THIS IS THE EXAMINER S COPY WITH (POSSIBLY INCOMPLETE)

More information

The Bakery. from the BLACK LAGOON

The Bakery. from the BLACK LAGOON The Bakery from the BLACK LAGOON trait UserModule { def loaduser(id: Long): User trait TweetModule { def post(userid: Long, body: String) trait MySQLUserModule extends UserModule { trait TwitterModule

More information

Arrays. Friday, November 9, Department of Computer Science Wellesley College

Arrays. Friday, November 9, Department of Computer Science Wellesley College Arrays Friday, November 9, CS Computer Programming Department of Computer Science Wellesley College Arrays: Motivation o o o Lists are great for representing a collection of values, but can only access

More information

CMSC436: Fall 2013 Week 3 Lab

CMSC436: Fall 2013 Week 3 Lab CMSC436: Fall 2013 Week 3 Lab Objectives: Familiarize yourself with the Activity class, the Activity lifecycle, and the Android reconfiguration process. Create and monitor a simple application to observe

More information

Atelier Java - J2. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

Atelier Java - J2. Marwan Burelle.   EPITA Première Année Cycle Ingénieur. marwan.burelle@lse.epita.fr http://wiki-prog.kh405.net Plan 1 2 Plan 1 2 Notions of interfaces describe what an object must provide without describing how. It extends the types name strategy to provide

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Statically vs. Dynamically typed languages

More information

Dependency Injection with ObjectPoolManager

Dependency Injection with ObjectPoolManager Dependency Injection with ObjectPoolManager Recently I got my hands over some of the IOC tools available for.net and really liked the concept of dependency injection from starting stage of application

More information

Section 8: Design Patterns. Slides by Alex Mariakakis. with material from David Mailhot, Hal Perkins, Mike Ernst

Section 8: Design Patterns. Slides by Alex Mariakakis. with material from David Mailhot, Hal Perkins, Mike Ernst Section 8: Design Patterns Slides by Alex Mariakakis with material from David Mailhot, Hal Perkins, Mike Ernst Announcements HW8 due tonight 10 pm Quiz 7 due tonight 10 pm Industry guest speaker tomorrow!

More information