Näytetään tekstit, joissa on tunniste ENG. Näytä kaikki tekstit
Näytetään tekstit, joissa on tunniste ENG. Näytä kaikki tekstit

lauantai 4. toukokuuta 2013

Do you know what a "regression bug" is?

All the readers that are not programmers, can safely get their eyes crossed. Most would not know differences between "regression bug", "logic bug", "blunder in implementation", "this will not work, but let's try it anyway" or any other type of "bug" (which, btw is an umbrella term to enclose pretty much everything that can go wrong in a software) from each other. For the end user, there is no difference; the software does not work as it is supposed to, and it needs to be fixed. Preferably yesterday.

For software developers, designers et al., there is a difference. Regression bugs are the most common type of bugs when new functionality is being added to existing code. And usually, fixing it is not really hard - though finding the reason might take a while.

In laymans terms, a regression bug is "something that worked as expected before, but no longer doesn't". Most of the times this happens, it is unintentional. Then again, if the feature was that previously was working, but no longer is, it being removed from a new version is not a bug - in that case, it is a "design decision". Sometimes it is necessary to remove features from software. Most of the times, this is done with long and careful consideration. Clients do not want to chabge the way they are used to doing things, so if you deliberately remove a feature, you better have a damn good excuse. The most common reason for doing it is "maintaining that feature in the future would slow down all development". Better yet, if the feature is something that nobody uses (anymore possibly), well... it can go.

But yeah, there often are unintended regressions in functionality that are bugs. Because they happen often, is why they have a specific name in software developers' vocabulary.

These days, pretty much all of the professional software is composed of tiny pieces of code that are meant to do one thing and one thing only - but do it consistently, so that the same small piece of code can be called from a multitude of places - to do that one thing with any input we decide to throw at it. This is a good thing - because if we find an even better way to do that one thing, we only need to change it once... and every part of the code that uses that piece of code will be working... "better" by definition.

In theory, there is no difference between practice and theory. In practice, there is.

What works for most situations - even though the base problem might be the same - doesn't necessarily work for all of the situations. And these few situations where things don't work are the ones that cause regression bugs.

Imagine an axle that is able to hold a number of wheels of various widths (just for the fun of it). You've made the axle 100cm long. Before you had four 20cm wide wheels on the axle. No problem. Then you add a fifth one. Still no problem ... all the wheels are still on the axle. One day you add another feature to your program (a new wheel) that is supposed to use the same axle as the previous five wheels, and you get a regression bug. One of the wheels drops off from the other end of the axle and no longer does what it is supposed to do.

In real life, it is easy to see that one of the wheels has dropped off. In software development, finding this out might be a lot more complicated. Perhaps that is not an important wheel ... maybe it is only used rarely anyway. All of the other parts (that are not dependent on that one now missing wheel) might work perfectly. But when you try to do something that really needs that wheel ... most likely you will end up in trouble.

