Dependency Injection in Swift (Mini Cake solution)

I already talked about the subject of Dependency Inversion here and of course the way to implement Dependency Inversion is to use Dependency Injection.

First let’s go back to what is Dependency Injection. Dependency injection is used to inject real implementations into a class that uses abstract interfaces instead. So let’s say a Presenter Class uses of View Class. If you are using SOLID, then your Presenter Class will “see” the View Class thru an abstract interface (a contract) and thus the dependency to the View Class will be reversed as you can see in the Fig-1.

Fig-1 : Presenter-Interface-View

When this is done, you can “insert” whatever View in the Presenter as long as it respects the View Protocol contract.

To do the insertion, you will use Dependency Injection. There are 2 types of Dependency Injection :

  1. Dependency Injection at instanciation
  2. Dependency Injection by modification

Continue reading “Dependency Injection in Swift (Mini Cake solution)”

ReactNative Native Modules in Swift – Part 3 (details, conclusion, …)

To give a conclusion to this subject treated in Part1 and Part2, I want to go back to how native module work and how to communicate between native modules and ReactNative modules.

First, let’s talk about the .m file that enables to link native to JS thru runtime. The code was this :

#import <React/RCTBridgeModule.h>

@interface RCT_EXTERN_MODULE(MyNativeModule, NSObject)
RCT_EXTERN_METHOD(triggerJSRequest)
@end

Continue reading “ReactNative Native Modules in Swift – Part 3 (details, conclusion, …)”

From VIPER to VIP’R (VIP – pause – R) or how to eject Entity!

For this week, I want to give a clear example of the type of architecture that I’m trying to push on the projects I work on. Some of you probably already know VIPER. It tends to become a classical architecture in iOS development and in other platforms like Android. VIPER goes for :

  • V : View
  • I: Interactor
  • P: Presenter
  • E: Entitie
  • R: Router

It was inspired by the Onion Architecture or Clean Architecture pushed by Robert Cecil Martin, more known as Uncle Bob.

The Clean Architecture – © Robert Martin.

On the image The Clean Architecture, you can see an example of what it looks like. You see “skins”, or layers, that go from external to internal, crossing boundaries in one way and going right to the center where you find Entities. Continue reading “From VIPER to VIP’R (VIP – pause – R) or how to eject Entity!”