roytang.net Posts Photos Archives About

2016 December

  • In one of my most recent projects, a large system that had gone through a relatively long and unstable period of many, many changes due to sales demonstrations, different clients and whatnot, one of the "fun buffer tasks" I always kept around for devs was code cleanup. Because of the unstable nature of the project, there was always a lot of duplication, unused/unnecessary/obsolete classes/functions/files and so on. Unnecessarily large CSS files where most of the selectors were no longer really needed or JS libraries that weren't actually used. That kind of thing. It's one of those things that you'll never

    read more (290 words)

  • I traditionally try to save some time on the week between Christmas and New Year's Day to do some cleaning up and decluttering of my stuff. One would assume that having more time meant I would be better able to organize my stuff and all that, but one would be wrong. My room still has stacks of books, toys, Magic cards and other stuff in random places. Or maybe I just have too much OCD that I want everything to be neat and organized, but I'm not industrious enough to make it happen. I'm sure there are people a lot

    read more (358 words)

  • Related: Learning new skills While many people working as programmers/software developers are happy enough specializing in a single programming language or platform, I generally consider it a better idea to have a wider toolset and the ability to easily pick up new programming languages as needed. The benefits should be obvious: when you have a wide variety of tools under your belt and are able to quickly learn to use a new tool, the number of work options you have increases greatly. Happily, programming languages share a lot of similar constructs. Only your first programming language (when you first learn

    read more (581 words)

  • When Hanamichi Sakuragi from the manga Slam Dunk tries to get into the basketball club, he insists he's a genius who doesn't need to practice the basics and instead wants to go immediately to doing spectacular things like Slam Dunks. Sadly, the vast majority of us cannot claim to be geniuses at anything, and we are forced to undergo a bit of hard work if we want to learn a new skill. Malcolm Gladwell says one needs 10,000 hours of work at something to become proficient, but that probably only holds true if you're using those hours "smartly" and not

    read more (837 words)

  • In any reasonably large software project, the system will be so large that no one developer will have a good grasp of the details of every function in the codebase. The tendency is for developers to specialize -- that is, developers tend to focus only on certain parts of the codebase and become more familiar with that part, while not having much knowledge about the other parts. This tendency is self-reinforcing -- once it becomes known that the developer is an "expert" in the given module, there is a tendency that he will be assigned the most difficult and urgent

    read more (321 words)

  • I was in a meeting once with my boss (literally the CEO, a Malaysian) and some representatives of another company (Americans) where we were discussing the technical details of a possible future partnership. At one point, one of the Americans said to my boss that he was pleasantly surprised that I was openly speaking up independently of my boss and willing to correct him on some points when he didn't quite get the technical details right. It seems they were used to working with some Indian outsourcing firms, where due to cultural differences, the tendency was for the Indian guys

    read more (354 words)

  • In JavaScript, referencing variables that are declared outside of a function's scope can be tricky. If you have code like this: var btn = document.getElementById("BTN"); var test = 1; btn.onclick = function() { alert(test); } test = 2; The click handler above retains a reference to the test variable even though it falls out of scope as soon as the script block finishes execution. When you actually click the button, the alert will show the last value of the variable when the block finished execution (2) instead of the value at the time the function was initialized (1). I thought

    read more (361 words)

2016 November

  • If a friend found out your work was horrible, would you want to know? Or would your feelings be hurt? If your coworkers think you're doing something wrong, would you prefer that they keep quiet or that they call you out? As a leader, do you prefer to have sycophants who sing your praises or people who are willing to tell you that you have no clothes? Is your ego more important than doing a good job or self-improvement? But what if the guy is just being an asshole who hates me and wants to discredit me? Whether or not

    read more (191 words)

  • This is a story of something I consider to be one of my worst mistakes in software product development. Some years ago I was asked whether it was feasible to write software that would be integrated with Software X that allowed us to export that software's output into a format that was compatible with Standard Y. I took a look and after a while came back with "Well sure. We could use Programming Language M that has an API that lets us integrate into Software X so we can export the output data. Then we'll have to use Library N

    read more (368 words)

  • The series was a bit formulaic, and towards the end really preachy toward's the authors personal philosophies, but Terry Goodkind's Sword of Truth series always comes back to me because it codified one of life's most important truths: Wizard's First Rule: "People are stupid. They will believe a lie because they want to believe it's true, or because they are afraid it might be true." That doesn't mean you're stupid or I'm stupid, just that collectively, we're kind of dumb. Put another way by another wise character in popular culture, from the film Men in Black: Kay: A person is

    read more (326 words)

  • "Button for non-service floor does not light up." For more than a decade I regularly went to an office building where the elevators verbally spouted this nonsense message whenever you tried to go to a floor that the current elevator car did not service. For context, the elevators in the building were zoned programmatically -- this means that they only service a particular subset of the floors that are provided on the elevator panel itself. They sometimes disable the zoning depending on the loading among the elevator cars so simply removing the buttons for the unsupported floors isn't a viable

    read more (579 words)

  • Recent events both in my country and abroad, both of wide importance and personal importance, have made the past week or so difficult. Bad news and bad events have no master or timing, they do not consider giving us a break, they come and go as they please no matter how bad the situation already is. I fully understand why many people choose to withdraw from daily news or shut it out altogether or even just avoid social media completely. Hearing the bad news can be disheartening, and it comes at us even when there is work to be done

    read more (288 words)

  • There was this project we had where there was a strange bug. The developer working on it found that the problem only appears when the record ID was 12. When it was 11 or less, everything was fine. When it was 13 or more, everything was also fine. After some investigation, it was found that there was some code that executed with a condition of "if record id == 12", which was already a WTF. It turns out that some behavior had been hardcoded for a previous demo to a client and was never reverted and made it all the

    read more (278 words)