Finding out why the end user is getting in trouble might be... umm... troublesome. Finding out how to fix things might be even more so. When you finally find the source of the problem - too narrow axle with too many 20cm tires, you need to decide what to do...

  • Do you widen the axle to hold the 6th wheel? What if a wider axle doesn't fit where it is supposed to be?
  • Do you make all the tires 16.5cm wide to make six of them fit on the 100cm axle? What if the tires really needs to be 20cm wide in order to work? Can you make the tire have larger diameter to have the same internal volume in 16.5cm as it has in 20cm width?
  • Do you make another axle to hold the extra tire (and possibly something else you would like to add there later on? What problems will that bring?

Like said, regression bugs are amongst the most common ones encountered in software development. Test teams arethe main way to keep them from appearing. But this is slow... Because not only the latest changes need to be tested - but also everything else... just to see that there are no regression bugs. And if there are, the testing begins again from the start - because when the problems were fixed, this might have created new ones. This is the main reason why software testing of new versions might actually take longer than the actual implementation of new features.

keskiviikko 13. kesäkuuta 2012

The gravity of the situation...?

Where it all starts

Sometimes I find myself thinking of stuff I should not be bothered with. The most recent time this happened was when I saw this GIF showing a simulation of what happens when a star is consumed by a black hole (it looks marvelous, I'd say)


Well, this got my mind working... Black holes are not some gigantic vacuum cleaners in the sky preying on unsuspecting stars to consume. In fact - for the black hole to have any kind of effect on the trajectory of a star in the first place, the black hole would need to have a mass comparable with the star, which something that is a way lot more than most people are even able to visualize in their mind.

The experiment

For the sake of satisfying our scientific hunger, let us create a lab room for testing things with black holes. The room is created in such a fashion that no amount of gravity escapes from the room (thus making it safe to test some serious shit inside the lab) ... for the sake of argument, let's do this by magic, since I know of no way to actually achieve it otherwise.
Now, let us put a black hole in the middle of the room that has a mass of one million metric tons. And since we are sadistic beasts that couldn't care less what PETA has to say, let us put a mouse inside the lab and see what is going to happen to the mouse?

This is going to be legen-(wait for it)-dary!

Aaaaand... absolutely nothing. Wait? NOTHING you say?!? Yes, the mouse is unharmed. As is the lab assistant that went to the room to put the mouse in there. Even me, the mad scientist performing this experiment that entered the room to see what went wrong is completely unharmed.
The "mad scientist"-me is furious. Why did the experiment fail? Did our magnificent black hole escape the room before we started?
Interestingly, the answer is that the experiment didn't fail - it simply proved that black holes behave exactly the way they are supposed to, and that you still need to obey gravity (after all, it's the law; don't mess with it).

So, what went "wrong"?

Inverse square rule of gravity effect and a huge misunderstanding of mass and other things required to make anything happen. To put it simply - believe it or not, a black hole with a mass of one million metric tons is way smaller than an atom. The inverse square rule of gravity states that every time the distance from the object doubles, the gravitational effect of the object drops to one fourth. And, since the object in question is smaller than an atom, the drop in gravitational effect happens fast.
In fact, were the mad scientist to go stand in the middle of the room, chances are that still nothing would happen. There are vast amounts of "empty space" between atoms, and for even one atom to come close enough to the black hole to be consumed by it, that atom would have to be extremely unlucky - and that is where the train would stop; you'd be that one atom short in your body and would never be able to tell the difference.

Why are black holes usually depicted as "starkillers" then?

Well, our experimental black hole was too small to do anything. That doesn't mean that there aren't far larger ones to be found in the universe - there are. Interestingly, though. For a black hole to have any kind of effect, it usually needs to be huge (and by "huge" I really do mean bigger than massive ... our one million metric ton black hole just wasn't large enough, not by a far margin).
Let's take something a bit more sinister; a black hole with a mass of one sextillion (that is a number with one followed by 21 zeroes) metric tons. That would be roughly one sixth the mass of earth and if one were passing through the solar system it could have an impact on the orbits of the planets. Still however the chances are that such an object would pass through the solar system completely unnoticed. Interestingly - if that black hole were to pass by earth at a suitable velocity and distance, there are bigger chances that earth would make a satellite of it ... it has about the same amount of mass as our moon (and what a great opportunity for science that would be having our own largeish black hole to experiment with).
That "moon mass" black hole would still frankly be quite small. So let's go mythbusters and ramp things up a little - say... get a black hole 2 million times larger than the previous one. The mass of that thing would be roughly similar to the mass of sun. This means that if earth were directly in the middle between the sun and our black hole, we would possibly finally become the center of our solar system; sun and the black hole would start to revolve around each other with the earth stationary in the middle. Most likely all the other planets in the solar system would have a hard time to adapt to the situation, though.

And what does all this mean in practice?

Interestingly, even though we've already ramped things up multiple times, we are still talking about very small black holes here. I personally must admit that I am not too worried about the possibility of LHC creating black holes ... after all - even if it did, they'd go unnoticed in the big scheme of things :)

maanantai 19. syyskuuta 2011

My keyboard controls for FPS

Back in early 1997, I used to sneak with a couple of friends to a school's computer lab during nighttime to play some multiplayer first person shooters like Quake and Duke Nukem 3D (this was actually strictly forbidden; not "using the lab" per se but using it to play games). At that time, it was still quite customary to play using only the keyboard, because "mouse-look" still hadn't really caught wind. You would use the right hand on arrow keys to control the character whereas left hand generally was used for crouching, jumping, switching between weapons and stuff like that. Needless to say, this wasn't too efficient control method.

Fast forward to 1999 and the release of Unreal Tournament. By this time, mouse-look was already a standard feature in FPS-type of games. Some people still used the arrow keys for character control (which I find strange, because that way your whole body was shifted to the right of the keyboard - assuming of course you use mouse with your right hand ... then again, many of those persons had also moved their monitor to better suit their way of playing - to each their own, I guess). Most however were already using the "quite standard" A/S/W/D control keys which, granted, was a lot more sensible.

At this time, I found a control mapping that suited me a lot better than any of the alternatives I tried. It was (and still is) controversial and not too widely known. Frankly, most of my friends never learned to use it. I personally opt for a pose of hand which requires minimum movement of fingers. In practice, I use the following keys:

A - Strafe left
S - Strafe right
D - Move forward
C - Move backward
SPACE - Jumping
CTRL - Crouching

While this may at first look like a strange layout, once you've familiarised yourself with it, you will notice that, it can give some benefit in games, because you are able to move around easier and - frankly - without effort because your hand does not "move" ... in fact, under normal circumstances your fingers are never supposed to leave their assigned keys (CTRL is pressed with the palm of your hand - the palm is already positioned over it).

Also, I know that I'm definetly not the first person to use these keyboard controls. I just thought I'd post this - things that are not often used by others may just give "the next generation of gamers" the bit of edge they're graving for. Not to mention, this is a great way of stopping others and make them think twice before they attempt to play on my computer ... after all, you don't modify mappings on anyone elses computer, do you? ;)

maanantai 28. helmikuuta 2011

My Internet Roadwarrior experiences in Asia 2011

Travellers on a holiday generally use Internet for checking their email, possibly reading the local and home news. Such things can easily be done on the occasional internet cafe. If the connection is slow or cuts out, that is usually not the end of the world for those people.

Internet Road warriors, people travelling and doing work at the same time however have quite different kinds of needs for network connectivity. They may be transmitting large amounts of data (pictures, videos), having long staff meetings over Skype (with voice-communication), constantly reading their eMail and accessing all sorts of other resources over the Internet. For Internet Road Warriors, having "better than average" connectivity is a must and a link dying for even one minute may actually become a life and death situation. Still interested in becoming one? Read on...

The following is based on my most recent experiences around Asia. I've covered getting connected in Bali (Indonesia), Phuket (Thailand), Singapore and Dubai (United Arab Emirates). While it is true that you can often get connections for a fraction of the prices quoted here, these things have been chosen based on the needs of a working person. For everyday traveller they may well be overkill. However, on many occasions, the prices quoted are not the most overwhelming ones either. Yes, granted, you could go for a "leased line" in all of these locations and pay "only" 1.000-10.000 US$ worth for it monthly, but more often than not, nearly the same can be achieved for lot less - of course, if that is your cup of tea, just go for it :)

Indonesia / Bali

While connections in Java (especially around Jakarta, but other parts also) are generally speedy and quite cheap, Bali is quite a different animal. Most locals (including over 90% of the internet cafes I've tested) are still connected using ancient dialup modems, and anyone who can remember how those things perform (or rather, don't) when surfing the net can attest to the fact that the experience is far from enjoyable.

There are some broadband providers, but generally they are not worth the trouble; unless you're on a longer visa, it is quite impossible to have line connected - at least during your stay ... and even if you get connected, the speeds are far from those advertised (in Bali, 256k and even 128k are considered "broadband"). For example, the place I was staying had a 1M ADSL but in practice the speed hardly ever was more than 0.13M at any given time - and they paid an arm and a leg for it.

In Bali (and actually in most of Asia) you're best off subscribing to a mobile broadband connection (3G). I personally took quite some time testing different providers and finally settled with Telkomsel. You can't throw a rock in populated areas of Bali without hitting a stall selling their Simpati-cards. Since the card is prepaid, you need to load enough "pulsa" (credit) on the card in order to register for a 3G-plan. There are different plans, but if you wish to get most bang for your buck, pick the "Flash Volume Based 1.5GB" like I did. It requires 400.000rp worth of pulsa on your account. In addition to "Volume Based" plans, Telkomsel offers so-called "Unlimited" plans, but frankly these are not worth considering. In reality, they also have a maximum quota (determined by the amount of pulsa you're willing to sacrifice for Internet) - and the speeds you get are lower than in the Volume Based plans.

You register for the plan by sending SMS to number 3636 with message "FLASH ON 400k" (without quotes). You get a response stating that in order to accept the plan, you still need to send SMS to number 3636 with message "FLASH YA". After you've done this, the plan is activated and you have 30 days access with 1.5GB quota (maximum sum total of your download and upload during the validity period of your plan) at speeds of 2Mbps maximum (in reality, I often got speeds far exceeding 1Mbps).

At any time, you can check the amount of pulsa and the remaining plan quota. Just call number *888# for the pulsa (amount is returned to you in text) or *889# for the quota (also in text, displayed in kilobytes remaining). If you happen to run out of quota, your data transfer will be charged on your pulsa (quickly depleting it if you fail to top it up) and the speed drops to something like 64kbps maximum ... if this happens to you, discontinue the existing useless plan by sending messages "FLASH OFF" and "FLASH YA" (after confirmation request) to number 3636 and resubscribe (at the time I had to do this, it was not possible to top the quota, only resubscribing did the trick).

For connecting with a computer, you can purchase a cheap USB-3G -modem (Rimo Computer in Jalan Diponegoro is a good place for such purchases in Denpasar). APN for Telkomsel's Flash is either "internet", "telkomsel" or "flash" (this depended on the day; on other days all worked, on others only some - go figure:) You could use anything (except empty values?) for username/password. The telephone number to dial with modem is *99# (like with most 3G providers).

While the speed using the above plan is good, Telkomsel has often problems with DNS-servers (meaning that even though you are connected to the Internet, you are unable to access any websites). For this, registering for a secure VPN-tunnel provider (I personally use vpntunnel.se) can greatly enhance your websurfing experience (tunnels usually provide their own DNS). Also, using a secure VPN-tunnel will enable you to bypass any access limitations the ISP may have set up (not that I ever noticed any).

Also, it is worth noting that the whole island is not under 3G coverage. However, if you spend most of your time in main tourist attractions of Denpasar Selatan, Sanur and Kuta, you'll be just fine. Also parts of Ubud have good coverage. At the time of writing, there are nearly no areas outside those mentioned that are yet covered (outside 3G coverage area you only get GPRS or EDGE speeds - if you're lucky).

Thailand / Phuket

When I decided to go to Thailand, I was initially pretty uncertain how I would be setting up my communication needs there - seeing that the country has been a rather late adopter of any new communications technologies in the recent years. Last time I had visited the kingdom (in 2005) there were no 3G providers in the whole country - at least that was the official story at the time. Of course, if you're in the country for at least a month, you do have the option of subscribing for ADSL during your visit. Some villas, condos and hotels already have broadband connections available. Also there are many internet cafes that have relatively speedy connections.

Thankfully, during last few years, mobile broadband has entered many parts of the country. Most providers in Phuket only offer 2.5G (EDGE) connections, but Truemove has 3G coverage in some parts of the island. Same as in Bali, there are a number of access plans to choose from - prepaid naturally, for the benefit of travellers. Personally, I chose their highest "Volume Based"-package that gives me 1GB worth of traffic in 3G network and - interestingly - unlimited access to Truemove's WiFi-hotspots. Registering for the plan required me to have 699 baht credit on my SIM, and was as simple as sending SMS message "V3" to number 9789.

For using the connection with a computer and USB-3G -modem, APN for Truemove is "internet" and both username and password are "TRUE". The telephone number to dial with modem is *99# (again, as with most 3G providers).

As said, the 3G is only covered on some parts of the island (namely they promise coverage only in Patong & around the Airport, but Kata and some other places here and there work too - and don't forget about the unlimited WiFi-hotspot access). It is worth noting however that Truemove's 3G uses the 850MHz band (instead of the more common 900MHz) so not all USB-3G -modems are able to connect. I personally have at my disposal Huawei's E220 which is unable to use the 850MHz while my older BandLuxe C179 connects without any trouble.

For sake of completedness, it needs to be told that CAT offers CDMA EVDO connections in Phuket area. However, don't be fooled by the "3G" they have plasered around their advertisements; EVDO is an entirely different system (works on different bandwidth, etc.) than what people normally associate with 3G (HSUPA/HSDPA). Unless you know for a fact that you have a suitable modem, don't bother going this path :)

Singapore

Singapore is an Internet Road Warrior's wet dream come true :) Not as cheap as most other countries in Asia (however, still quite affordable), and you can do just about anything in here. Internet cafes have faster connections than in most western countries and if you choose to purchase a 3G card, you can get 7.2Mbps download (theoretical, I've never managed to actually achieve more than little over 5Mbps) and nearly 2Mbps upload speed.

