Since a few days a certain operation in the webshop software we’ve written at work was extremely slow. Adding a product to the basket took forever, like 2 minutes. When adding a product to the basket it checks if there are any related products that should be added to the shopping basket as well. This is a feature we’ve called bundles. You can bundle products together and specify some rules such as optional or obligatory to purchase with the selected product.
In our current database some products can have up to 100 optional articles. Such as extended warranties, memory expansion and so forth (in case of e.g. a desktop PC). After finding the source of my problems I was dazzled. I iterated over the products in my shopping basket with a foreach-loop. Inside I used a switch-statement to see if the related article was optional or not. If not, I would simply do a continue to go to the next item in my list. Or so I thought.
This however didn’t seem to work and after looking up PHP’s online manual I found this:
Note: Note that unlike some other languages, the continue statement applies to switch and acts similar to break. If you have a switch inside a loop and wish to continue to the next iteration of the outer loop, use continue 2.
I was very surprised to read this, totally unexpected to learn about this behavior. I really can’t think of any reason why they did this.
PS: I know adding 100 optional products shouldn’t take that long, but since all our prices are pre-calculated (we have a very extended pricing table with lots of features and conditions) we want to be sure the price is right when they add it to the basket so we recalculate it and update the product database.
A while ago I posted about Programming languages to learn in 2011. Now that we’re almost halfway into 2011 I though I do a little reflection of what languages I’ve learned so far… None!
Although none isn’t exactly correct, I can’t say I have learned enough of any of the listed languages to program with. So far all I’ve really done is reading the amazing book Learn You a Haskell for Great Good. So far I’m halfway through the book and I actually did some of the examples and am able to figure out what most of the syntax means. But not more than that.
Not exactly what I had in mind but still it’s better than nothing. I’ll be able to catchup soon though as I’m still only working full-time for 6 more weeks. After that I’ll have 2 months off (I’ll still have to do work from home, but will have a lot more free time on my hands) so that should be plenty of time to learn some new stuff!
Since almost 6 months has passed now, why is it that I haven’t done more yet? Well, there’s still the issues I have with my hands, although the last couple of 5 weeks or so this is getting much more better. I’m still trying to get my Vitamin D level up and am also getting Vitamin B12 injections. On top of that I’m still visiting the Acupuncturist every month or so.
In these weeks that I’ve finally been able to get some stuff done I focused on getting the Maximus website up and running and make it feature complete. All required functionality is in there now and it actually already hosts quite a lot of modules. Out of my head over 250. There’s still more work to be done for the final 1.0.0 release but it’s mostly refactoring, writing test cases and the occasional bug fixing.
So no, I haven’t been able to study the listed programming languages, but I have been able to do some more Perl and get Maximus in a state where it’s usable. In the coming months I do plan to focus on Haskell and C# though, as well as refreshing my Math skills. So all in all I’m pleased with my progress so far.