Offering you a business mentorship opportunity

Times are hard. Students are treading water in a deep pool of student loan debt. The unemployment rate is high. Those without jobs wonder how they’re going to feed themselves. Those with jobs wonder if they can keep their jobs.

While the financial markets have caused much trouble, occupying some prominent financial street isn’t enough. Protesting only means you’re surrendering the solution of the problem to someone else, waiting for that someone who may or may not be able to help you.

It is said that total sum of all small businesses drive the majority of all businesses in the world. I’m offering to teach you how to start a small (online) business of your own. I run a small business, and though it has a modest return, it feeds me. And in my book, that’s successful enough for me.

Here’s the deal

I’m not providing financial aid to you. But I will answer any question you have on starting your online business. If you have an idea on what you want, we can work on that. If not, we can work to find something you’d be interested in. I will point out reference material you can read up on. I will suggest actions for you to take. But I won’t do those things for you. You still have to work for it.

In exchange, you have to write articles and do some research stuff for me. 1 article per week, either for the blog, or for my magazine, or for my email newsletters. Add in the research, you’re probably looking at 2 to 6 hours per week, depending on how fast you write/research. If you’re currently studying, that shouldn’t put too much of a dent into your week. If you’re still employed, I can help you with a side business that brings in a little bit of cash per month. If you’re unemployed, well, the time taken shouldn’t bother you too much.

I’m also open to other types of contributions. Maybe you can create and edit videos. Maybe you’re awesome at taking photographs and photojournalism. Suggest away, and we can balance out the stuff I might ask you to do.

As for that business of yours, I won’t take a single cent. All profits from your business will be yours. You did all the work, right?

The time frame is 2 months. For now. We can extend if it works out. Most people will be winding down for the end of the year. You, on the other hand, can learn and create something that puts you in a better position for next year.

You think 2 months isn’t long enough? I created a profitable business selling a programming guide within 6 weeks. It took that long because I was writing code and creating a PDF that explains all that code. You can probably create something that you can sell profitably (even if modest) within a month.

If you don’t want to work, then even a year isn’t enough.

Also, I’m not going to teach you how to create the next Facebook/Twitter/Whatever. I’m here to teach you how to build a profitable business (as opposed to business for equity), and not something that’s valued at 3.7 million dollars after 3 years. I don’t have 3 years. I need to eat right now. I’m assuming you share similar feelings.

“Why are you doing this?”

I want to help you. If I was still studying for my bachelor’s degree, I’d at least be interested in someone offering to teach me how to start a small business. It would help with paying off my student loan, and I would have started before I graduated (when the student loan interest starts to kick in and I had to start paying back). If I was out in the world, whether employed or unemployed, a couple of hundred dollars per month would help. I grew up in a family between poor and middle-class. Every single dollar helps.

There are probably a lot of stuff I should clarify, but I don’t know how many people will respond to this. I might be helping 1 or 2 people. At the most 3. There might be no one who’s interested. That’s fine too. But if you’re interested, contact me and we can work out the details.

Responsibility culture

Clearly yesterday’s article struck a nerve. I usually have zero comments on my articles. But for yesterday’s article, I had 2 people commenting! That’s like an increase of 2/0 = infinity percent! Marketing and business people will kill for this kind of return.

I want to thank James Carman and William Saunders for their comments. I’ll return to their comments in a bit, with a bit more clarification about that story. But first, let me tell you another story.

“Don’t say sorry.”

“Vincent, I just want you to know something.” I felt my stomach twisting a little. “This can’t be good,” I thought. She spoke in barely a whisper, like she was afraid other people might overhear her, and I suck at phone conversations, so it’s doubly worse. “You shouldn’t say sorry to those people. It makes you look weak, and they will take advantage of you.”

Those aren’t the exact words, but the essence is there.

This happened like 3 or 4 years ago (I think). I was working as a Systems Analyst, but for expediency’s sake, just take it as I’m responsible for anything tech-related, unless otherwise stated. I work in a small team, as in like me and my supervisor. I mention this because my supervisor gave me a lot of autonomy on how I work. Basically, she just told me “Vincent, I need you to do this.”, or asked for input “Can we do this?”, or “How long would it take?”, and then just let me do my thing. Because she had her own stuff to do.

I know there are people out there who say that managers (or people in managerial positions, say a supervisor) of programmers should be protecting programmers from being disturbed (for lack of a better word). People like Joel Spolsky or Michael Lopp. I support this in general. It’s just that sometimes, the situation doesn’t quite allow that. My supervisor already shielded me from a number of (unnecessary) meetings (for me) and does most of the documentation (for the design, not the code).

So what usually happened was that whenever tech-related problems came up, they email my supervisor. Typically, it’s so technical that she would route that email to me. Eventually, the users learnt that I’m the ultimate person to solve their problems, so they skipped my supervisor. If the task in the email was too big or involved, I will let my supervisor know and let her decide if I should proceed. Otherwise I just solved the problem, sent an email to the user(s) and CC my supervisor (just so she knew about it).