In Singapore, my choice for data carrier has always been StarHub's MaxMobile prepaid. You do have a "fair use quota", but since the quota is as high as 2GB daily, it is essentially "unlimited" (in most other countries I've visited, the quotas on prepaid 3G are often way lower in allowed amount of data transfer ... on a monthly basis). The SIM-card itself costs 12 Singapore Dollars whereas a 5 day unlimited data plan of 7.2Mbps shells off 25 Singapore Dollars more. Easiest way to get started is to simply go to a StarHub outlet (these can be found on most shopping centers or - if you're a die hard roadwarrior - already at Changi airport) and purchase SIM as well as a top-up card there and have them set it up for you (after all, you need to provide your passport details in order to purchase a prepaid card). However, if you already have the SIM-card and you have added 25 Singapore Dollars worth of credit on it, you can also activate the plan by sending SMS message "7M5D" to number 6782.

For using the connection with a computer and USB-3G -modem, APN for MaxMobile is "shppd" and the telephone number to dial is *99# ... no username/password is necessary (however, some software dialers refuse to call out if they have not been set, so I assume anything is allowed?).

United Arab Emirates / Dubai

I must admit that on my most recent visit (that also being my first visit, actually) I spent so little time in the U.A.E. that I didn't bother setting up a local 3G account. WiFi hotspots were available everywhere, using them is cheap (when not entirely free) and the connection generally was quite pleasantly speedy. It must be noted though that at most places, services like Facebook and Skype are often blocked, so if you're into those kinds of services, I'd suggest registering for a secure VPN-tunnel provider (I personally have an account at vpntunnel.se) ... using one of those you can bypass almost all kinds of blocks they've attempted to raise.

torstai 7. toukokuuta 2009

Debugging ain't rocket science, they say...

Well, apparently, sometimes it is. On other times, it just feels like that.

Many software developers are - for the most of their time - tasked with debugging their software; just in order to make it absolutely impossible for the program to make mistakes that could (in the worst case, for example in case of the above linked lunar module example) cost lives... or - lead "the people in charge" to wrong conclusions.

Why am I blogging about this? Well, perhaps it's easier to tell what it is that I "do" for living... I am a software developer; if I had any family, after work I'd go home and my children might ask me "daddy, what you do today?"... to which I couldn't do anything but simply answer that "I performed my duties as a software developer" - and leave it at that. Anyway, for the past 10+ years, I've worked on a project that supposedly is used to follow who works on a company and does exactly what. Furthermore, the system is designed to keep track of what the said workforce actually can do - and what it is supposed to do.

Even though it is not designed for this, I do know - without a shadow of a doubt - that the system I've designed is sometimes used to "create the unemployed". Granted, the software is not designed with that goal; instead, it is meant to measure what each and every worker within a company should be capable of - and what they indeed are capable of. Unfortunately, these days it very often means that the workers that aren't capable of what is expected from them... are "let go". They are the ones who should be able to do a given thing, but - for one reason or another - arent't capable of doing it.

So... why would I be interested in this? Well, to put it in simple terms - because I think it's necessary. I personally would feel like shit if I learned that someone - even one person - were to be "gotten the boot" because of a program I made told his/her supervisor that s/he ain't fit for the job.

How does this influence my work? For one thing, I want to make it absolutely certain that whatever I code meets the criteria set for it - at least. Also, I want to be able to understand what is actually expected of the code. This helps me point it out for the people who are in charge of determining what it is that is being designed when something it is supposed to do is illegal, or - to a lesser effect - not something it should be able to tell about people. Even though everyone says they want to know everything... honestly - they don't. They want to know what they need to know - and that is usually very far from "everything".

Anyway - to get back to the subject... sometimes debugging software honestly does seem like rocket science. When you work with a given software for a number of years, it tends to "bloat". New features are (often) added, old features are (more often than not) redesigned to work differently. Sometimes, due to all these new things and possibly some old things not working like they've originally been designed... or some old things not working as originally designed because of the new things - well... things just tend to break up. Something that was designed for one thing gets used for entirely different thing. Something that was never supposed to be used at all is brought in as an indispensable new feature. When all these redesigns occur, it is possible that something that (at the time it was designed) was very much something users couldn't live without - becomes the source of multiple problems. A piece of code - that originally did a very distinct work - now does many things... and some of those things manage to mess things other pieces of code are supposed to handle...

Those are the days that make software developers very sad. Unfortunately - all they do is code based on what is needed. When they see their "child" becoming corrupted... what can they do - but weep... and hope for a better tomorrow. And do their bloody best to keep the thing they originally lovingly brought into being from becoming a monster. Well... I think that is something every parent might face at one point or another.