Thursday, December 25, 2008

Make it work or Make it fast/optimized?

Most of time this issue struck my brain during my coding. Should i make it work first? Or should i optimized along the way?

It is easy to think that everything should be made to worked first, then optimized. It's normal (and thinkable, of course). We have to, since anything that we do is because we want to see it work. Otherwise it'll not be useful at all.

But do not forget that programming/coding involved a lot of works. Normally we are not writing 2-10 lines of codes but hundreds. Or maybe thousands (millions? are you writing another Vista?). So to review all these codes for optimization might take us several hours or days. And this if our working code can go along the optimization process.

But what if they not? What if we are writing the code using algorithm A, and suddenly we found that the optimization require algorithm B?! Isn't that would be burdening, redundant work, since we have to make it using B, make it work, and then optimize?

So these thing make my head spin fast, trying to solve these work-or-optimize issue ...

hmmmm.... but for now i just simply make it worked first (since i'm an ordinary programmer)...

2 comments:

  1. Bro, orang industri macam saya boleh kata, the keys of software developer, incremental , agile and simple, mudah nak faham of course OO.

    $person->getHead()->getHair();

    easy kan?

    Ko tgh guna framework apa? Made your work easy with a framework. Don't waste your time untuk benda2 simple.

    Kalau functional, best practice kalau disertakan sekali unit test. Kalau tak, testing part akan jadi serabut. Ko akan lupa function tu sebenarnya berfungsi untuk hasilkan output yang macamana. Bila nak refactoring code pun taak risau dah.

    Bole tengok soalan yang macam bubble sort. Soalan ni fames kalau interview dengan microsoft. The thing is, aku pernah cuba buat soalan ni.. code aku panjang menampakkan logic iq aku ni rendah. So it does not a matter kalau ianya tetap berfungsi sama seperti yang the simplest one. May be one day kita rasa nak improve kod tu sebab ko expected ia ambik resource tinggi, boleh la buang mana2 yang nampak messy tu.. tapi sebenarnya aku tak suka cara mcm tu.. nampak sangat bazir masa. The key aku develop ialah functional mesti ada unit test. Kalau tak haru biru nanti. Baru test-driven!

    http://en.wikipedia.org/wiki/Bubble_sort

    ReplyDelete
  2. OO erk? btul. bukn stkat industri je. Academician Soft Eng. pun galakkan.

    tp realitinya ada part OO lembap/less advantage berbanding functional. kalau tak apsal orang masih guna C...

    test? mmg betul. tp ni yg orang selalu lupa, mcm aku la. sbb lepas aku test, aku delete test code tu hahaha (patut archive/rekodkan.). thanx for the comment.

    ReplyDelete