Categories
Rants

Howto Help the Economy

A bit of locally flavoured South African non-technical posting… on how to help an economy in need.

Indeed, when the chips are down, and prices are going up, and the economy is under threat of recession; what’s the most tactful move you can make? Why, organise a mass-action protest stayaway that effectively costs businesses billions of rands- just to put the cherry on top. Maybe put one or two out of action while you’re at- slam the final nail into the coffin? Oh, and don’t forget to cripple transportation and emergency services- hold the country at ransom during an economic crisis. What a sure fire way to send out a great message. At least you’re guaranteed of getting some attention.

Exactly what the message is however, and to whom it’s addressed to remains a mystery. ‘Cos the ubiquitous “business” and government of South Africa sure aren’t responsible for the price of barrel of oil.

Sadly, true character will always be revealed during the trials. But I suppose the alternative was to organise a call to come together and find innovative ways to save and help each other… Mmmm…

With great power, right, comes…?

Categories
Technology

Snippets

How often you store code snippets, only to lose them again? Often enough (or maybe you aren’t writing that much code). There are plenty useful routines out there, already written, some you could probably rewrite in your sleep without looking them up and probably aren’t worth saving. Others are gems that need to be published for posterity- not for yourself, but more importantly for somebody else struggling with the problem/language for the first time.

So after much delay, besides posting snippets here in this blog, i’ve taken to posting some around. There’s also an interesting angle wrt copyright and code ownership which can be completely circumvented (thus ensuring the longevity of tried and trusted routines) if you publish your snippet in the public domain.

Strictly speaking, depending on the kind of labour contract you’re engaged in, whoever pays you, pays you for your time plus the product of your time, and by implication, with intent and legal claim to that code routine. A highly contentious topic if there ever was but a difficult one to implement or monitor.

Nonetheless, with certain freedoms in place, you can strike a happy balance between ensuring your client gets full copyright and ownership of code particular to their domain, while you remain free to reuse that general routine in another (unrelated or not) project with a clear conscience: public domain. Of course, again technically speaking, you need to decide who pays for the time on that routine, and it should be you unless there is a transparent agreement from your client. Yours to work out or not.

Other than that, just a general shout-out big THANK YOU to everyone who does post code snippets- it’s helped me huge in my career; hoping to pay it back to others somehow. And a general encouragement to everyone else… get pasting.

Categories
Business Rants Technology

PAYE

UPDATE: 3 July 2008
Updated code to reflect more recent tax tables (2009)

When I was asked to estimate PAYE on a gross monthly salary, i hauled out the calculator and started chipping away, according to the SARS Tax Tables. Not being a tax consultant or looking at various structured packages, the first stab is mostly always a straightforward estimate without investigating further deductions. While doing this, the math-programmer inside me went… “Mmmm. Calculator. Boring. Ruby. Smile”

Turns out, it’s a simple little script; a useful little snippet and, bonus, i migrated some more learning onto Ruby. An aside; there’s definitely something about the difference in speed and endurance of learning between my brain versus my hands. You know the feeling. You can forget a password mentally, but let your fingers do the talking… And utilising muscle memory as an aid is just one of the many senses you can draw on…

Back to the snippet. Not too much interesting going on in terms of code. I chose a multidimensional array for storing the tax table. First used a hash, found it was overkill, reverted. Also did a classic switch in the beginning, to determine which “bracket” your pay falls into, but then figured a straightforward loop works just as well. This was an interesting break in habits from C# however.

In C#, looping through an array would be: for(int ii=0;ii<array.length-1;ii++)
I did the same in Ruby, transliterated the code, first time round: for ii in 0..array.length-1
But then, the knowledge of the “times” method changed my thinking completely: 6.times { |ii| … }
There are, afterall, one of 6 tax brackets you are likely to fall in (for all positive salaries)

And that’s where it hit me: the uncomfortable (more about that later) shift away from a corporate-sponsored, statically typed, IDE-integrated, certificate-oriented, compilable(?) programming language into a community-driven, dynamic scripting language is underpinned by these sudden ferocious rushes of freedom. Too much freedom? Certainly, too much to what i’m accustomed to sometimes.

Why’s that uncomfortable? Well, MSDN, VS, MS communities and the framework tell you how to code- to a large extent. They dictate the patterns, the constructs, the idioms; in short, they impose a very definite way of doing things. And it’s a big abstraction layer, forever changing (but not really) and giving you tons of resources to make your coding easier. This is good. Books, online help, built-in help, IDEs, intellisense… and more of all the good stuff. Don’t get me wrong, these things made me very productive and i’m grateful for that. But then you break away from that.

