5 Common Android Anti-Patterns That Make Your Code a Mess

preview_player
Показать описание
In this video you're going to learn about 5 anti-patterns that will make your code bad. I see people use these all the time.

00:00 - Using base classes
03:46 - Putting all dependencies in AppModule
06:15 - Using one activity per screen
08:08 - Hardcoding dispatchers
13:36 - Using GlobalScope

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

💻 Let me personally review your code and provide individual feedback, so it won't backfire and cost you a fortune in future:

Join this channel to get access to perks:

Regular live codings on Twitch:

Join my Discord server:

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

Philipp's happiness while recording this video was on 🔥🔥

mehulbisht
Автор

You're killing it Phillipp, this is an outstanding video!
I so appreciate these type.
Heck, I like all your videos.
Keep up the good work man!!

matt-g-recovers
Автор

Please continue this series! This is the kind of information that is hard to come by. I wish I knew this when I started.

joemoe
Автор

Thanks Philipp, can you make a video on *"How to use sealed classes in android"* with a practical example

jatinvashisht
Автор

Hey Philipp, on the first anti pattern, I think the extension function doesn't solve the tight coupling issue as an update on the extension function affects all class using this function.

sundayndu
Автор

Outstanding, I thought it will be same old boring stuff other channels are talking about in such videos, but of course, you had to make it cover actual bit more advanced topics and provide awesome knowledge and point of view, thanks!

dawidtyburek
Автор

MainActivity inherits from BaseActivity and you say we have no idea what this BaseActivity brings. You change it to an extension function, but i'm afraid we have no idea which extension functions are available, do we?

philippepons
Автор

You cant say using BaseClasses is an anti pattern, i have used some BaseActivity and BaseFragment and BaseViewmodel which makes life very easy for me, you need to know how to structure your Base classes

aabhishek
Автор

What is the best place to put all extensions together, for example for Activity? A separate file like ActivityExtensions? Great video and huge knowledge. Thanks.

aksonsoftware
Автор

5 Common Android Anti-Patterns Solutions in a Nutshell:

I) Don't use global scope - WHY? memory leaks
II) Use dispatcher provider interface and its implemented classes - WHY? testing purposes + constructor injection is the best
III) Use fragments instead of activities - WHY? more activities == heavier and slower app + complicated code because of intents (my opinion)
IV) Specific module for each requirement - WHY? memory efficiency + cleaner code + testing purposes
V) Don't use base classes, use extension functions instead - WHY? Design principle: always favor composition over inheritance

Alchemist
Автор

Thank you Philip. Today's morning started from your video😄😊 nice explanation 👍

daniyar
Автор

Wait a minute, can't you also override the `showToast`, if it is defined in the `BaseActivity`?

typingcat
Автор

According to you baseActivity is antipattern and the reason is just a toast. Actually I never used baseActivity for a single toast. You can achieve a lot of functionality through base activity. What if you want to do some work in oncreat of every activity. Base activity comes to rescue.

afnanhaiderhaider
Автор

Sometimes without base classes it's very hard. Suppose we have 20 fragments and every fragment needs to execute something only 1 minute. Fo that I need to create CountDownTimer and after finish just exit that fragment. But it's not the right way to write CountDownTimer logic in every fragment separately, instead I can create that timer in my BaseFragment, start it in onCreateView(). After this I don't need any single line of code in my 20 fragments, I just need to extend BaseFragment.
But I'm also agree with you, because in some cases like toasts or similar things are bad practices and no need of base classes in that case.

haykmkrtchyan
Автор

Excellent Video, very useful, Greetings from Caracas, Venezuela

VenewebTV
Автор

I don't agree about base classes. They help one protect from changes of framework api. E.g. some new android api sets some field nullable/non-nullable, or a package name changed.
For me, it's better to have as little direct derivatives from framework classes as possible, because you have no control on them

Fateslav
Автор

Great video as always Philipp, the example on the first anti-pattern made me think about a case on my job, it's kind of a base class with a method with a lot of logic and there's some child classes that inherit from it and overrites maybe one or two of the secondaries methods cause the differences on behavior are minimal, I guess in a case like this where is not just a toast wouldn't be a bad approach, right?

nicolasmarin
Автор

Thanks Philipp!!! Really great and informative video!

patrickessiam
Автор

I mostly liked the hard coding dispatchers chapter.
Thanks, Philipp

venkatesh
Автор

Really your videos are increasing my code quality.... Hopi g for more videos...👏

atchayvarma