Something common to be found in large Android codebases is dimens.xml file with contents that look like this

This is a major ๐Ÿšฉ๐Ÿšฉ๐Ÿšฉ๐Ÿšฉ

It originates from overzealous developers not wanting to *hardcode pixel/dp in layout XMLs*, but it very counterproductive. Image
We need not be grammar-nazi like in our approach and go for a hard-rule on never to write android:layout_height=12dp kind of code, because from a readability perspective, there is no advantage of turning fig.1 into fig.2

@dimen/_24dp has to be 24dp right? What is the point? ImageImage
In fact, now we have opened ourselves to a whole different level of subterfuge in the code in the future.

What if, some day, (by mistake, not deliberately), someone changes these values. Perfectly possible under time-constraint, doing last-minute UI fixes. Image
Voila now, "@dimen/_38dp" actually means 48dp. We just turned the situation way worse. Nothing means what it says anymore.

This is waaaaay worse than just hardcoding 38dp or 48dp in the ImageView or wherever.
So what is a good approach you ask ?

Well there are 2 situations

1. the dimension can be semantically named, if so then do it and use a dimen.xml argument
2. it is really ad-hoc in nature, cannot have a semantic name. Then just hardcode the dp value.
Addendum: What is a semantic name ?

Something like "fragment_vertical_padding" - the const you use paddings of all your fragments.
Or "heading_text_size" - the const you use for text size of all your heading texts.

โ€ข โ€ข โ€ข

Missing some Tweet in this thread? You can try to force a refresh
ใ€€

Keep Current with Arnav Gupta ๐Ÿ˜ท ๐Ÿ’‰๐ŸŸข ๐Ÿ’‰๐ŸŸข

Arnav Gupta ๐Ÿ˜ท ๐Ÿ’‰๐ŸŸข ๐Ÿ’‰๐ŸŸข Profile picture

Stay in touch and get notified when new unrolls are available from this author!

Read all threads

This Thread may be Removed Anytime!

PDF

Twitter may remove this content at anytime! Save it as PDF for later use!

Try unrolling a thread yourself!

how to unroll video
  1. Follow @ThreadReaderApp to mention us!

  2. From a Twitter thread mention us with a keyword "unroll"
@threadreaderapp unroll

Practice here first or read more on our help page!

More from @championswimmer

Jan 13
200 LeetCode questions in 3rd year of college.
FAANG/BigTech job in placements
2 yrs in India, then move to US (sponsored by that BigTech)
7-8 yrs of laid back 5hrs/day work, with 30-40 leaves a year and slowly climb to L5

That's how majority folks turn millionaires by 30
Doesn't sound sexy or cool. Sounds counterintuitive, that if it is that straightforward, then why aren't more people doing it ?

Well if my estimates are correct, every year at least 10000 (probably 20000) Indian techies are doing exactly that.
Don't mistake this as advice to follow this path. (Hell I didn't, myself).
Don't mistake this as an indication of this being "easy" either

Getting into those jobs is not 'easy'. The path is well known and well trodden, but takes time and effort.
Read 5 tweets
Dec 29, 2021
As I filed my tax returns I realised last year I paid more taxes than the sum of all taxes I ever paid before that in my life.

Also couldn't stop thinking about how I'm actively funding a machinery that propagates hate on a religion which was celebrating their festival that day
Every day for every 3-4 rupees I make, I contribute a rupee to this refined, well oiled machine, sprouting hatred in a refined, perfected manner for the last many years.

Muslim, Christian friends of my generation have literally been leaving the country to escape the oppression
I have been paying taxes, coincidentally, exactly since the BJP govt came to power. And not that bridges were not made (some fell too), or roads were not repaired (except in Bangalore), but I have a feeling mostly I have just been funding a terror org, just legally.
Read 4 tweets
Oct 27, 2021
So I recently moved from #Delhi to #Bangalore and the easiest and fastest way I could move my work desk setup (monitors, PC, gaming chair) and my car was to stuff all that into the ๐Ÿš— and drive it all the way down.

So here's a smol thread ๐Ÿงต on a DEL-BLR road trip. Image
Day 1 was planned to be #Delhi to #Gwalior. But that would have left a very long 2nd day, so we planned to go a little further to Jhansi.

A complete chance browsing through @bookingcom led us to discover this beautiful Bundelkhand Riverside Resort at Orchcha to stay. Image
Day 1 was 425 km. Total drive time was 10hrs+, because we stopped at Agra to visit @TajMahal too.

Booked Hotel Atulyaa Taaj (apart from Oberoi Amarvilas, this is the nearest hotel to Taj) simply as an expensive parking spot ๐Ÿ˜… as the car was loaded with stuff. Image
Read 15 tweets
Oct 18, 2021
Today in India's tech ecosystem, if you ask *ANY*one, literally anyone, <5yrs exp, about what is the one thing they want to do to grow, 100% of them (including the Google engineers) say that they want to change jobs.
It is sad that we have over the last 1.5 years created a market where somehow everyone has FOMO. Everyone feels underemployed. 3yrs exp folks earning 50L found some outlier of an outlier on Blind earning $300k remote from India, and they now want that.
I am not saying when there is an open market, one should not look to optimise their net worth. But isn't it sad if you go out and do 100+ user interviews, mainly from highly aspirational companies, and 100% of them are looking to change jobs within 6 months.
Read 6 tweets
Aug 1, 2021
Over the last 3 years or so I have had to hire/help-to-hire a lot of senior engineers, especially in small to mid startups.

Usually it is in a role where the person would be the main pivot of the team and be responsible for a project.

A thread on what has worked ๐Ÿงต๐Ÿ‘‡๐Ÿผ
Over the last couple of years the tech hiring market has become more and more uphill. If you're a small startup, it is super challenging today. There are funded startups who are dying off because they are unable to corner tech talent. So the challenge is very real here.
Small caveat here - these are contextualised a bit towards Android, as that's what I have mostly hired for. Although the same methods and principles I have used for things like Node/Java backend too which has worked out well.
Read 30 tweets
Aug 1, 2021
I don't build social media clout for a dopamine fix.

Social media clout today is part of the essential consumer survival kit.

It is not only easy to access redressal mechanisms with most B2C businesses if you have clout, but in fact the only process of it happening today.
If you do not have the capability to raise a rabble, you just have no insurance against bad consumer experience and dealing with faulty products/services in today's world.

This is just the Black Mirror-esque world we live in now.

"Social credit scores" actually exist
I have regularly had experiences where my problems got fixed - exact same problems for which my friends who are not active on social have gotten the short end of stick.

In fact, the extreme end of *this* very spectrum is B2C brands sending freebies to influencers.
Read 4 tweets

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just two indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3/month or $30/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal

Or Donate anonymously using crypto!

Ethereum

0xfe58350B80634f60Fa6Dc149a72b4DFbc17D341E copy

Bitcoin

3ATGMxNzCUFzxpMCHL5sWSt4DVtS8UqXpi copy

Thank you for your support!

Follow Us on Twitter!

:(