Monday, October 15, 2012

What make Quality of Code/ How to measure?



What make Quality of Code/ How to measure?

To make sure that your code is well running together with the other, you might need to have standard or tools that you and your team could work

Code Metrics

Code metrics is a set of software measures that provide developers better insight into the code they are developing. By taking advantage of code metrics, developer can understand which types or methods should be rework or have more tests.
There are some common measures that we could use;

  •           Total line of code
  •           Line of duplicate code
  •           Unit test coverage
  •           Coding standard violation
  •           Program execution time
  •           Program load time
  •           Ratio of comment and code

Code Standard

MISRA-C is software development standards for C programming language develop by MISRA (Motor Industry Software Reliability Association). Many developers from embedded systems specification always refer to MISRA C Standard for the work that needs high reliability.
MISRA also has more users outside the original specification. They realized that in many areas of an automobile design, safety, portability and reliability is importance. They has evolved as a widely accepted model for best practices by leading developers in sectors including aerospace, telecom, medical devices, defense, railway and others.
The result was a set of “Guidelines for the use of the C language in Vehicle-Based Software” or “MISRA C”. The first published guideline comprises a 70-page document that describes a workable subset of C to avoid many of well-known problems. The MISRA C document contains 8 chapters and 2 appendices and was obviously written by experienced embedded programmers. Chapters 1 through 6 contain important information about the rationale for MISRA C and how to interpret the rules. These Chapters should be read prior to diving in to the actual rules, which are found in Chapter 7. MISRA C document is available at www.misra.org.uk for about $50.

Friday, October 12, 2012

Quality of Code



Quality of Code

There are many definitions for Quality of code from my research this few days. As we know, we try to improve our code, not only for the author but also other people in the team. If I could list what are the good code should be, it should be like this;
  • No redundant or repeat code: if you have several lines of code with the same action, you should make it to the new function. For this advantage, you will have another short command that can reuse many times.
  • Code readable 
    • Use good name for function or variable
    • Good comment and document
    • But if you have a good code it should understandable without comment. Source code itself says what the code does and how
  • Right responsibility for each function: one responsibility for one function.
  • Optimize resource/efficient: Poorly written code will not take account of resource usage, for example it will not cache information it could cache, or it will create new objects when it did not need to. These issues lead to hard to maintain applications when deployed and used.
  •  Well organized: should be easy to find what variable goes to which function, where you locate your code.
  •  Have code review: ask some other person for each some important part

Wednesday, July 11, 2012

python and opencv

Install OpenCV and Python
Yesterday we had problem about installing OpenCV with python, so I tried to install on my computer and it work quite well here. I also have problem with new version of OpenCV (OpenCV version 2). It seems like new version of OpenCV is just a zip file and we need more step that we have tried but it didn’t work such as Add <...>\OpenCV\bin to the system PATH and so on.
What I have installed: python-2.6 and OpenCV1.1 (OpenCV1.1 is .exe file, so it automatically add path for us. If you found problem about downloading the old version of OpenCV, you can email me to send the link to you, it’s about 25.5 MB)
After you installed those two programs, you can try if it work or not by import these two libraries from Python shell

>> from opencv.cv import *
>> from opencv.highgui import *

If it works, it means you can use this function with python.
There are some examples that you can learn more from <yourOpenCVpath>\samples\python. They also provided the example for C if you prefer to use.

Getting start with Python
To create new project,

  • File>New Window, then you will have new space to create your program
  • Import CV and Highgui
    from opencv.cv import *
    from opencv.highgui import *
  • You can try with load image and show image here I show the image called penguins.jpg here is the program;

from opencv.cv import *
from opencv.highgui import *

img = cvLoadImage ("penguin.png",0)
cvNamedWindow("Image", CV_WINDOW_AUTOSIZE)
cvShowImage("Image", img);

while cvWaitKey(0) != 0x1b: pass

  • After that, for test your program just press F5.


I hope I might help you to start your project, you can email me if you have problem about programming or image procelssing. I would glad to help you if I could.

Monday, July 9, 2012

I was hacked!!

When I got Hacked!
It was just this morning, I woke up at 5:30 am as usual, took a bath, check e-mail. Then I found that I was hacked and it charged from my Credit card about 23k THB! (Around 600 Euro) Oh my god! I was like stunning for 30 seconds. I got the receipt from Paypal and Skype for purchasing Skype credit but I didn’t! It reduced my Paypal money 9 times and each time with 85.40 Euro!
My transaction last night

