Light bulb at the brink

This is another one of my “lessons learnt from video games” article. The role playing game in question is Romancing Saga. To illustrate my point, I’m going to describe some of the game battle mechanics.

Brief gist of the game. You, the player, can control up to five characters. Characters can be recruited during game play. Characters can master a variety of weapons (such as the sword, broadsword, staff and even martial arts) and magic (one of my favourites is the “sunlight”. Simple, unassuming, cheerful and very anti-violence in name. Still does good damage too.).

Sunlight on lake with mountain background

The difference between Romancing Saga and other RPGs is the method of levelling up. Normal RPGs have an experience point system. The more monsters you kill, and the more vicious they are, the higher the experience points. Once you accumulate a particular number of experience points, you level up, where one or more of the following increases: strength, speed, intelligence, health points (reach 0 and it’s game over), magic points (for casting spells) and other kinds of character statistics.

Romancing Saga, on the other hand, has an incremental system. After every battle, there’s a possibility that one or more of the character’s statistics will increase. I’m going to focus on 2 particular stats, the WP and the JP. The WP determines how many weapon skills a character can unleash. The JP determines how many spells a character can cast. What do they stand for? I’ve only got a hunch. See image below.

Ji Shu kanji

The 2 Chinese characters, or kanji in Japanese, is pronounced “ji” and “shu” respectively (in Chinese). Their Japanese pronunciation are “wa za” and “jiu tsu” respectively. They refer loosely to technical skills and intellectual skills respectively. Can you see it now? Wa za points, or WP. Jiu tsu points, or JP.

I’m focusing on WP and JP because, along with HP (health points?), they fluctuate in battle, usually in the undesirable direction of down. And if you have a long series of battles ahead of you, you want your characters to start with as high a value for each as possible.

So I, uh, sometimes go bully some weaker monsters. I will start off my bullying spree by wasting every single point of WP and JP. Why? This could be some superstitious belief of mine, but I found that when I’ve got 0 WP and 0 JP, my characters seem to improve their base WP and JP more often.

It’s like the game felt that because I’ve got nothing left, I probably don’t have enough WP and JP to begin with, so rewards me with increases of base WP and JP. Then when I rest up (which I hardly ever do), I have higher base stats.

The light bulb

There’s another reason why I waste all my skill points away when I’m trying to level up. In Romancing Saga, you can learn new weapon skills right there in the heat of a battle. You could use a rapier to attack normally, and suddenly, a “kring” sounds, a light bulb appears, and your rapier wielder unleashes an elegant whip-like slice to the monster’s aorta, resulting in fantastic arterial spray (muahahaha). Or you could use a weapon skill, say a double slash, and you learn the next version, the triple slash. It is an awesome sight to behold when your characters are “kringing” left and right…

And… it seems that if you’ve got 0 WP, the light bulbs come a bit more often. It’s like the game senses you’ve got nothing left, and to help you continue the battles, it rewards you with new (and usually devastating) skills so you can vanquish the monsters and actually stay alive.

I love this light bulbing so much that when one of my characters master a weapon (no more skills of that weapon to learn), I switch weapons just so that character continues to “kring”. It’s that much fun.

The obscure kringer

In Romancing Saga 3, there’s this female character you can recruit. In the story, she’s very sick, and cannot leave her home for too long. She’s gentle and sweet and frail. When she joins your party, your first impression of her is that she’s strong in magic, but she’s too weak in other areas to function well. On an overall character evaluation, you might think she’s not a good addition to your party members.

That is probably what the game developers wanted you to believe.

You see, once you can actually get her to survive some battles, her JP starts shooting up. She can learn magic spells faster than anyone else. She can wipe out a group of monsters with a flick of her little finger. She can bring one of your characters back from the brink of death with her healing spell. As a powerful magic user, she’s unbeatable. Until she runs out of JP.

That’s when her secret comes out.

She, is the most prolific kringer I have ever had the pleasure of playing.

