Sunday, 9 March 2025

How I Quit Smoking Using Software Development Principles

This is the story of how I quit smoking, for the second time in my life. The first time was back in 2012.  What happened was that I took stock of how much I was spending on cigarettes in a month. It amounted to SGD 300 and change. And I gave it to Mom, fed her some bullshit story about being promoted at work and this being my pay rise. I thought it was brilliant back then - I'd committed to giving her that money now, and couldn't take it back. And just like that, I stopped buying cigarettes, and smoking them.

Stubbing the habit out.

After a bit of a struggle in the first few months, I was clean. All this lasted a full year. And then I changed jobs. I was still a web developer, but now in a company with significantly more resources.

Guess how much more the new job paid me? Yep, about SGD 300 per month. Can't fight fate, amirite? Soon I was right back at smoking with a vengeance, and never stopped for the next twelve years. In fact, it got worse during COVID-19, when I was working from home. I was also smoking in the bathroom, kitchen and living room constantly. I was averaging a pack a day, sometimes more.

And now I was earning significantly more money, perhaps double. Back then, being a consistently broke web developer, I could use a lack of funds as a way to stop myself. Now, it was no longer feasible. One could say I was a victim of my own success.

Quitting for the second time

Fast forward to 2024. I had just moved house and the thought of smoking in an otherwise clean new apartment just felt wrong. Besides, I'd managed to stop smoking in the bedroom due to being married and all, I figured it was no big deal to expand the no-smoking zone to the entire apartment. Thus, I kept my cigarettes in the mailbox on the first floor. Every time I needed a smoke, I would take the elevator all the way down to the first floor. As I live on the twenty-fourth storey of my apartment block, you can imagine this got old pretty quickly.

It's unclear and what point I decided to work towards quitting smoking altogether so I could do away with this annoying hassle, but the plan to cut down was soon in motion. I restricted myself further; there should be no going downstairs just to smoke. If I was going downstairs, it had to be for some other reason, such as checking my mail, or training at the outdoor gym.

That was when I decided to see if I could recapture my vigorous youth. My chin-ups record stood at fifteen. I wanted to see if this aging body still had it to reach those heights. And, from experience, this would require muscular conditioning, which meant consistent training. And with what I had mandated with regard to smoking, this looked like an excellent opportunity to kill two birds with one stone.

As a software developer interested in Data Analytics, I even compiled some statistics beginning from the 4th of March. The point was to exercise enough discipline to compile those stats, and track progress.

A combo chart!

Soon, I was down to five sticks a day. And on the 19th of June, 2024, I smoked my final cigarette.

Strangely enough, psychologically, there was nothing to fight. One day I was a smoker, and then the next day, I simply wasn't. I even forgot all about trying to quit (other than faithfully filling in the data once daily) until my wife checked in to see how I was coping. The only time I felt any kind of craving was directly after a workout, and even then it was manageable.

I seem to remember the process of quitting being a lot tougher than this. Perhaps it was because I had turned smoking from a pleasure to a chore.

Aftereffects

Not needing to smoke has, given me a sense of freedom. No longer do I feel the need to stick to areas where smoking is allowed, or feel under-equipped if I leave home without cigarettes or a lighter. And while the Missus was agnostic to me being a non-smoker, she really grew to like having an extra SGD 500 in our joint account every month. (I know, cigarettes got so much more expensive in the past ten years. Crazy, right?)

Saving money.

The most obvious question, however, would be: how much healthier has this made me?

Sorry to disappoint, but it hasn't made me feel appreciably healthier. I assume I'm at lower risk of lung cancer and heart disease, but short of a thorough medical checkup, there's simply no way to tell.

I seemed to have put on almost 10 kilograms. Whereas before this I was weighing at a range between 69 to 72 kilos, now I was weighing between 77 to 82. Apparently, the regular nicotine intake had been doing a number on my heart rate; and now without it, my heart wasn't working quite as hard. Which is great, but I wasn't shedding excess weight as fast either. Good to know, I guess.

As for symptoms like fatigue, grumpiness and anxiety... I didn't notice anything. I mean, not more than usual. Insomnia? Not at all. Even with the Missus snoring like a cow beside me every night, I slept like a baby.

Applying software development principles

