Constructors and Init blocks in Kotlin - BEST PRACTICES

Constructors and Init blocks in Kotlin - BEST PRACTICES

Rahul Pandey

3 года назад

16,361 Просмотров

Effective Kotlin requires the use of classes. In this video, we talk about how to instantiate objects using constructors and the init block. We also discuss best practices for object oriented programming (OOP).

➤ Programming Kotlin by Venkat Subramaniam: https://amzn.to/33yHJ7r
➤ Android Cookbook: https://amzn.to/3IfEX6h
➤ Head First Kotlin: https://amzn.to/3I77Z7Z
Kotlin style guide: https://android.github.io/kotlin-guides/style.html
Kotlin classes: https://kotlinlang.org/docs/reference/classes.html

Hi! I’m Rahul, a software engineer with a passion for teaching. I went to Stanford, was a founding engineer at a startup, and have worked at various companies across Silicon Valley. I’m currently an Android Developer at Facebook and teach an Android class at Stanford. Would love to connect with you! This channel is about tech (especially Silicon Valley), combining tactical how-to guides with interviews.

📹 YouTube: https://www.youtube.com/c/RahulPandeyrkp?sub_confirmation=1
📝 LinkedIn: https://www.linkedin.com/in/rpandey1234/
🐦 Twitter: https://twitter.com/rpandey1234
📸 Instagram: https://www.instagram.com/rpandey1234/
📂 Github: https://github.com/rpandey1234/

Тэги:

#android #androidstudio #development #programming #kotlin #code #tutorial #rahulpandey #rahul #pandey #teach #kotlin_constructors #kotlin_init_block #kotlin_best_practice #kotlin_best_practices #kotlin_android #java_to_kotlin #kotlin_style #kotlin_oop #kotlin_object_oriented_programming #kotlin_mistakes
Ссылки и html тэги не поддерживаются


Комментарии:

Rishi Raj
Rishi Raj - 14.09.2023 11:53

Thanks

Ответить
Lokeshwar PG
Lokeshwar PG - 03.07.2023 09:36

what if the doesSmile is false
will it throw an error for nickname undefined

Ответить
Harwinder Benipal
Harwinder Benipal - 30.05.2023 14:53

If we write the smily code wothout int it still will be working. So whats the purpose of init here i didnt get it?

Ответить
William Castro
William Castro - 11.05.2023 06:42

Thanks for the excellent video, I learned a lot!
Question? I come from JavaScript and I was wondering does Kotlin have High Order Arrays? Examples would be forEach, map, filter, reduce. Or what about arrow functions? I am spoiled with JavaScript and so far I haven't seen other programming languages with these features. Thank you.!!

Ответить
bouchnak jihed
bouchnak jihed - 10.04.2023 14:20

good job Rahul could you made us video about code optimisations fro more clean code ?

Ответить
Rodrigo
Rodrigo - 13.05.2021 02:06

Hi Rahul! Nice video!
I was wondering what are your thoughts on the kind of logic that should go into the init{} method.
I'm interested in some cases where instances of ViewModels have their init{} performing some sort of communication with repositories. I have a feeling that init{} shouldn't perform such implicit actions (which may also introduce side effects). Do you have any thoughts on it?
Again, thanks for the content! Have a good day.

Ответить
Dan Tran
Dan Tran - 01.05.2021 07:12

Your example is so simple and concise. Straight to the point.

Ответить
Muhammad Wasim
Muhammad Wasim - 25.04.2021 15:42

I tried to create the Person class in a separate file. It goes under the resources directory. And I'm not able to import it in my main.kt file. How can I import that kotlin Person.kt file?

Ответить
shubham mandal
shubham mandal - 15.04.2021 12:08

Exactly to the point video!
thanks brother

Ответить
Sagar Lokhande
Sagar Lokhande - 30.01.2021 20:35

Sir can you teach us how REST API is used in one more fragment plz

Ответить
Nikitha B.M
Nikitha B.M - 18.01.2021 15:52

Hi. Why is doesSmile not the member variable? Could you please elaborate?

Ответить
19Olcay97
19Olcay97 - 13.01.2021 02:30

Sir, your videos are awesome.

Ответить
Adam Deane
Adam Deane - 12.01.2021 08:05

Can you do a video on keyboard shortcuts? I do everything the hard way and I would like to be more efficient.

Ответить
Gajendra Pandeya
Gajendra Pandeya - 12.01.2021 04:06

Awesome. Loved it

Ответить
Dayamoy Adhikari
Dayamoy Adhikari - 11.01.2021 22:15

More videos on best practices please! ✨🙌

Ответить
Suboptimal Engineer
Suboptimal Engineer - 11.01.2021 20:19

Rahul: Deliberately made it suboptimal...
Me, a suboptimal engineer: Nice

Ответить