Well, some problem cropped up. I can’t remember if it affected customers or internal users. Ok, it probably affected paying customers, otherwise it wouldn’t have been that big a deal. It might have involved customers in that million dollar deal thing I worked on. I don’t think it was entirely a mistake on my part, but I don’t think that’s important. I felt the important thing was to solve the problem, and then move on.

I solved the problem, and sent an email telling the people involved that the problem’s solved. I also apologised that the problem cropped up. I treat myself as a business working within a business (my employer). If your customer had a problem with your products or services, would you make it right and apologise? I would. It really doesn’t matter if it’s your fault or not. The customer typically doesn’t want to blame you specifically. The customer just wants the problem to be fixed. At least that’s what I’ve learnt from reading business and marketing books.

Apparently, one of the users was concerned for me (thank you!). She called me up personally, and advised me to not apologise. It might make me easier for other people to pin the blame on me (whenever technical problems crop up).

Anyway, I believed that if a program or application was under my care, then I’m responsible for it. It didn’t matter that the source code was written by someone else. It didn’t matter that I didn’t have full control over where the program resided, or what it did, or why it sometimes had problems. I took responsibility for it. I think I read Seth Godin write something on it. Maybe this one.

In our current economic situation, it’s ever easier to blame other people than to take responsibility. Taking responsibility means putting yourself on the line. It’s frightening. Which reminds me of another story. I was once in charge of a task force to find out “why people are afraid to speak up”. I’ll tell you that story another time.

The point is that the corporate culture (back then. I don’t know about now since I left the company) had an in-built blame culture based on fear. I was trying to spread a culture of responsibility, hopefully by being an example. With that, I return to the comments left by James and William.

On blame culture

If you skipped all the way down here, this is the story I told. James said,

Your story is a key example of why I am willing to take a pay cut, rather than work for a business like that.

First off, that company I worked for wasn’t too bad. The department I worked in had very little office politics (such as it was). Maybe it was that my team worked in a different location than headquarters. I typically go to the office with the feeling that I’m making a difference to my users. Even if I don’t directly contribute to the bottom line, I think of it as helping my users, who do contribute to the bottom line (the sales staff particularly).

That said, William had this to say,

That situation would make me want to quit. Large scale operational inefficiency goes way above/beyond people in our position, yet can sometimes directly impede us getting our jobs done. […] Really I think it should not be your concern how much the man-hours cost to get what you need done, especially since a whole team of people seemed to be fine with lobbing a bunch of blame your way.

The blame part happened because in the meeting, other departments were involved. Now that outsourcing project involved taking a bunch of the company’s work functions and bundling them together to be handled by the Cheng Du staff. Many other departments were involved. I got dragged along because the program I’m responsible for (see, see?) was involved (albeit a small part).

My supervisor was a nice person. It just so happened that she wasn’t around that day. My associate director and senior manager weren’t even involved in that program I’m in charge of. They might have gone along to the meeting just to see what the offshoring project was about, and my (program’s) involvement gave them an excuse to join (I don’t know about their intentions, so don’t quote me on this).

So when all eyes turned to me, I took the heat. I don’t remember feeling indignant about it. Just a kind of all-round-sucky feeling. I’m not saying this to protect my behind, or to not burn any bridges. My superiors were generally nice people. It just so happened that those people at the meeting wanted to point their blame cannon and fire at someone. I was the most dispensable. I was even the youngest at the meeting if I recall (have I mentioned my boyishly good looks? *smile*). Someone had to be responsible, and I decided stopping the blame game right then would move the meeting along the fastest. I even took notes on what I could do to improve the situation (that’s what the pen and notepad was for).

With regards to that $375 thing, it turns out to be some company policy. It’s an internal charges thing, and I charged at that rate too (or more specifically, my department charged that. Everyone charged at that rate). Even though opening up network ports and granting network access should be easily done (by a competent network administrator) within say, half an hour, the policy seemed to be that a minimum of 4 hours effort be charged. I’ve learnt to “bunch” up my requests when possible.

I’ve been “consulted” by my supervisor on how long a project would take. I’d give an estimate, say 5 days, and she would charge the department I’m to help. My department technically earned about 30 grand. I don’t get a single cent from that. It’s a “passing money from the right pocket to the left pocket” thing.

And yes, I’ve written such technical requests and viewed requests to my team/department before. That’s why I know the rates.

Dang, I should probably be a millionaire by now.

Outsourcing blame

The thing with outsourcing (or offshoring) is that on hindsight, it’s obvious that your business should’ve done it a long time ago. But when it was first introduced, no one really wanted to give it a shot. Why? Because it’s not safe. It’s not tested (by other people). It’s not well understood.