Give her a sword, and don’t think she might drop the piece of steel. She can learn up to 3 new skills in a single battle. That’s about an average of one new skill per attack in the entire battle. Not enough money to buy weapons? Start her on unarmed combat. She’ll master the mid level martial arts skills so fast you’d think she’s on steroids. And maybe because the game feels she’s too weak, and grants higher level skills to her. It’s just so amazing to watch.

Sure, her new skill doesn’t do a lot of damage compared to another character performing the same skill, since her strength isn’t high. But as battles go by, and her base stats go up, her polymath abilities to master both weapon skills and magic spells make her a compatible character to whatever group you have in mind.

And get this; her name is Muse.

So what’s the lesson?

You’re at your wit’s end at solving a problem, say finding that elusive bug that’s driving you crazy. Maybe you’re not really at your wit’s end? Give more, give everything you’ve got. Scrutinise every single line of code. Question every single for loop structure. Scan like an infrared sensor and inspect like a telescope.

And sometimes when you’re tired, your vision is blurry, your shoulders are slumped and you’ve got nothing left to give, your brain does something magical. A light bulb “krings”. Your brain presents you the simplest solution requiring the least amount of effort, because you’ve got nothing left.

You light bulbed at the brink.

Reusable code not important

We’re moving faster. Technology advances. Businesses change. New services emerge. It’s not how much better you are at reusing code, but how much better you are at creating new code that’s of value.

It’s a new program, with new logic

Someone once said that his team seldom reuse code, because they almost certainly have to rewrite most of their existing code. Their new program will need new logic and a different way of optimisation.

I’m talking about demos. I can’t remember if it’s ASD, or Conspiracy who said that. Or maybe I read it in a Hugi magazine.

Once you get past the standard texture, music and 3D geometric mesh/object loading, it’s down to the new and creative code. And new and creative code doesn’t come from reusable code. Code used to create a special effect in one demo, might not be transferrable to another demo.

Businesses change

And so does the business logic. My users think of new ways to conduct business all the time. New services, new forms of price plans and new ways of interacting with data.

I develop .NET web applications for them. Like a good programmer, I separated web pages from business logic code. Then I realised that I’ve never used any function related to business logic more than a few times in an entire web application. That business function had a specific use, and so was inappropriate for code reuse, because you can’t reuse it!

To stay competitive, businesses have to change. They’ve got to keep innovating and keep providing more value to their customers. Programs written for one service might have to be rewritten to take advantage of better tools, or refactored to remove useless parts, or even replaced by a new program specifically written for a new service.

Innovation versus APIs, components and the like

Innovation means new ideas. So it means new code. Sure, you could come up with a new idea by combining two or more existing ideas. Existing code could still be used. Fair enough.

Then you come up with another new idea, based on that combo idea. And another based on existing ideas. Eventually, there comes a point where a new idea is better off being free from any parent idea. The new idea is so completely new that it looks nothing like existing ideas.

That’s innovation. So where’s the code going to come from? From scratch.

Application programming interfaces are meant to be reused. I’ve written custom web controls for reuse. I’ve written Javascript functions for reuse.

But unless you’re specifically writing code for reuse purposes, write code for the intended purpose first. If it’s easy to extend it to a more general form, then go ahead. Forget generalisation if any major reconstruction is needed to make it usable by an unknown number of applications for unknown uses.

I am the sole web developer in my team. I don’t have time to think into the future where I guess what my users might possibly want to do with my applications. By the time that imagined future arrives, my users might want a different feature. So what does that get me?

So should you reuse code or write reusable code?

As with many things, it depends. I want you to think for yourself. Decide for yourself if that piece of code is going to be useful in a generic form. Decide for yourself if your time is better used on writing a feature that provides value immediately.

This decision comes with experience. And programming experience isn’t measured in years, or months. It’s measured in the number of lines of code you write that never see the light of day. (which is an excellent topic for another day…)

In these current times, there are excellent code libraries that take out the drudgery of your work. Your time should be used on creating more valuable code on top of that. Reusable code is not important. Valuable code is.