11 มิถุนายน 2552

การเขียนโปรแกรม เริ่มต้นที่การออกแบบจริง ๆ

วันนี้ ได้ทำการสังคายนาโปรแกรมที่เขียนใหม่ โดยเริ่มทำการสังคายนาในตอนเช้าเพราะ เออะใจตั้งแต่เมื่อวาน ว่าโปรแกรมที่เขียน มีการทำงานไมถูกต้องกับบางกรณี ซึ่งในตอนแรกไม่ทราบสาเหตุที่แน่ชัดของปัญหา ทำให้เสียเวลาค้นหาไปมาก และที่สำคัญก็คือ ในชุดทดสอบ เกือบทั้งหมด มันมีปัญหาแค่อันเดียว

Today, I tried to rewriting my source of my program in the morning because of some problem that existed yesterday. Such that my program was working incorrectly in some kind of problem. In fact, I did not know the real reason of this problem because my all test cases had one failed.

แต่พอได้ทำการดีบักไปซักพัก จนเย็น ได้พบว่า ปัญหาเกิดจากฟังก์ชั่นนึง ซึ่งส่งค่า ตำแหน่งของข้อมูลที่ผิดพลาดไปหนึ่งตำแหน่ง

But after I used most time for debuging, I founded the function that return wrong index of my datas.

แต่การแก้ไขซิ ไม่ง่ายครับ เพราะ ค่าที่ผิดอะ มันเริ่มเหลื่อมกันตั้งแต่ตอนไหนละ

First ever bugImage by Charlie Evatt via Flickr


But, It did not easy for fix because I could not find where the lines of miss concept code.

พยายามอยู่นาน จนเกือบถอดใจ สุดท้ายใช้วิธี ลองวาดภาพโฟล ของโปรแกรมใหม่ทั้งหมดอีกครั้ง
เรียบร้อยครับ ครั้งเดียวผ่าน แล้วยังแก้บัคที่หลบอยู่ ได้อีก จำนวนนึงด้วยพร้อมกัน
I tried for a long time. In the last I tried to use diagrams and flowchart of my function. Then, succeeded in one times and solved some hiding bugs.


ซึ้งแล้วครับว่า การวาดแผนผัง การออกแบบล่วงหน้า ช่วยได้จริง ๆ สุดท้ายขอตัด ประโยคนึงครับจากหนังที่ผมชอบ fool proof
I like to use this quotes from my favorite movies fool proof for myself.

"Think, Formulate that perfect plan And then we can proceed with absolute confidence"

คิดวางแผนที่รัดกุม แล้วทำตามอย่างมั่นใจ
Reblog this post [with Zemanta]

ไม่มีความคิดเห็น:

แสดงความคิดเห็น