You gotta search for help (no nicely packaged MSDN DVD delivered to your door). You gotta scratch under the hood. You have to engage with community blogs and real people in a virtual world. You are forced to read opinions. You are stripped to the only the most simple of tools- a plain text editor. On a coding level, you are forced to remember namespaces, method names, variable names, libraries… no more intellisense to rely on. And this is where it was difficult. No more crutches to help me be more productive. I had to start thinking- for real now- and remembering stuff. And then i got scared: what if the “community” changed something and i didn’t know about it- or worse, didn’t agree with it? And I didn’t get an email with an updated change delivered to me automatically via updates or DVD? Hang on! Is that really the way it’s supposed to be? Have i become that lazy? Oops.

And all i was doing was having some fun, writing a little script to calculate PAYE so that next time someone asks me, i save myself a little more time.

Btw, the Source Code is here, if you’re interested.

Categories
Technology

Mac

Finally. It has arrived. After some time of deliberating, this once MS-only geek, turned and ran for the cover of open source operating systems; but not happy to just stay there, went one step further and has now immersed himself into the world of Mac 🙂

Afterall, i was tired of hearing the debates all the time; and to a large extent, i couldn’t really care which OS is best, since “best” is a loaded term and sparks off quasi-religious wars amongst the zealots; so i decided to live my opinions out, if i had any. And i definitely have some now.

My early comments can be summed in one thought which continuously bumps against the inside of my skull as i discover some new joy lurking under the hood of UI: “how on earth did i ever compute without a mac?”

Categories
Rants Technology

Clamour of Petty Kings

We have some serious issues facing our world today. Heck, in South Africa, the land of opportunity, we have more serious issues than we sometimes care to face up to. Tackling real issues is hard work. So, what’s the alternative?

Stop the press! Houston, we have a problem! In fact, call Heather Brenner out of retirement! Google does not display a link to it’s privacy statement on the home page. God forbid!

Something so serious demanded the attention of the world media (and my blog :sigh:), along with a host of, ahem, clamour, of petty kings. Good thing they were watching because if Google manage to continue getting away this kind of arrogant in-your-face lawlessness, who knows what cheecky and utterly ludicrious cheap shot they might plan to get away with next? :p

Categories
Business Technology

Ding

That’s roughly equivalent to the sound of the resonating chord which struck me this morning.

But today’s revolutionaries are sheep in wolves’ clothing. They’re lost in the economically meaningless, in the utterly trivial, in the strategically banal: mostly, they’re cutting deals with one another to…try and sell more ads. That is, when they’re not too busy partying.

Oh, if it weren’t so true. The rest of the article, is soul-searching and uncomfortably challenging because it has that “truth bites” edge to it. It’s also filled with quotable quotes, not for the purpose of quoting, but for serving as reminders when you get enough chance to breathe and realize exactly what it is you are doing.

That is to say, it serves, at the bare minimum, as a reality control against going too far in one direction; but only if it failed to catalyze something deeper within you.

Categories
Business Technology

Investing in the Learning Curve

We have a concept of what the learning curve represents, and unfortunately, the same thing can represent 2 opposite concepts. What makes more sense to me is looking at a learning curve from a classical labour cost perspective and more keenly towards labour productivity. In this sense, the learning curve is interpreted, broadly, as: the more you work with something, the more productive (cheaper, better, faster, more knowledgeable) you become. And one can recognise that sentiment when it’s expressed variously with respect to success, specialization, expertise, productivity, quality or minimizing costs. So where’s the investment?

Programming technology changes rapidly, and sometimes to the detriment of programming and business, sometimes not, but also to the advantage of progress and for the sake of technology itself. But changes are also forced to be incremental in order to be successfully adopted, since any radical departure will result in a prohibitively expensive learning curve where the economic costs outweigh the advantages of the change. Similarly, you also cannot force change too frequently, even if it’s small enough, since you never get to break even or realise a profit from the previous change. I think this last point might also be reflected in the current developer attitudes towards the “next big Microsoft thing” and the ubiquitous jading of old hats. Everyone seems to hanging five for a bit before moving forward. Or maybe Douglas Adam’s theory is kicking in?

At the same time though, you need to keep moving forward. So where do you invest your next generation of development so as to minimize the costs of the learning curve if you want to remain marketable and competitive across:
* web development
* mobile application development
* backend systems
* any platform (platform agnostic)

C++, C, C#, VB, Perl, PHP, Python, Ruby… ?

All these languages have their pro’s and con’s and more importantly, costs. As an example, I recently looked at Symbian C++ development, and the learning curve is relatively expensive. The idioms alone take time to get to grips with, so although you got a very powerful API, C++ on Windows desktop, or legacy ATL knowledge is not easily transferrable to a Symbian C++ development effort. Possible, but no as easy as say, being able to use a standard framework and language, with the same idioms, on both (all) platforms. That would be the ultimate prize (for me).

And it doesn’t have to be the same language. Case in point, i’m currently using Monorail (.NET web development) and RoR (other web development) concurrently on different projects and i’m enjoying the benefit of being able to work in a predictable (hence productive) manner switching between the two, relatively seamlessly. Whereas, switching between asp.net webform development and RoR, as an example would not be feasible. The traditional 30% context switch overhead would double.

