//TODO Live Templates06 Mar 2020 | tags: android studio
Throughout my career, I have worked in projects of all sizes. I have taken part in greenfield projects and some that are a few years old. One of the lessons I have learned over the years is that no one ever goes back to fix the
In our current project, we are trying to mitigate the unchecked growth of this list (we have some from 2015 ). One of the solutions we are trying to explore is to create labeled
// TODO-Zarah (06 Mar 2020): Some comments go here
This means that when leaving a
TODO, devs would have to leave their name and the date in the comment. We then do periodic checks (usually before a release) to make sure that we are actively going back and actually fixing the issues.
Now typing the same thing over and over is indeed very annoying,
To help alleviate the pain, we decided to employ parameterised live templates. There are a whole bunch of these templates (
Live Templates) available in Android Studio, like the one for making a
Never forget .show() again
To create our template, open
Live Templates then click on the
+ sign on the right of the panel. I chose to create a
Template Group to contain our custom templates, but it’s also fine to directly add a new item to any of the existing groups.
Template creation menu
Live Template Anatomy
Android Studio will ask for some information when creating templates:
Live template anatomy
Abbreviation: What the user should type to use a template
Description: Short text to appear in the context menu
Template text: The actual template, including variables
Context: Gives Android Studio hints on when it should suggest the template (choosing Java and Kotlin is usually sufficient)
Variables are either pre-defined values or input fields. In our case, we have several of these:
- person the
TODOis assigned to
- the date the
- the actual comment for the
TODO(optional, can be left out of the template)
To auto-populate the variable values, click on the
Edit Variables button and define the expressions to use. There are a lot of pre-defined functions we can leverage.
On my work computer, the
user() function gives back my work-imposed ID and it’s not pretty. To use a better (i.e., my actual name) value without having to type it over and over, we can override Android Studio’s custom properties (
Edit custom properties) and add the value:
And here’s our brand new template in action:
Custom template in action
At the start of this post I mentioned that we do periodic checks on our
TODOs. When I look at our
TODO panel (
Tool Windows >
TODO), there are hundreds of them across so many files. Before a release, we review all the templated ones so we can follow up with the devs who left the comments.
To make this task easier, we created a
Unfortunately the results of this search is not exportable, so if we want to generate a report we need to run code analysis (
Run inspection by name) and choose
TODO. This can be exported to either HTML or XML which makes it easier to share with the team.
Your Privilege is Showing21 Jan 2020 | tags: musings
When I left the Philippines five years ago, I had a high-paying job at the heart of the country’s financial district. I was living a very comfortable life: I can afford an annual membership to a yoga studio, I bought an off-the-plan apartment with views of Manila Bay, I get to treat my parents to a holiday once in a while, I get to travel with my friends – we were even able to go abroad a couple of times!
When I left the Philippines, I was getting paid an annual salary of PHP1.7M. That may sound a lot, but in Australian Dollars that is only 48k – slightly above the minimum wage set by the Fair Work Commission, and way less than what a junior developer would earn.
But the thing is, that IS a lot of money. Chances are a lot of people outside tech might work all their life and never get to that salary range at all. I am indeed extremely luckier and more privileged than other people in my home country.
With all that money, it was still a challenge to do one thing I would have loved to do more of when I was younger – to travel. I’ve always read books and seen shows where teenagers go to exotic places, or heartbroken lovers go to the airport and buy tickets to “anywhere”, or people doing the whole Eat Pray Love thing.
You see, I had the unfortunate case of being born in the Philippines to parents who were also born in the Philippines. Outside of traveling outside Southeast Asia, having a Philippine passport is like traveling in super hard mode:
Them: YoU haVEn'T BeEn tO LoNDon???— Zarah Dominguez 🦉 (@zarahjutz) July 17, 2019
Me: No, it's really difficult to get a visa.
Them: *puzzled looks*
Me:: *pulls list out* pic.twitter.com/i7tnokjUBb
And that’s just going to ONE country. At some point in the past I swore that I am going on a Europe tour on my 40th birthday. That would mean applying for a Schengen visa; which means I need a full itinerary planned out; which means I have to prepay ALL hotels and transportation to all the countries I want to visit; which does not guarantee me being granted a visa at all. It takes a lot of physical and emotional energy getting all these requirements together, not to mention the monetary investment when applying for a visa (for Schengen, non-refundable fee of ~PHP4,000 – equivalent to a month’s rent). I checked the requirements again when I got my Australian passport, and guess what, I can apply online and then I basically just show up? Whut.
Look, the requirements I showed in that tweet is NOT unique to the UK. Almost all countries have the same requirements for Filipinos. Even when I got my work permit in Australia, I have to provide almost the same exact requirements if I want to go to New Zealand (and now that I am an Australian citizen I can just show up there? Like… It’s still me??).
Don’t even get me started on how I get treated when I land in the country I’m visiting. Some questions I have been asked by immigration:
- you have a Philippine passport, why are you flying from Australia?
- how did you find your job in Australia?
- who invited you to go to this conference?
- why did they invite you to this conference?
I’ve traveled twice so far on my Australian passport and I have to say I have received the warmest welcome I have experienced ever.
Anyway, what I am trying to say is that the past couple of days suck because of something I keep on seeing on Twitter. People have been posting all the countries they have been to, and all the others on their bucket list.
I guess sometimes it’s easy to lose sight of how things we take for granted are just faraway dreams for some. When I started traveling internationally, I couldn’t have imagined the amount of suffering and humiliation that I had to go through just to get visas. I have lost count of how many times I have been looked down upon because of the country I was born in, or the passport I am holding. I know that there are SO MANY people out there who have the same aspirations and the same bucket lists as those we see in the meme but have resigned themselves to the fact that it will just be that – a bucket list.
I recognise that as it is, I am much much luckier and more privileged than most. I was given the chance to set myself up for success, I have a supportive family behind me, and I have been given so many opportunities to pull myself up. I am not discounting the fact that those people have worked hard to be where they are, and I am sure they deserve all the fun and enjoyment that they are having.
All I hope for is that we all do not forget how extremely valuable freedom of movement is, and how liberating it must be to have the means to enjoy that freedom.
Which is Which: Named Breakpoints15 Jan 2020 | tags: android studio tools
I have always believed that one of the biggest factors that influence a person’s enjoyment and delight in doing their job are the tools. Having the right tools and using them the best way possible helps direct our energy on the what rather than the how.
For instance, I have lost count of how many times I stopped in the middle of a debugging session only to find myself drowning in breakpoints. I have put in so many that I have lost track of which breakpoint does what, or why I even put a breakpoint on a particular line in the first place.
What are even these lines
It is situations like this that breakpoint descriptions become super handy. These descriptions appear after the line number and provide an easy way of keeping track AND searching for breakpoints.
For example, adding “drag dismiss” after the breakpoint on line 84 serves as a short note to myself what that piece of code is doing. It gives me a hint about what I may want to do with that breakpoint when I’m grouping, muting, cleaning up, or managing all the other breakpoints.
Breakpoint with a description
To add a description, open the Breakpoints Dialog.
First open the Edit Breakpoint dialog using any of the following:
ALT + ENTERon any line with a breakpoint and then choosing “Edit Breakpoint”
SHIFT+COMMAND+F8on any line with a breakpoint
- right-clicking on a breakpoint in the gutter
Edit Breakpoint dialog
We can then click on More or press
SHIFT+COMMAND+F8 to open the Breakpoints Dialog. Right click on the breakpoint in question and choose Edit Description:
Adding a description
This is admittedly an over-simplified example (in my main project I have so many breakpoints accumulated over so many debugging sessions and I’m afraid to remove any of them. Don’t @ me.), but finding a specific breakpoint is now easy as!
Search through all breakpoints easily