And then when it becomes well-established, you give it a go. Because if something goes wrong, it can’t be because of the outsourcing, it’s because the person/company you outsourced to didn’t deliver, or the person in charge of the outsourcing didn’t do a good job. Basically, it’s not your fault.

In the initial phase, you can blame the concept for not working. When it’s established, you can blame whoever’s implementing the concept for the concept not working.

The meeting where 20 people stared at me

I remember it was a dreary morning. I received an email “inviting” me to attend a meeting. My supervisor was away (I can’t remember if she’s on leave or simply at another meeting or otherwise off-site), so I was to attend the meeting on behalf of the team (which was a joke, since the team only consisted of my supervisor and me). Little did I know the meeting in that afternoon would soon turn drearier.

After lunch, I went back to my desk to finish up some coding. And was surprised that my associate director and my senior manager came down to my workplace (they work at headquarters). They were attending the meeting too.

So what’s the meeting about? To discuss how to move forward on a fairly big operation to be handled by the offshore team in China. I’m involved because one of those legacy programs I maintain was in that big operation. By proxy, my associate director and senior manager were involved (though not directly, since my department wasn’t really involved in that operation). Have I mentioned my supervisor wasn’t around?

Near the appointed time, I wrapped up my work, took a pen and notepad, and went to the meeting room. I arrived in the room, with a couple of people already there, and chose a seat that’s as inconspicuous as possible. Don’t choose the corner seats or seats right at the back. They’re at the extremes, and people notice extremes. I chose a seat that’s near the end of the meeting room table, but not at the end. Close enough to the action that people acknowledge you, but invisible enough that people don’t notice you unnecessarily.

Presently, the attendees arrived. My associate director and senior manager (henceforth referred to ADSM. Ok, that sounds weird… never mind) chose seats at the back. All in all, there were perhaps close to 20 people in that meeting.

The meeting proceeded wonderfully, with me casting a powerful magic veil of moderate genuine interest and blending successfully into the background. And then it happened.

[conversation made up, but the essence is there]
“So what is slowing down the project?”
“Oh, we’re waiting on [my legacy program] for the progress.”
([my legacy program] henceforth referred to as MLP)
“Who’s in charge of MLP?”

Oh cranberry.

“Uh, I am.”
20 pairs of eyes turned to look at me.

“Where’s [my supervisor]?”
“She’s on leave.”
(obviously, my boyishly good looks fooled no one that I’m actually in charge of anything)

My associate director and senior manager didn’t speak up. Good move. I don’t blame them. That was a big project, and the uppers really wanted that to move along and succeed.

“Why is MLP so slow? The people at Cheng Du are complaining that it’s so slow they can’t do their work.”
“And they have lots of problems logging into MLP.”

Oh cranberry.

I can’t remember what answer I gave, but it seemed to mollify the person. I’ll explain the technical difficulties in a bit. No one else came to my defense. Not the users of MLP (who had a representative there, but she also found MLP slow at times. *sigh*), not superiors of the users of MLP, and not my associate director and senior manager. The meeting continued, and apparently, everything was going smoothly. Other than MLP being the bottleneck. Schedules were displayed, training sessions to be coordinated, business reference materials to be created and sent to China. Etcetera, etcetera, etcetera.

The meeting concluded, and I breathed a sigh of relief. That was a good 3 hours (or so) of productive coding gone, with a dash of mild insult, condescension and blame sprinkled on top.

The technical difficulties

So let me talk a little about the technical difficulties, without giving away confidential information. First of all, MLP was a Windows program. The platform wasn’t really the problem. It’s that MLP wasn’t designed to be scalable. It was originally designed to be used only by a small number of people. Like maybe 2 or 3. Database connections became a battle of who logged in first. Seriously, I knew of users who logged in first thing in the morning, just in case they had to do something in the afternoon. I know, because of sp_who.

Which is also the second problem. The database administrators of MLP (I’m not pointing fingers, ok?) decided they couldn’t afford to buy the license to increase the capacity of the database. Which I agree. The cash cow of database companies? Not the database software. It’s the support, licensing and training. Just so you know.

Third problem was that it’s a Windows program. Ok, maybe the platform is a problem… MLP was an archaic program, written on an IDE that I’m not familiar with (and sometimes hairpullingly difficult to use), in a proprietary language, connecting to a database that’s tightly coupled with that proprietary language. Installing the program required me to fiddle with the Windows registry (never a good thing), and half a dozen steps (that I painstakingly came up with) that if done wrongly, meant the computer would explode. Or at least, that’s what it felt like to me.

Fourth problem (oh yes, there’s a fourth) was about restrictions. You see, MLP allowed the user to perform any action on a particular screen, once the person was authenticated. The big offshoring task required MLP to restrict the kinds of information available, depending on whether the user was based here in Singapore, or there in Cheng Du. Well, roughly, but the nuance is irrelevant for our purposes.

