The worst design formula I ever encountered was by courtesy of a group of interns, ten years ago. When given the problem statement, they proceeded to convert the top level business entity names into classes and the verbs into their methods. Needless to say, what came out of the exercise was an abomination: it looked beautifully elegant as a class diagram, but lacking any consideration of how the thing might work at implementation level, it (and the code it inspired) had to be thrown out with prejudice.
I have seen many such formulas over the intervening decade. They all had one thing in common: they were formulas. In that they substitute the hard work, i.e. the thinking, with a series of steps based on some theory (or worse yet, based on a collection of buzzwords masquerading as a theory). I myself have tried to come up with a few over the years. Not because I dislike thinking, but as I have come to realize, because I hate chaos.
A design technique, in my opinion, should not try to reduce the amount of thinking required. It should instead try to reduce the amount of chaos in the process so that the developer can do his thinking methodically. Here I outline a process that I have been using for the past four years. It has worked equally well with C++ (my mother tongue of ten years), PHP and especially JavaScript (my recently adopted second language).
Wednesday, July 16, 2014
Tuesday, July 15, 2014
Micro-disassembly of a DVD player
Armed with a Phillips screwdriver, a pair of tweezers and a 300x digital microscope, I decided to delve into the innards of this three year old Chinese-built DVD player. What follows are some of the interesting things I found inside. If you like, you can skip the regular teardown and go straight to the microdisassembly section at the bottom of this article.
The device
Step #1 - under the hood
The first look under the hood. I'm immediately out of my element: being a software engineer, no amount of the likes of me would traditionally be able to screw in a light bulb. Also, growing up in a family that wasn't exactly swimming in cash, we had to make all our purchases count. Taking something apart to satisfy my curiosity and not being able to put Humpty back together again was not an option for me as a child. And so I developed a hardware phobia. In fact, these teardowns are partly an attempt to cure myself of that fear.
But I do have something going for me: first principles and a good deal of reading. Let's see how far that gets me:
Right off the bat, I can see the drive (1), with a Russell Peters disc I need to liberate in the process of taking it apart. Everything connects to what is obviously the main board (3). Going by how they align with the various bits on the outside, I can identify: the surround sound outputs (2) coming in through it's own little board, as do the microphone/karaoke inputs (4). The USB slot gets its own little connection to the main board (5). Interestingly, the SD card slot seems to connect to a dedicated reader (7). The front panel connects to this (6) board, which I'm guessing houses the buttons, seven-segment displays and whatnot.
The device
The device: a run-of-the-mill DVD player with the usual bells and whistles. Cheap, Chinese and claimed irreparable by the friendly neighborhood repairman. |
Step #1 - under the hood
First look under the hood |
But I do have something going for me: first principles and a good deal of reading. Let's see how far that gets me:
Right off the bat, I can see the drive (1), with a Russell Peters disc I need to liberate in the process of taking it apart. Everything connects to what is obviously the main board (3). Going by how they align with the various bits on the outside, I can identify: the surround sound outputs (2) coming in through it's own little board, as do the microphone/karaoke inputs (4). The USB slot gets its own little connection to the main board (5). Interestingly, the SD card slot seems to connect to a dedicated reader (7). The front panel connects to this (6) board, which I'm guessing houses the buttons, seven-segment displays and whatnot.
Tuesday, June 3, 2014
Kickstarting science: crowdfunding as a cure for scientific research compromised by the pursuit of grant money
Sandia Labs |
Money is a scarce resource, so the unfortunate truth is that researchers are forced to spend time and effort competing for grant money — time and effort they could have spent on their work (by some estimates, researchers spend as much as three months a year writing grant proposals, most of which they don’t get). Not only do they have to compete with other researchers for a cut of the science budget, they also have to compete with all other budgets of the funding organization. Whether it is in government or industry, it is well known that when the budget ax falls during tough times, it usually falls on the science budget first. Science is a long term enterprise: for most people, it appears as a money sink with no near term benefit. And we live in a world that is increasingly near term oriented.
Sunday, June 1, 2014
Light field videography
Multi Camera Array, Stanford University |
Wednesday, May 28, 2014
On entropy and optimism
In a universe where entropy increases with time, one has no choice but to be an optimist. For in such a universe, the number of possible negative future outcomes (i.e. disorderly outcomes) will always exceed positive ones (i.e. orderly ones) by many orders of magnitude. Therefore, for animals like ourselves who can contemplate the future and be emotionally affected by what has not yet come to pass (and perhaps never will), an unbiased view of the future means a life of fear and worry.
Thursday, May 1, 2014
Why the Ukraine crisis may be a good thing for the US space industry
It was the cold war that fueled the space race of the mid twentieth century. As the cold war drew to a close in the early 1990's, so did the space race. We are now in a strange situation where America, once a space superpower, not only has no manned space vehicles, but for the first time in decades, does not even have a TV show set in space.
As of this writing, America is relying on Russian Soyuz craft to get their astronauts into space -- a state of affairs the baby boomer generation would find bizarre. Also as of this writing, a crisis is brewing in Ukraine -- crisis that might very well end with Russia annexing a good part of the former Soviet republic and provoking the United States and its allies into a response. The response may not be military, but it may be enough for Russia to close the doors of its cosmodromes to American astronauts. The Deputy Prime Minister of Russia implied just this when he recently suggested that America send its astronauts to the International Space Station by way of trampoline.
As of this writing, America is relying on Russian Soyuz craft to get their astronauts into space -- a state of affairs the baby boomer generation would find bizarre. Also as of this writing, a crisis is brewing in Ukraine -- crisis that might very well end with Russia annexing a good part of the former Soviet republic and provoking the United States and its allies into a response. The response may not be military, but it may be enough for Russia to close the doors of its cosmodromes to American astronauts. The Deputy Prime Minister of Russia implied just this when he recently suggested that America send its astronauts to the International Space Station by way of trampoline.
Wednesday, April 30, 2014
Top-down API design
Bjarne Stroustrup, the creator of C++, is believed to have said that programming in C++ involves writing libraries and then using them. Having worked with C++, Perl, PHP, Python and Javascript for the past ten years, I'm inclined to think the principle applies to more than one language. Especially the object oriented variety.
The idea makes sense. Large problems need to be broken down into building blocks. Then you must first build the building blocks before you use them to build the building. Build the building blocks wrong and the building comes out wrong.
How do you go about designing the building blocks? Based on your building's requirements, of course. Strangely though, in the world of computing, some programmers (including my past self) tend to forget this basic principle and try to stand the process on its head.
Friday, April 25, 2014
On social media and psychohistory
Every successful social network will eventually consider selling your data. The temptation is simply too strong. Contrary to what you might think, the true value of what's in Facebook's database is not in the personal information — in other words, it's not really about your name, face, address, friends, family, place of work, school etc. In fact, if you're a person who doesn't really mind Facebook (or even the government) knowing these details about you, I wouldn't really blame you. Well, at least not as much as some privacy advocates would. Because the real danger is elsewhere.
In his 1951 science fiction novel Foundation, Isaac Asimov envisioned a discipline called psychohistory — a sort of advanced statistical sociology that allowed its practitioners to make highly accurate predictions about large populations over long time spans. In psychohistory, individuals and everyday events don't matter — there is too much uncertainty at that scale to make meaningful predictions. But when taken as a large population over time, people begin to exhibit patterns. Hari Seldon, the fictional creator of psychohistory, uses the equations of psychohistory to predict the collapse of the galactic civilization, followed by 30,000 years of barbarism. He then devises a secret, millennia-long plan to prevent this catastrophy.
Psychohistory
In his 1951 science fiction novel Foundation, Isaac Asimov envisioned a discipline called psychohistory — a sort of advanced statistical sociology that allowed its practitioners to make highly accurate predictions about large populations over long time spans. In psychohistory, individuals and everyday events don't matter — there is too much uncertainty at that scale to make meaningful predictions. But when taken as a large population over time, people begin to exhibit patterns. Hari Seldon, the fictional creator of psychohistory, uses the equations of psychohistory to predict the collapse of the galactic civilization, followed by 30,000 years of barbarism. He then devises a secret, millennia-long plan to prevent this catastrophy.
Subscribe to:
Posts (Atom)