Which beliefs or practices in your colleagues or other developers that you work with or read of drives you mad, or you find at least questionable?

A place for rant, but also for serious discussion of pros and cons of habits in Android development.

So here’s mine, free to argue:

  1. **Putting each and everything into dimens.xml or colors.xml**. You have a layout, and for some reason or another, you create a margin between two buttons of 56dp. I do android:layout_margin=”56dp” in the layout file and that’s it. Some developers do:

`android:layout_margin=”@dimen/activity_product_details_margin_buy_button_cancel_button” <dimen name=”activity_product_details_margin_buy_button_cancel_button”>56dp</dimen>` in the dimens.xml and link to that from their layout. What for? It’s just a detour. Now if that same margin is used on another layout and it becomes your default margin between two buttons, I get it. But for these one-shot kind of things … don’t see the point. Bonus points for an extra detour: `android:layout_margin=”@dimen/activity_product_details_margin_buy_button_cancel_button” <dimen name=”activity_product_details_margin_buy_button_cancel_button”>@dimen/very_large_margin</dimen> <dimen name=”very_large_margin”>56dp</dimen>`

  1. **IntDefs**. So you’ve watched that PerfMatters video on 5 years ago and they said enums will make your slow and ugly and noone will want to download it. Maybe you even read an “article” on Medium by someone who watched the same video and felt like he needed to parrot its’ content. You didn’t conduct any experiments on your own, nor are you willing to accept the fact that there’s loads of stuff in you you could much more easily optimize. Screw you for making me write these horrible IntDef abominations for the sake of your premature optimization fetish. Oh, and btw: neither Android Studio nor the compiler nor any code analysis tool, to this day, enforces your precious IntDefs on any non-trivial case.

  2. **Copypasting from old projects**. Your company already did an app that uses an http connection to fetch stuff from an API and that code is rotting somewhere in the depths of your Git repo … why not copy paste some of that into a fresh project? Nevermind it was written years ago by an intern, has no tests and there’s tons of state-of-the art libs out there that do the same thing better. You go ahead, I’m not touching it should any problems arise. Very much related to “not invented here”.

  3. **Interfacing everything**. I’m going to be a bit provocative here and say that 90%; of interfaces created in Android code (and probably loads of other code) are useless. There seems to be a widespread … not belief, but vague sentiment that interfaces make your code ‘clean’. What’s the purpose of an interface? a. To provide a contract on what the implementing class ‘can do’. b. To make the implementations interchangable when used by another class That does make sense, but: a. That contract is often provided simply by the sum of public methods a class provides b. most interfaces are never ever interchanged. In reality, most interfaces have exactly one implementation and will never have a second one. By adding this interface you have gained nothing, except for an additional file to the project, congratulations.

Post your least Android developer practices.

Source link


Please enter your comment!
Please enter your name here