As an example, MLP allowed the user to enter information on customers. Information on confidential customers (such as government agencies or the Singapore military) were only accessible by Singapore users. That information was strictly off limits to Cheng Du users. This meant I had to go through every single SELECT query, every UPDATE/DELETE statement to make sure that only the correct user accessed the correct information. Those SQL statements were embedded everywhere throughout MLP. And at that point in time, I was the only one who knew how to use the IDE associated with MLP. I doubt anyone in the entire company knew how to use the IDE. People were having way more fun working with Microsoft’s SQL Server, or Oracle, or IBM’s DB2, together with ASP.NET or some modern technology.

Fifth problem (ohhohohoho yes, there’s a fifth) was about firewalls. I’m not talking about the Great China Firewall, but it might have had something to do with it. I’m talking about internal firewalls. The database server was located in Singapore, but the Cheng Du staff had to access it. Not through the Internet, but through internal firewalls. The Singapore side had to open up, the Cheng Du side had to open up, they had to open the right ports, they had to grant access (I learnt that I cost my department $375 in internal charges just to open up network ports and grant access).

All in all, I feel that particular offshore project was a big waste of my time. On the whole, the project might have made financial sense. But the cost of making it happen trickled down to me. I hope it’s worth it to the company.

Oh right, moral of the story. People tend to blame anyone except themselves. If someone blames you wrongly about something, be graceful about it. Don’t automatically defend yourself on the principle that it’s wrong. Choose your battles. I’m not saying it’s right. I’m saying it’s not easy.

Measuring happiness

How do you measure happiness? Is there an objective and quantitative way to know if a person falls within “acceptable happiness parameters”? My answer might sound like it comes from one of those self-help books. Or Zen philosophy. Meh.

So let me tell you the story of how this question came up. I was invited to attend a small gathering of, hmm, philosophically-inclined people (let’s leave it at that). I arrived before the appointed time, and met up with a couple of people. One of them said he was thinking of a way to measure happiness. Naturally, we asked how. On hindsight, I think the “why” is probably more important.

The happiness measurement experiment

The guy (henceforth referred to as the “proposer”) said he would attach equipment that measured a person’s brain waves, heart rate, or some such. I can’t remember the exact details. I think it involved EEG (electroencephalography). Basically, you measure and record the physical signals of a person (henceforth referred to as the “subject”).

The subject would also have to follow a prepared diet, so as to keep the physical input/output of the body consistent. This was when I asked what if the subject tired of the diet. The proposer said there could be slight variations of the diet so as not to bore the subject’s palate, say the weekend fare was different from the weekday fare. This immediately sent red flags to my (programmer/scientific/whatever) senses. But I smiled and gave mild encouragement, as did the other person at the table. I just met this proposer guy, so it’s not really up to me to say anything negative.

For the purposes of this discussion, we’ll say that for an experiment to have merit, the experiment must be repeatable with consistent results. First off, it will be ideal if you have full 24 hour monitoring on the subject, for at least a few weeks. Or a couple of months if your subject is female (I’m not discriminating on gender! I’m just aware of the hormonal changes in a woman’s body, ok?).

Second, the activities of the subject cannot vary. At all. There’s no practical way of determining if a particular activity triggered happiness or induced sadness, if the subject is allowed to do all sorts of activities without any kind of regularity. If the day starts with exercise, then reading, then some writing, then sleep, then that’s how it has to be every day. If you give some leeway on a weekday/weekend difference, then you need to have 2 sets of measurements. And that’s assuming all those activities are performed at exactly (or nearly exactly) the same time. Exercising at 6am, or at 10am, or at 4pm, or at 8pm feels very different.

Grocery shopping is dangerous. (There, I’ve said it)

Frankly speaking, even grocery shopping is dangerous. The subject may be buying some bread. But passing through the meat aisle to get to the bread section might feel very different from passing through the sweets section. Heck, what if the subject meets a close friend? What if the subject meets a hated individual? Small events might trigger a physical signal, but not considered important for consideration. How does one know if those small signals aren’t significant?

Have you had one of those days where you just feel happy? For no apparent reason. Maybe there was a nice breeze in the morning. Your coffee was done just right. That paperwork you dreaded didn’t seem so bad. You fixed a couple of difficult bugs. At dinner, you found out that the nice waitress was getting married (depending on your circumstances, this might sadden you, but whatever…). The book you’ve been reading ended with a flourishing finish. You feel satisfied with your day.

Small events matter. They build up. And you don’t know if there’s causality. And if you don’t, then your measurements aren’t as meaningful.

And then there’s diet… The proposer was very ready to adapt the diet. I’m not so sure. What you put into your body has a direct consequence to your well being, particularly if you know what you’re eating. Change the diet, and you don’t know which foods might have contributed to the happiness measurements (or whether it’s simply because there’s a change that the subject felt happy). Don’t change the diet, and you don’t know whether it’s because the subject got bored of eating the same foods.

Can you keep to a diet?