5:55 am

First, I called my credit card provider to check is it true and yes, it already in the bill! Oh my god! Then Costumer service transfer my line to technical support (I guess) and complain that I didn’t do any transaction please check! They asked me many question to make sure and tell me that they will check and call me later. As you see from the picture, I think I was hacked by Chinese hacker for sure! They send me the information about Skype activities in Chinese and I don't understand! This morning I was in hurry because I was in the line for so long and didn’t feel the breakfast anymore. I slept all the way to work.
Email I got

8:00 am
Arrived work place but my mind still thinking about the money. For your information, I don’t have internet access on my computer at workplace. So everything I have to done on my mobile phone.
I contacted Paypal team about my problem via their web form once, and then 10 minute later I realize that I might send with wrong type of problem because I expect that they will have the auto reply email to me but it didn’t. At that time I really want to make a call but the nearest local was located at Singapore! I didn’t worry about speak English but to call to Singapore so it means I have to use long distance call isn’t it? No way! Email is okay.
Web form from Paypal


What! Singapore,



9:15 am
After that just notice that I didn’t contact with Skype yet! I was paid from Skype, how can I forgot! I send my problem to Skype team and they have auto reply email. Gosh!
Skype status

9:44 am
Got Email from Paypal, they already review my account and suggest me to cancel an automatic payment on merchant-to-merchant basis. Honestly, I don’t even know what is it, but when I did on the steps, I found that it was automatic payment! You don’t need to make a review again if you do another transaction! That’s why I have like 9 transactions with the same amount! As I told you I never know about this function, it was shock because it show that I have active this activity since 2010! I think it was my first time buying Skype credit.

Automatic payment list
Merchant detail, it started from 2010, 2 years ago! Did they just hack me or they already plan since last 2 years?

10:09 am
Got Email from Skype, they need me to verify that the payments are genuine. So I need to have a live chat with agent to give them my information. Then, I need to prepare the information such as my Skype name, email address, Paypal email, transaction ID, etc.

10:30 am
After taking a break, talking to my mother and crying, I’m ready to have a live chat! I go to Skype chat room talking to Skype Staff, Mr. G. He asked me the information about my name, my account, my email and so on. He said it seems not usual compare with my previous transaction. Then they transfer my chat to Skype-Paypal staff, for specialize my problem. Then I talked with Mr. R. He just needed to review my account and the previous chat with Mr. G. Then he said like skype team already inspect my problem, I will got the email about the billing cancellation as soon as possible and then I need to filling the form about refunding from Paypal. We finished live chat around 12:30! Wow, It was time for lunch, I think I started to hungry.
Live chat with Mr. R, finally they can provide me a help :)

1:00 pm
I finished my lunch early in order to get anything done. I got the email from Skype about charge back my order so it means skype already confirm that all transaction last night have been made fraudulently. I filled the form about transaction information and sent them to Paypal. Right after I send, I got the email about investigating status. Paypal said skype has been asked to provide more information about the transaction. During this time, I cannot do any thing via paypal until they decided and then I'll got the refund for the amount of the transaction. It was about 10 days for investigate process. So I think I won't be the problem because I already got the charged back email from skype. I hope I'll get my refund soon. I have no money to pay for sure, I don't even have money to buy stuff.
One (from 7) of the email from Paypal
This is from Skype
Note from this morning. Not only the basic information, I also prepare some vocabulary about money and privacy activities



Wow! Finally! All done before the afternoon section, then I can concentrate to my work as usual. 

To prevent this experience
Skype and Paypal suggested me to change my password and security question. Moreover, they suggested to use Antivirus too. I'm not really sure, I use Mac OS. - -" And I can't believe I got hacked! As firefox said, มันช่างน่าอับอายยิ่งนัก, Computer Engineering student got hacked!

Pay safe,
Patama R.



Last but not lease
4:48 pm
I got the phone call from my credit card provider! What! Don't you think is it too late? The staff call me in order to ask for my email address because she want to send me what should I do to about this problem. She said, they provided Thai language for Thai customer (but why they go to Singapore! Why do I need to use long distance call while you have Thai language from Thai stuff! And this was really make me upset, the email said for Thai language, I need to call between 9am to 5pm but you called me at 4:48am! GOSH! I didn't complain her about how late they are, they might have many thing to do in order to email to paypal to check them for me. (- -”) because I got the email that was the forword mail from paypal team which are the same as I saw from the Paypal website except the have Thai language. She told me if I already got the email please forward all email to them to check and they will contact again if they got the refund from Paypal and Skype.