What I'd done here was programming. Not programming in the sense of me typing in commands into a computer that would then execute those commands faithfully, but programming nonetheless. Programming of the incremental, conditioning kind. Most programmers would have come across a warning from their IDEs at some point or other - Unreachable Code. Code that technically existed in the system, but due to the way the program was structured, would never be arrived at during an execution.

I had used my training as a software developer, and applied it. First, instead of outright stopping myself from smoking, I imposed restrictions around it. I could still smoke, but only if an increasing number of conditions were met. Thus, if I wanted to badly enough, I could jump through a lot of hoops. At some point, my natural laziness won out. Theoretically, I could still smoke if I wanted to, but the combination of conditions I would have to meet pretty much turned that into Unreachable Code.

Setting up roadblocks.

Another principle which I took advantage of, was that of optimization at the point of bottleneck. It's probably more a manufacturing principle than a software one, but still applicable nonetheless.

In any system, there exists one (or more) points where throughput is constrained, and the only way to increase throughput is to optimize at the bottleneck, not away from it. This means that we need to understand what the bottleneck is. In my case, I wanted to make smoking less easy, not more, so one might say I took the principle and inverted it for my purposes.

Why had I been smoking so much? Basically, because I could. There was an ashtray in almost every room in the house, and I had pretty much given myself permission to smoke wherever I wanted. It was convenient. Thus, if I wanted to make it less convenient to smoke, I had to impose restrictions. Barriers to doing so. As such, I identified the "bottleneck" (more like a leak, really), and fixed it.

Of course, I could have just told myself that smoking was bad for me and I should just stop. But telling that to a guy who already works out five days a week and survives largely on oatmeal, is ineffective.

Epilogue

It's been eight months, give or take, since I last smoked. Ostensibly, the lifestyle change should have been considered to take hold once past my second month, so I'm gonna take the win. Go, me!

Unfortunately, my little foray into chin-ups did not quite go as well. After I managed to hit ten chin-ups, my right elbow gave up on me. Golfer's Elbow, they call it. That's another story for another time.


Much tobacco-fuelled love,
T___T

Tuesday, 4 March 2025

Is Repeating The Password Field Really Necessary?

There is something that seems to be some kind of de facto standard where updating user passwords is concerned. And that is the practice of asking the user to enter in the password twice.

We'll need that
password again...

It's so much of a standard that whenever I create a for for users to edit their details (the password being among those details) I always have an extra field for the user to repeat the password, with the required validations. It's reflexive by now, and not once over the years have I ever thought to ask why.

Until now, that is.

That's a good question, though. Why this feature, and why not? Let's break it down.

Why this feature?

Well, for one, password entries tend to be masked. Therefore, users may misspell their initial choice of password. The Caps Lock key might have been on, or something. They keyboard might be jammed. Hey, not everyone can type stuff with 100% accuracy while blindfolded, OK?!

Typing while blindfolded.

Therefore, putting in a confirmation field helps ascertain that, yes, the user absolutely meant to key in "i_k1cK_@$$!556677".

The second reason I'm about to name, is a bit of a circular argument. As mentioned earlier, this UI pattern has been in use since... forever. Which means that users are comfortable with it by now. It's, despite its flaws, an established part of the process. People generally want to stick with established patterns instead of figuring new shit out.

I'm only including the reason above because legacy inertia is legitimate grounds where UI and UX are concerned. As a techie, I despise the argument that we should continue bad practices simply because it's the way we've always done things.

Why not?

There's a whole host of reasons not to do it.

While an extra confirmation field might help the user avoid typos, there's nothing stopping the user from copy-pasting passwords. This feature may also drive users to use overly simple passwords instead. Never underestimate the lengths users will go to, to make life easier for themselves. All of which make a system less secure, not more.

Copy-pasting.

An extra field adds overhead. Not only is there more data to input, there is more data validation to cover. We have to check that the field is not empty, matches the previously typed password, and so on. All in return for the dubious value of helping ensure users didn't mistype their chosen password.

And of course, from the user's point of view, one extra field, masked and with extra validations, is just more inconvenience. Although, in the case of security, anything that adds security almost always inconveniences the user to some degree.

All in all

What's the solution for this? There's no one single unified solution thus far. Some platforms prefer the tried-and-tested way. Other platforms prefer the visibility toggle on the password field so that users can see what they typed, if they so chose, with no extra field. With time, an eventual standard should emerge.

r3g@rd$!!12345,
T___T