I have first-hand experience. To keep my living expenses low, I’ve kept my diet fairly consistent. Everyday, with a few rare fails. I came up with a diet that I’m happy (heh) with, and which is affordable. And then I eat those same foods everyday. Those bodybuilders and people who successfully lose weight? They do the same thing. They come up with a diet they’re comfortable with, and they stick to it.

Just to give you an idea, my breakfast is cereal with milk. The brand of the cereal, or the type of cereal might change, but it’s usually cereal. My dinner, for the most of 1 year (as of this writing), had been 4 to 6 (depending on how hungry I was) slices of bread and peanut butter (or occasionally some other bread spreads). Lunch was up for grabs, but I usually eat noodles in soup.

I will tell you something right now. I could distinctly feel my body changing. Heck, I’m not afraid to tell you this. I, uh, smell different. Sometimes, I even feel I’m oozing oil through my pores. I think that’s to do with the (almost) daily consumption of peanut butter. It’s why I’ve, uh, modified the bread spreads, going so far as to even eat something more wholesome, like rice with some meat and vegetables. Ah, the things you do to keep your business costs low…

So yeah, the proposer didn’t even have the discipline to keep to any kind of schedule for the subject. And frankly speaking, the only way to get extremely good consistent results that are meaningful, will be to keep the subject in a prison-like environment. Everything should be as regularly followed as possible, such as activities and diet. Only then can you say with a certain amount of confidence that, yes, that 5 minutes of meditation had a measurable effect, since that was the only day when the subject meditated (and the 2 days before and after had no measurable signals of happiness).

The biggest problem with human experimentation

Even if you managed to keep all the variables consistent, and find a willing participant to follow along, there’s one huge enemy. Boredom.

Hey, I’m quite indifferent to food. As long as it’s fairly palatable, I only care that it’s nutritious. I can eat that regularly, everyday if need be. During my primary school days (for a couple of years), my dinner was practically always barbequed pork rice (or char siew fan, if you understand Cantonese). I guess my indifference to food started then.

Even so, I have my limits, it seems. A steady dinner diet of just bread and peanut butter wore me down. (And I’m also getting tired of people telling me how thin I look. Apparently, my face has thinned, my eyes have sunken in, and my bicep muscles have slightly wasted away, rendering the years of my weights training moot. I’m eating, ok, I’m eating! Sheesh…)

We are humans. The complexity of our minds is too great to fully comprehend, let alone the connection of the mind with the body. How do you really measure happiness? How do you find out which variables affect your mood?