Tuesday, June 19, 2012

and another new place again


And another new place again!
Hi! it's going to be my third week here. I'm currently join the trainee program at the factory of semi-conductor product around Bangna, Bangkok. My work here was about develop machine vision measuring system using integration of Halcon vision software and visual C#.
I will write about the work later, this blog i want towrite about the workplace. During working here, I usually called myself as "สาวโรงงาน-sao rong ngan" (girl who work in the factory). Actually, my friend called me first then we started using this word and I just like it. The office hour is super early, they start work at 8.00am till 5.45pm.(Kinda long ha?) Normally, i was getting up around 7.30am- 8.00am but now, I have to get up at 5am and arrive the workplace around 7am. Well, at least I still have time to take a nap before work.
As here is the manufactory, I expected about somewhere like the power plant that I worked when I was in the University, it was like a lot of dust, noisy place and super big. But you know, here is very clean factory! No dust in the walkway or even in the noisy sound. Because here is a factury about semi-conductor or electronic device, just a little of micro dust is unexceptable! So there are many many rule here we need to follow strictly, otherwise it will damage there products. Such as no food or drink, no photo, no mobile phone, no make up and so on at the production line. Fortunately, i no need to work at the line, some rules were no need to follow at the office. (So it was the only chance that the engineer girl will have a better look than the real sao-rong-ngan. lol) You might think, ooohh, it was so long day here. Actually, here they allowed the employee to take a break for 3 times!, morning break, lunch and afternoon break. Woo, that was strange! (but my previous workplace was not that strick, I can take a break anytime I want. As long as I send them the work on time ;P).
I might say, working here was so technical work. It was my interested field of work! Working at lab and experiment in the company! wow! I just wonder, if I'm not the student, is there any chance to work like this?
Enjoy!, Patama R.

Monday, June 11, 2012

Halcon realtime

Hi, this is going to be my second week working at semi-conductor industrial factory. My work is quite interested, I have to develop machine vision measuring system using Halcon vision software and visual c#. Actually, the workers in team already have the knowledge about machine vision, they just need a programmer who can build the application file for them using c#. So they asked me to join.
Just wow for the equipment they provided for the trainee student.
my computer and lab camera

The following video is showing the measurement of angle rotation for the wafer using Halcon.  At first, they already have a program that can measure the angle of the wafer but it cannot use in realtime. So I have to edit and make it run as an application for the real machine. Actually, before I finished my work today I already finished implement with C# but I'm afraid to make a video at that time because many people in the team came and saw the progress at my table.

PS. I don't know how to stop capturing in C# if someone know the solution please contact me. T^T
PS2. I don't know if it going to be illegal to record and share the video or not but it was my program (LOL).


Wednesday, May 30, 2012

Change or Die

I just resigned from my work at KMUTT library last month (The end of April) because I need to continue my Master's Degree by join the internship for at least 4 months. I worked almost one and a half year here. There are many things that made me improve my skill for both human relation and technical skill.
My previous works are related to Education Development. As KMUTT is university of technology, so we try to use and develop our own learning community system.
My last project here was called "KMUTT Cluster for Education Development (C4ED)". KMUTT Education Development Structure response to the commitment to quality, we focus on the educational system, framework, process and people to bring about innovative learning solution that remain relevant and responsive in changing times. To sum up, we try to improve our teaching and learning method by provide training, support or related development activities for student and teacher, designed the course, the curriculum for student (KMUTT QF) and try to encouraged everyone to be our part.
As a programmer here, our team did the research about the curriculum for Engineering study, how IT media can improve the learning, develop our own Learning Management System and any thing related to technology including build up the public relation website or Facebook Fan page. I made some video for introduce the LMS, you can see from my previous blog (with tag: Learning Environment). The last event was called "Change or Die". We organize this event for introduce the alternative way to use technology for learning, show the teacher about student views, discuss about how we can improve our learning. I didn't join the seminar, I was just a staff. In this event, we showed how we can use technology for learning by using gadget so I reposed to install learning application for Android.
As I told you that I have made some video for this project, so when I saw myself here, I was so embarrassed.
The photo is from this video: http://www.youtube.com/watch?v=UkLMjQjNgig
Board presentation
C4ED website: http://www.c4ed.kmutt.ac.th/