meguid / EvenTask

Event Based Task Management
4 stars 4 forks source link

`BaseViewController` may not be the best way to handle common actions #21

Open fadi-botros opened 5 years ago

fadi-botros commented 5 years ago

https://github.com/meguid/EvenTask/blob/06cf013359f2e0b4aeb82a649ccb3ba7e9547271/EvenTask/Modules/BaseView.swift#L10

Imagine you are making an Android application and needs Dagger 2, which makes BaseActivity and something. How could you inherit both while Swift, Objective-C, Java, and Kotlin don't allow multiple inheritance??

You could favour composition over inheritance, create a struct (or even a class) that is instantiated, then call from the viewDidLoad, etc... manually (just a call, not a big repetition), or use Java's code generation (annotation processing) when on Android, and Objective-C method Swizzling (dynamic function dispatch) in iOS.

There is a library by Abuzeid Ibrahim that Swizzles the UIViewController Life-Cycle

meguid commented 5 years ago

@fadi-botros I get your concern, and I'm thinking about it, I just will give the BaseView few days to see what it's gonna evolve to (functionality wise) to see what's going to be the best approach for it.