Full Guide to Delegation in Kotlin - Android Studio Tutorial

preview_player
Показать описание
Delegation is a concept in software that allows us to delegate some work from one object to another and is commonly seen as alternative to inheritance. In this video, I'll show you how you can benefit from it in your Android project.

⭐ Get certificates for your future job
⭐ Save countless hours of time
⭐ 100% money back guarantee for 30 days
⭐ Become a professional Android developer now:

🎓 Become an industry-ready developer in the Mobile Dev Campus:

🎁 Get my FREE 4.5h course "The Best Practice Guide to Android Architecture":

Read our weekly Android blog:

Join this channel to get access to perks:

Get the source code for this video here:

Join my Discord server:

You like my free content? Here you can buy me a coffee:
Рекомендации по теме
Комментарии
Автор

Quick question: How do you like having quiet background music in tutorial videos like this one? Fits well or rather distracting? Thanks!!

PhilippLackner
Автор

For each and every video I see, I'm getting improved more and more. Almost all of your videos are helpful for at least one of my projects. My colleagues, CTO and managers always appreciate me with the knowledge I have which has come from you.

I really feel so happy and lucky to have your videos when I'm learning... Of course lifetime learning is required for any software developer and you are the one major contribution for me.

Thanks again Philipp.

Zeeshan-Syed
Автор

When I search some confusions about android on the YouTube, it will always recommend Philipp's tutorials, you always know what confuses me~~

acercow
Автор

Man, you are the best...
I'm starting a new project in my current job, and I'm going to apply this new knowledge here. Thanks a lot.

viniciuscoscia
Автор

Thanks, Philipp for this video. For my last three project's I have created BaseActivity, Basefragment for common code base. Now after I am trying to convert my base code through delegation.

NeerajGupta-offy
Автор

Super cool video. I feel like after several smaller projects, I'm starting to get better at visualizing separation of concerns across different object types, and how we can link them together.

spicyunicornmilkfarmer
Автор

Although this is a cool way to implement core functionalities, it is impractical when your app has multiple activities and multiple devs working on it. Each and everyone has to remember to add these sets of lines in their code (considering these are critical functionalities like analytics, initialisers etc). If even one of them gets missed, it becomes a huge pain for both the dev and code reviewer to explain this. This is true when there are new developers in your company. Base Activity (although might look like an anti pattern) mitigates the human error part. Generally most companies have a dedicated platform team which takes care about these core functionalities of the activity, and other feature teams/pods simply inherit this base activity which is maintained by the platform team. Moreover, if let's say a new core functionality ( ex a new library) is being added, 100s of activity files needs change. Huge PR, and huge effort to review.

pranaym
Автор

I am the one Base user, and now I understand why you said Base not a good practice. Actually you right with Interface, we can only add it when we need some.
Anw, love this new video, I easily get distracted with BGM but yours so far enjoyable, maybe just carefully choose BGM so we don't distract.
The way you zoom in out is smooth too. Keep it up! 👍🏿

bboydarknesz
Автор

Watching all your videos like a TV series 😅😋 Keepem coming!! 👍

prageeth
Автор

This was very helpfull, i have a bottom sheet dialog for taking images from different sources, such as camera, gallery and own explorer.

For camera and gallery I use contracts, and also I have to check for permissions for access the camera, all of this logic was rewritten on every fragment that makes use of that bottom sheet dialog.

So I put all of this logic into a class and now, fragments just have to instantiate an object of this class.

Thanks You.

andreshoyo
Автор

Created today a class to handle Otp Auth with firebase. Previously, it was a method inherited using a base activity, now whe are using delegate, and its clear that the single responsability principle its achieved with delegation.

arthurgomes
Автор

Thanks for Video. I keep improving by watching your tutorials

Guilo
Автор

Super excellent way of using delegation!

stanleykou
Автор

I agree, base activies are an antipattern they end up being dumps for anything. Favour composition over inheritance.

clivejefferies
Автор

Good video, Philipp! Question: You created interfaces, then never really used them. If this were dependency injection, then you wasted the opportunity to substitute different implementations - for example in testing. How does the use of an Interface help things? Seems like the Activity is hopelessly coupled to particular implementations...

ubersticks
Автор

Thanks for the video. Never knew how to actually use delegates :)

DerCheckerzeigts
Автор

Really amazing, I learnt a lot and am still learning and your videos are the major part of it, It really helped me a lot and I'm able to grab multiple offers, Really Thank you, you are one of the best mentor.

ketanchaurasiya
Автор

Great video! Really useful. If I understood correctly, then this Kotlin delegation works exactly the same as the delegation in Swift (?). This will be really useful to make some implementation similar, since I feel Swift and Kotlin already look quite similar!

joseangelsanchez
Автор

Best explainer I have ever seen. Thanks @Philipp

GK-rcfd
Автор

BaseActivity havy user here ;)
Thanks for wonderful video
I get the Single Responsibility argument, but this seems very impractical to use in real life.
For example - if I have an app that has lots of Activities and I want all of them to have AnalyticsLogger and DeepLinkHandler I have to remember to correctly override onCreate and onNewIntent in every single one of them. If I were to use inheritance I wouldn't have that problem

Czarnini
welcome to shbcf.ru