There are too many things to consider. Your particular circumstance. Your education. Your group of friends. The time period when you’re living in (people living 100 years ago probably feel happy just to have bread to eat, while you’re only happy if you get to eat steak #firstworldproblems).

So my answer, after you’ve read all that, is this: The criteria for your happiness is determined by you. Don’t let other people determine what criteria you should meet before you can feel happy.

Big numbers are not scary

Because they’re still numbers. You’re scared of them because you’re not used to seeing them on a regular basis.

The recent announcement of the US public debt being in the neighbourhood of 14+ trillion had caused some waves. You can relate with 0 to 20 easily. You can count reasonably well to 100. You might even be fairly good at handling numbers of up to 10 grand.

But a trillion? Your hands start to sweat.

People’s reaction to numbers seem to increase with the magnitude of the numbers, particularly if there’s a dollar, pound or yen sign attached to it (or any other monetary sign).

Well, the numbers are just going to grow. The earth’s population is going to grow. From what I understand, debt (not just that of US) will continue to grow (it has to, to keep the economy growing. It has to do with international borrowing or some such. Hey, I’m not an economist). The size of your computer’s storage capacity will grow.

So deal with it.

When I heard about the US public debt amount, I was only mildly surprised. I think it has to do with my exposure to numbers. And not just because I have a background in maths. Look, my first job had me looking at data that are 7 or 8 figures. And they’re of debt. I got quickly blasé about millions of dollars (of debt no less) within a month or two.

Then somewhere down the line, I was associated with a million dollar deal, of which I was tasked to create a website for a customer. And the crux of the deal seemed to hinge somewhat on my website. I had to design the website’s look (Ha! Me! Web designer!), craft a good login system, write it for security (because the website’s public), deal with SSL certificates, map the public web URL and the private subdomain IP address (oh networking stuff!), make it look somewhat like the competitor’s (because the sales team convinced the customer to switch providers), design the backend database, write the programs that will feed the database all of the transactional data (and plan the schedules for running the programs). Basically, almost everything technical, that’s me.

Oh and I had to do it within 1 month (it was the holiday December season too). Because that’s how long the sales team gave me for when the customer wanted it done. And I did it, even as I managed to handle tasks given to me by my ex-manager (long story) as well as my own tasks. And I still managed to do tech support. “The network is not working.” I went and checked, and plugged out the LAN cable, blew off any dust, plugged it back in, and the network’s back on. I’m not kidding.

Where was I?

That million dollar contract website also had to handle millions of satellite call transaction data. You see a million here, a million there, and suddenly big numbers aren’t so scary.

Then there’s the fact that my salesperson brother tells me stories about his work and customers. His company has a VIP pass that you can have only if you spent more than 600 grand a year. This means you’ll probably have spent upwards of, if not more than, a million dollars a year at the store. My brother has a personal sales target of over a million dollars a year.

My point isn’t to be insensitive to big numbers, even financial ones. The point is to not be scared of them. Fear is crystallised when you can find words to describe it. It’s even worse when fear can be numerically measured.

As my maths professor once said, “Keep cool and calm” on the subject of solving a nasty problem. “Then just do it.”

Trying To Fly

This was a demo I wrote way back in 2004. It runs against the .NET Framework (version 1.1 back then). Wow, it’s been a while…

In the demo, I tell a story of a wooden cuckoo bird trying to fly. All the shapes were rendered using primitives such as spheres, cuboids and 2D planes. Textures were generated using a 3D renderer (Bryce 4). The sounds were downloaded from 3D Cafe, and were listed on the “free” page. While I can’t remember the exact licensing (which wasn’t a big deal back in 2004), I went to the Wayback Machine and checked. There were no licensing terms, either to credit the individual or 3D Cafe.

You can download the demo here.

I wrote a 3D engine called Visionary for my own purposes, which was used to render the demo. It generates 3D primitives (spheres, planes, cuboids) with or without texture mapping. The engine also had support to play sound and music. And I lost the source code to it. The DLL is Visionary.dll, so if you have a good .NET decompiler, I give you permission to use it. I’d appreciate it if you could also send me a copy.

Note that some of the sounds will be loud. Take care of your ears. I tried to edit the sound files, but apparently they were so old that I can’t edit them with Audacity. I can only play them. Maybe I missed something…

DefinedNames in Cells for Open XML spreadsheets

So a while back, a customer of mine asked me if I knew how to set names (or labels) to cells in a spreadsheet, so that a cell formula just referenced those names. Frankly, I didn’t even know I could do that. I’m not an Excel wizard, as you can tell.

In case you’re in a hurry, here’s the code and the resulting Excel spreadsheet. The code runs against the Open XML SDK.

To my surprise, the name given to the spreadsheet cell isn’t defined at the Cell class level. You’d think you would name your child and make sure to slap a name tag on your progeny just so everyone knows what to call your offspring, right? After looking through the documentation, and thinking it through, I guess it makes sense to separate it. It works by having a central depository with all the available names, contained within DefinedNames and DefinedName classes. Then the names are available throughout the spreadsheet’s workbook.

It’s sort of like the SharedStringTable, where every piece of text is stored in a SharedStringItem, and referenced with an index. This has problems, in that I don’t know what is contained in the Cell class itself, but I don’t really want to go there right now…

Let’s go through the code a bit. Here’s the part where you define DefinedName(s):

defname = new DefinedName();
defname.Name = "PrimeNum1";
defname.Text = "Sheet1!$C$2";

defname = new DefinedName();
defname.Name = "PrimeNum2";
defname.Text = "Sheet1!$C$3";

defname = new DefinedName();
defname.Name = "PrimeNum3";
defname.Text = "Sheet1!$C$4";

defname = new DefinedName();
defname.Name = "PrimeNum4";
defname.Text = "Sheet1!$C$5";

In case you’re unfamiliar with Excel, “Sheet1!$C$5” means the cell C5 of the sheet named “Sheet1”. The dollar sign acts as a separator, I think. In this case, the relevant cells are C2, C3, C4 and C5 (containing the 1st, 2nd, 3rd and 4th prime numbers). And then we have this part:

r = new Row();
r.RowIndex = 6;
c = new Cell();
c.CellReference = "B6";
c.DataType = CellValues.String;
c.CellValue = new CellValue("SUM");
c = new Cell();
c.CellReference = "C6";
c.CellFormula = new CellFormula("SUM(PrimeNum1, PrimeNum2, PrimeNum3, PrimeNum4)");
c.CellValue = new CellValue("17");

Note this particular line:

c.CellFormula = new CellFormula("SUM(PrimeNum1, PrimeNum2, PrimeNum3, PrimeNum4)");

That’s our defined names in effect. Otherwise, we would use this:

c.CellFormula = new CellFormula("SUM(C2, C3, C4, C5)");
// or even
// c.CellFormula = new CellFormula("SUM(C2:C5)");

I teach you more about the CellFormula class, as well as a whole bunch of Open XML concepts in my programming guide.

The Dragon Bubble

I’ve been, uh, flipping through some books lately. As far as I understand it, they were written by economists, financial analysts and political journalists. And there was this general idea of the seemingly unstoppable growth of China crashing down.

Look, I’m just a mathematician and programmer. I don’t know much about statistics, or demographic studies, or sociology, or economics, or global financial analysis. I just pick up a book that looks interesting and start reading, ok?

UPDATE: Here are some of the books I, uh, flipped:

Here’s the gist of what I understood:

  • China’s massive growth hinges a lot on manufacturing and building real estate (commercial buildings, factories).
  • Manufacturing and building new buildings need lots of raw materials.
  • Countries providing steel, copper and other raw materials are riding on China’s growth.
  • China’s manufacturing and building works on the assumption that the infrastructure is needed for future expansion.
  • China doesn’t have a big enough domestic consumption for that infrastructure.
  • The recent global financial crisis has stunted, if not removed, other countries’ enthusiasm for overseas investment (say in China).
  • China is set to become the world’s largest manufacturer of things.
  • A monopoly of China being the largest manufacturer may not be in the interests of everyone. I’ve read of toxic plastic toys, deadly baby milk formula powders, and suicidal iPhone factory workers.
  • We may be following “Be liberal in our input, but be stringent in our output”, but China’s not. See China’s Internet censorship laws.
  • China is set to consume lots of energy, as her people get lifted from poverty. The “getting out of poverty” thing is good. It’s just that the world isn’t ready with more energy. It sounds unfair, as there are arguments that 1st World countries (in particular, America) enjoyed unbridled (and rampant) use of energy (coal, oil), yet other countries can’t (when it’s their “turn”). We need those alternative and affordable sources of energy, like yesterday.
  • China has bought (as well as other countries) lots of America’s debt, mainly in the form of Treasury bonds.

Please note that this isn’t a China bashing. And note that those authors are American (I think). They weren’t “attacking” China, so much as pointing out probable situations.

So as far as I understand it, China’s growth is fueled primarily by outside investors. It’s domestic consumption is marginal. Jobs are outsourced to China because it’s cheaper there. Manufacturing is done in China because it’s cheaper there, what with the infrastructure the Chinese government had encouraged into place, and the influx of raw materials due to other favourable conditions (such as being cheaper there. Have I mentioned that?).

Here’s a possible situation. America is arrested by her (unimaginably high and increasing) debt crisis, and curbs her consumerist behaviour with less imports (not just from China). Europe has her own debt crisis to deal with. Globally, everyone is affected, because (that I’ve read) 25% of the global economy is due to the exchange of US dollar. China starts to see less investments in manufacturing and building. Australia doesn’t have a strong demand from China for copper, and starts looking somewhere else to invest in. Whatever it is, China’s growth slows and eventually bursts.

Thus the Dragon Bubble.

So who rises? Apparently India and Russia. India, because her measures to lift her people out of poverty are somewhat more stable. People get educated, and get jobs (Is your call centre based in India? Is your development work augmented by, if not outsourced entirely to, Indian developers?). But India still has her old caste system firmly in place, and it will take some time for the growth to spread. But India also has a population just as large as China. And she speaks English.

And learn Mandarin (or Chinese)!. Just in case the Dragon manages to burst through its bubble and has claws in every country in the world. If you can’t speak the tongue of the Dragon, you can’t understand and talk with the Dragon. I’m fine, since I’m bilingual in English and Chinese (as well as C# and VB.NET *smile*).

What about Russia? It turns out that the reason is due to Russia’s possession of oil (lands). Western Siberia, I believe. Hey, I just flip through interesting-looking books.

A couple of definitions to continue with a more light-hearted story. Offshoring is when your company has an office in another country, and your company tasks that office with work. That office is still under your company, perhaps as a wholly owned subsidiary. Outsourcing is when your company tasks an outside company with work. The outside company is involved with your company only so far as being paid is concerned.

Let me tell you a short story. In a previous employment, I had to work with an offshore office in China. That offshore office belonged to a wholly owned subsidiary of my employer, and the subsidiary specialised in IT work. The point was that it’s cheaper for the Chinese there to do certain work than hiring, say, me to do it.

In hindsight, my previous employer entered the offshore/outsource game late. The balance sheet looked great in the short term, but as time went by, and difficulties in coordinating development work increased, the cost savings started to be less prominent.

Hey I understand what you may be going through, or seeing around you. Jobs flying out of your country to “cheaper” countries such as China, India and Philippines. So to make the process easier for you, understand this: If a task can be systematised such that anyone can do it, that task will be systematised so that anyone can do it. If your job consists of checklists doable by paying someone else cheaper, you don’t have that job anymore. Worse, if a task can be automated by computer software, consider it gone.

The offshore team assigned to my team was great. The programmers there did well, once you explained the business requirements and the programming requirements enough to them. But I felt my colleagues here (in Singapore) can explain things too far. One of them went so far as to write the actual SQL statement for use in the code. I felt that was unduly unnecessary.

The more interesting part of the story happened to a colleague’s team. There was a Chinese candidate slated for work in a week’s time. The candidate was a fresh graduate and was hired and assigned to my colleague’s team. The offshore office even sent the candidate’s resume to us. We spent about half an hour marvelling and commenting at the resume written in Chinese, because we’ve never seen one not in English.

One day before the candidate was to report for work, my colleague received notice from the offshore office that the candidate had quit. What? The candidate quit before even starting work? Apparently, a particular university had accepted the candidate, and the candidate decided to pursue a Master’s degree. I don’t know whether to laugh or be outraged.

I intended to write this as a pithy Seth Godin-like post, but apparently I failed. Utterly. I decided not to redact what I’ve written.

Multi-use variables or multiple variables?

So I’ve been working on a software project of mine. I’ll tell you more about it soon enough, but for now, it’s enough to say that I’m writing source code that generates source code.

One thing I’ve noticed is variable declaration. There are 2 extremes.

One variable used multiple times

This is the memory-efficient version. If you need the use of an integer variable, you just declare one variable. For example,

int i;
i = DoSomething() + DoSomethingElse();
i = DoThis() + DoThat();

That’s just for illustrative purposes. If you’ve written a fair amount of code, I’m sure you can think of better examples. Which are probably (and usually) more elaborate and lengthier.

The drawback to this is that the variable is temporary. As the code continues its execution, previous values stored in that variable are considered to be unimportant to future executions. That’s why the value can be discarded and the variable overwritten.

Multiple variables but one-off use

Then there’s the “declare as many variables as you can (or think you need)” method. For example,

int i1 = DoSomething();
int i2 = DoSomethingElse();
int i3 = DoThis();
int i4 = DoThat();

This has the advantage of keeping the variable values “alive” through that section of code. The drawback is that you use more memory, even if seemingly trivial. I mean, that’s like 12 more bytes of memory (assuming integers still take up 32 bits when you’re reading this). That hardly makes a dent in the computer’s memory space.

The hybrid

The above 2 are extreme cases. What happens when you write code is probably a hybrid, somewhere in between the 2 extremes. For example,

int iSubtotal;
int iTotal;
iSubtotal = DoSomething();
iTotal += iSubtotal;
iSubtotal = DoThis() + DoThat();
iTotal += iSubtotal;

You know what you declared those variables for, so you have an idea how many “unique” variables you need. This have the benefits of using the least number of variables (sort of), balanced with keeping the least number of “live” variable values around.

So why am I talking about this?

Auto-generated source code cannot generate hybrids

When you’re writing code, you have one very important advantage: You have context. A program that generates source code, such as a decompiler, does not have that.

When you’re writing code, you make variable decisions such as naming, naming conventions, how many you need and so on.

A decompiler has difficulty making decisions like those, so it has to choose one of the extremes. Typically the multiple variables route, because that’s the safest. All a decompiler can do is detect that a variable is needed, and so writes out the variable declaration in the resulting source code. It cannot decide on whether this part of the code can reuse one of the variables it has already declared (or at least has difficulty doing so).

Ok, so the cat’s out of the bag. I’m writing a decompiler. That’s not exactly true but will suffice for now (I promise I’ll tell you more soon!).

Anyway, that’s what I discovered while working on my software project. I have decided to go the multi-use variable route, because of a human (and programmer) behaviour. A human programmer has difficulty holding on to many separate variables in his head.

When a section of code requires many variables, I tend to try to limit the number of variables I remember in my head. Maybe there’s a pattern. I might remember there’s fFinancialYear1 up to fFinancialYear7. I might decide to refactor the code such that I only need one fFinancialYear floating point variable (assuming the appended numeral makes sense, and not just laziness in naming). I might separate the code section into several sections, so each section has a limited number of variables.

Maybe that’s not how most programmers work, but I find it “friendlier” than having thisIsAnAwesomeClass1 through thisIsAnAwesomeClass20, and I can’t remember which awesome class does which. I tend to work with tighter variable names (where possible and logical), and write code that’s as tight in scope as possible. So the variable values can be discarded, which means I don’t have to keep track of whether that value is still needed, even if the computer doesn’t mind having to keep track of it.

So how do you write your code where variables are concerned?

Singularity Magazine October 2011

Singularity Magazine October 2011 issue

Download the October issue now (3 MB).

In this issue, you learn about mooncakes, ebooks and personal growth. The latter two were topics from the BarCampSG7 event I attended.


I will be taking a short break from publishing Singularity for 2 issues. This means there won’t be November 2011 and December 2011 issues. The reason is that I’m working on a software project (see update video), and coding is taking up 95% of my brain computing power (when idle). So I made the painful decision of just concentrating on the software project first.

The magazine will return for the January 2012 issue. You’re a wonderful reader.

You can also keep in touch on the Facebook page, or just watch my videos on YouTube. Short updates and videos are ad-hoc and one-off, so they’re still doable (with my 5% leftover brain power. Wait, how is my body still functioning?). Full formally published PDF magazine issues aren’t.

Subscribe to the magazine for free here.