So if you’re faced with “what to learn next”, take a closer look at the learning curve and where you can (need to) apply that knowledge in the future, in order to remain competitive- whether globally, or within your own department. Maybe it’s stating the obvious, but it’s surprising just how un-obvious the obvious can become when there are a lot of flashing lights going off all the time. So it’s not always about the language or the technology, but also a lot about the “way” in which things are done; which, by nature, is usually a little more sublime to spot since it’s hiding in plain sight 😉

Categories
Technology

Attitude Driven Development

A.D.D. From the textbooks of an introduction into the business world (Department of Decision Sciences, UNISA):

Control does not, however, keep workers from making mistakes. The motivation of workers and a positive attitude towards their tasks, limit the number of mistakes they make.

It explains why TDD on it’s own will fail, and also why some folk don’t even need a fully bulked up test suite, if one at all. Although personally, i think no matter how good you are, there has to be something challenging in every project which you need a safety net for to keep the productivity going.

And it explains a lot of things about business, but more importantly for me, the business of software production. Also, it helped me realise why the solid programmers i have had the honour of working with are good AND cool to work with.

Attitude towards your craft (and fellow crafters even) and the passion for what you do will be directly proportional to the number of bugs waiting for you in 3 months time on a tight deadline. And, i suppose, the converse would also be true: the number of bugs you’re dealing with today (of your own making) are a direct result of your attitude applied when first implemented, and if not of your own making, those bugs reflect the attitude of the guilty coder.

Of course, i maintain the assumption of all things being equal, most notably: skill and ability.

And therein lies a great life lesson too (it’s part of why i really groove on programming as a lifestyle). The relationship between the bugs in your life and your attitude towards your life is more apparent and plain to spot than you might imagine.

Categories
Technology

Annoying Software

One of the funniest things i read this morning… or maybe it was the tea?

“And yes, when I ask to exit the software, that’s because I really want to, not because I’m having a crisis of doubt.” (The bold is my emphasis)

LOL How many times have you joked about this? Are you really really really sure you want to exit? Really? For sure? Think about it carefully, because if you close me now, and you didn’t mean to, you’re going to have start me up all over again. So, are you sure you want to exit?

And the irony is, whenever i create an application where i don’t ask the user “Are you sure you want to <INSERT REQUESTED_ACTION HERE>?” after they explicitly clicked on the button to execute the aforementioned REQUESTED_ACTION, it feels like commiting a crime. In fact, i even had a user the other day log a “bug” saying: “Isn’t it supposed to ask me if i want to do that?” Priceless.

Btw, the quote is from an article on zdnet

Categories
Technology

Learn By Do. Part III

This is kinda like a bumper edition, since it wasn’t intended but after hacking this for a bit, it turned out to be a pretty useful exercise, no matter the language. Why? Primarily since you get to, depending on implementation, write your own data structures and use recursion. This combination of tasks usually allows you to explore and discover some interesting language-related issues. So then, without further ado.

The task: generate all the possible word combinations from a telephone number. The first stab, ignore dictionaries and words or phrases that actually make sense in English, and just be able to “translate” the number 23 => ad, ae, af, bd, be, bf, cd, ce and cf. If the number is 233, the options become add, ade, adf, aed, aee, aef and so on all the way through to cff. And then later maybe we can reverse the process and make up a word to come up with a number?

Right, the strategy: write tests first! The first thing i need is a class that can accept and validate a string as being a legit phone number.

class TestPhoneNumber < Test::Unit::TestCase
  def test_ctor
    p = PhoneNumber.new("0215556767")
  end
  def test_cant_have_alpha
    assert_raise(ArgumentError) {PhoneNumber.new("065a223")}
  end
  def test_cant_have_punctuation
    assert_raise(ArgumentError) {PhoneNumber.new("087!322")}
  end
  def test_cant_have_other
    assert_raise(ArgumentError) {PhoneNumber.new("0987%")}
  end
  def test_split_numbers
    p = PhoneNumber.new("0123")
    assert_equal(["0", "1", "2", "3"], p.split_numbers)
  end
end

I also wanted to store the individual digits since in my mind’s eye, i can see myself using a map to index and reference the letters using the digits so it just feels like something i need to do right now. We’ll see how it plays out. Turns out, the implementation is pretty straightforward:

def initialize(number_as_string)
   if number_as_string =~ /\D/
     raise ArgumentError.new("Can only contain numbers")
   end
   @split_numbers = split_the_numbers(number_as_string)
end

A simple regular expression takes care of most of what i need to cover. Splitting the numbers is a simple loop, no fuss there.

def split_the_numbers(numbers)
  i = 0
  result = [""]
  while i< numbers.length
    result[i] = numbers[i,1]; i += 1
  end
  return result
end

The trick now is to be able to write something like:

PhoneNumber.new("23").possible_words.each do {|word|
 print word
}

And get the output:

ad
ae
af
bd
be
bf
cd
ce
cf

Mmmm… Tree? Graph? Simple arrays and hashes? What will it be? (…to be continued)