In my first job out of college, one day I was told to query some data... and SQL was new to me. Gosh, computer science without knowledge of database is not so adequate for work because people want data, not determining if your algorithm is O(n2) or O(n log n), or if your problem is NP-complete or not. The ORDER BY clause saved me from pulling out the quicksort algorithm.
Fast forward many years, one day I take a look at some source code of a colleague (JSP file) and found the BUBBLE SORT algorithm!
What a surprise... Ok, that data is not from SQL so the ORDER BY clause can't help us here, but... buble sort on the presentation layer? this is not good strategy.
Ok, before you boo on the Bubblesort algorithm as poor O(n2) algorithm, let me tell you this: the quicksort is also O(n2) and a lot more ugly to write on your own.
Bubblesort is perfectly fine if your items to sort is not a whole lot.
The beauty of java is that many things are implemented for you already. How about Collections.sort? Stuff your items in an ArrayList, provide your own compareTo and voila.
I recently found out there is also Collections.shuffle too. This is ideal if you have to implement something like a card game.
So many objects so many methods within each... How do you learn them all?
So many new toys, some are here to stay, some are temporary hype.
Perhaps there ought to be continuous education program for people to stay updated. Perhaps it may be good business idea to open "tech update" classes...
Do I blame that colleague for being STUPID? No, as long as the code works.
That colleague was just not informed.
No comments:
Post a Comment