Happy Canada Day!
Not actually being in Canada, I am not doing anything particularly
interesting to celebrate. I did have some excitement today, though.
More about that below.
Contrasts
A while ago, in April, I went to Hong Kong and China. China requires
visas for Canuck tourists so I went to the consulate here in NY. It
was a well-oiled machine. Go in. Take a number. Wait until it's called.
Give them passport and some money. Come back 3 hours later and collect
passport with visa. One of the most painless visa applications I had
ever experienced.
I also go to Russia from time to time for work. Their consulate and
visa application is roughly the exact opposite of China's. Generally
when you show up, you can expect to see a big throng of people
waiting outside on the street. There is only one door to get in to
the consulate, and it is locked.
From time to time, somebody inside comes and briefly unlocks the door,
usually to let some people out. When this happens, the crowd charges
at the door, screaming at each other madly in Russian while babies
cry and everyone gets crushed. The door slams shut again. Repeat
this about 5 times, until you get close enough to the door to yell
"VISA!" to the guy inside, at which point he will push people out of
your way so you can come in.
I do not know what the other people are waiting for generally (passport
renewals maybe?) but it is obviously a service much more popular
(or time consuming) than visa applications. Anyway, I thought this
was an interesting contrast in consular experiences. You can tell which
country is hosting the Summer Olympics this year :P
On System Design and Architecture
I don't by any means claim to be an expert in this area, but I have learned
at least two important things over the years.
- Work at the right level of abstraction
- If your "architecture" involves sprinkling "if" checks all over the place,
it is not an architecture, but a pile of hacks
The second one is pretty self-explanatory. You can tell if you're doing it
easily: do you have "if" checks all over the place to check some common thing
(eg. access control)? Then you fail.
The first one though is a bit harder. How do you find the "right" level of
abstraction? How do you know if you're working at that level? Finding the
right level of abstraction is often hard. I find the best way is to design
your API and actually write some prototype code before fully committing to
the design. Which brings me to the second question. You know you're working
at the right level of abstraction when two things are (at least mostly) true:
- You are not constantly fighting the API to get at lower-level primitives
(in OOP languages these often manifest as downcasts)
- You are not constantly writing little utility functions to do trivial
things that cannot be easily expressed in your API
Note that when in doubt, it is easier if you start off working at a lower
level of abstraction. After all adding an abstraction is easier than removing
one.