Thursday, August 5, 2010

My Love Story

Linh & Danh

Love at first sight

We found each other about 4~5 years ago through the introduction of our friend Duc. When we first met, I thought she is older than me due to the thick make up on her face. But she is actually 7 years younger. Well, she thought that I was Duc's boyfriend. Duc is gay!

The next day, we went to Vung Tau beach with my staffs. We stayed there for 3 days. We had so much fun. I still remembered the way she looks in the white dress. On special occasions, I asked her to put on that dress. The dress is still around but its hasn't been worn for years.

We started living together after about 1 month. Linh was 41 kg. After 3 months, she gained about 6 kg. That's why she could not wear that memorial white dress. Well, she wore that dress when she dropped a few kilos. However, I might not be able to see that innocent look again.

Happiness

During the first few months, we enjoyed every moment together. We went shopping, dinning on daily basis. We went to Vung Tau again with a gay couple. They made us laugh every second. We never will forget them!

We traveled to many tourist attraction places like Da Lat, Nha Trang, Vung Tau, Phan Thiet, Mui Ne. Occasionally, I took Linh to Dong Nai, my home town. We had a lot of fun with my little cousins. There were so many of them.

Unfortunately, we do not have pictures of the gay couple. These pictures illustrated some of our happy moments:

Thung Lung Tinh Yeu (Love Valley), Da Lat.
Linh is leading. My brothers Hoa and Cong at the back.
Me on horseback.
I fell off the horse a few times in my life because I always going fast.
Vinpearl, Nha Trang. Left to right Me, Linh, Cong, Hoa.
Hoa is my youngest brother, his first time in Vietnam.
Vinpearl, Nha Trang. Linh putting sun screen on for me.
My uncle Samson from Australia next to Linh on the left.
We went to our home town to visit our relatives. 


Thailand 

On May 2008, my younger sister (Rachel) went to Vietnam. We went to Thailand altogether for 6 days tour. The happiest moments together were the Tiffany show and other gay shows. Those shows were unbelievable. Just amazing!

On the last day of the tour, we went shopping for at least 10 continuous hours. Actually, there were clear tasks for each of us. My partner and sister responsible for shopping. I do the paying and carrying. I could see people on the street sympathized for me. I must be carried approximately 10 kg at the end of the day.

And this is all I got from the trip, a couple t-shirt:

This photo was taken on the Boat Restaurant, Bach Dang, Vietnam.
That magnet couple t-shirt was the only thing I got from Thailand tour.
Safari, Thailand. That's little tiger was cute.
My sister Giang (Rachel).

Accident

One mid-night, while I was working. My mobile phone rang. A complete stranger informed me that my partner was in Saigon hospital. I rushed to the hospital, seeing my love crying, lying on the bed with blood all over her face and body. She was half dead. Doctors and nurses were at the desk chatting and doing nothing! Absolutely nothing! I paid for the services, then they started cutting her cloths. They could not take it off naturally.

I wish we both in Australia. We would have much better services. Anyway, we moved to Cho Ray hospital the next day because they could not do anything here.

Cho Ray Hospital

I could not believe that they arranged my partner to share a standard hospital bed with another unnown patient. I told them that I want a better paid service. They told me that all better services were booked out.

Now, I better take it or leave it! At that time, I didn't know of any other hospitals. I had to accept the offer before they are putting us on the floor.

While they were moving us to the room, I tried to locate the person in charge of the hospital beds. I found her and explain our situation, I was almost cry. I think she could felt what I had been through. We finally get our own bed in a better room.

For one whole day, I didn't see any doctor doing any analysis. This is wrong! My partner was in pain, constantly shaking and I do not see any body here doing anything. That night, I called my best friend's Tai in Australia to get his brother Dr. Hop number. Hop is a practitioner in Vietnam, I went to his house at about 7~8PM with the X-Ray of my partner's skull. I didn't know why the hospital gave me the X-Ray! This is insane, I am not a doctor. I could remember clearly because of the heavy rain that night. I was all wet like a dog!

Unfortunately, Dr. Hop did not specialize in face and road accident. Nonetheless, he introduced me to doctor Cuong. He analyzed the X-Ray and told me that there were 2 broken bones on her face:
  1. A broken jaw.
  2. A tiny bone near her nose. Nothing can be done as it was located underneath the face bone.
I informed Dr. Cuong that I already contacted the Australian embassy to arrange medical treatment in Australia for my partner. He insisted there shouldn't be any problem with the operation here. Well, I trusted his judgement. In fact, taking my partner to Australia would required a lot of paperworks. It would takes months. Perhaps, it could not be done because of the way the Vietnamese government system works. 

The next morning, a doctor came to the room. He asked: 
Who's the family member of Dr. Cuong here?
Almost everything flowed quite nicely thereafter. Blankets and bedsheets were changed quite often. 

Change another hospital

Later that day, we were informed that this Hospital cannot do anything as the injuries were face related. They asked us to move to another hospital. I called Dr. Cuong, he told me that he already arranged us to Rang Ham Mat (Teeth Jaw Face) hospital tomorrow. I didn't know what to do but wait for further advices. 

At 10 AM on the third day, Linh was asked to take blood sample. They took 10 cc of her blood. She was in serious pain, every movement would caused tear drop on her cheeks and shattered my heart. The procedures were as follow:
  1. Nurse informed Linh to take blood sample.
  2. I went from level 7 to ground floor to do the payment for taking blood sample. I used the staircases as there were too much people waiting for lift. It would be much faster.
  3. A nurse and I help Linh sit on the wheel chair. We moved to ground zero, wait in the long queue for about 30~45 minutes. 
  4. Thanks god! Tran Ai Linh was called. They took 10 cc of her blood. In case you don't know 1 cc = 1 ml. Therefore, they took about 10 ml. 
  5. I asked the nurse why taking so much, she told me it's for sample test. But Linh would be transferred to another hospital at 2PM today. She said: I don't know
  6. We moved all the way back to level 7 again, on lift!
Later that day, I found out that they took the patients' blood and sell to other patients. I could never ever thought of this in my entire life. Well, it's happening right here in Vietnam. I strongly believed they were taking patients' blood to sell because no results were sent to any other hospital and they knew that we would be leaving later that day. 
We hope that no internal organs are missing.
My first time on Ambulance 

Again, we had to do the payment before booking the ambulance. I had to hold on to the receipt. Otherwise, we have to pay again. 

I think the driver was insane! We were not in a hurry. But he turned on the siren and drove like F1 drivers. He went real fast through a lot of bumps and holes on the road. 

Anyway, nobody was hurt except my partner constantly crying as she swung left, right, up, down along with the motion of the ambulance. 

Rang Ham Mat Hospital

This hospital is a little bit more civilized. The procedures were as follow:
  1. Take a ticket
  2. Wait for your number
  3. Pay, keep receipt
  4. Move to your room
At the other hospital, you wait in the line. No ticket queueing system. There would be a lot of people trying to push in. 

As soon as we visit the hospital, people knew that we were family member of Dr. Hien Duc. Thanks God! The relationships were arranged by Dr. Cuong. The flowed was quite smooth. 

I believed it was Friday, Linh met a few room mates of similar situation. It turned out, all of them were here as a result of motorbike accident. They could hardly talk, but all seemed to understand each other.

Here are some of the pictures. I took these photos because I need to send these pics to my mum for doctor advices in Australia.

One broken jaw and another broken bone near the nose.
This look much better than the first day.
Imagine a bed like that with 2 people.
Scars are still on both of her arms.
Her legs took the longest time to heal.
There are still big noticeable scars her foot.
After 2 years, all the wounds are healed.
Linh's legs still hurt occasionally. I don't know why!
I still could not understand why she got the injury on the inner thigh.
Operation

The following Monday, Linh had an operation by Dr. Hien Duc. I heard that she is the best surgery doctor in the hospital.  She was very nice. She advised us what to prepare before and after the operation. My main tasks were:
  1. Pay for the operation.
  2. Buy the titanium plates for connecting the broken jaw.
  3. Buy milk for Linh to drink after the operation.
  4. Buy some other medicines I couldn't recalled.
The operation went well. Linh was transferred to the resting room. She slept most of the time there. If I remember correctly, I had to constantly applied ice pad to the operated area for two days. I think this would minimize the bleeding and pain.

Blended congee for 2 months

Linh's mouth was sealed after the operation. Her teeth were tied together to prevent movement of the jaws. Everyday, Linh's could only eat blended food. She didn't even have the energy to suck it. I constantly whispered on her ears:
If you love me, you must eat. You must eat a lot as well. You need food and minerals to repair your body. Otherwise, we would have to be in the hospital for a very long time.
The congee at the hospital wasn't soft enough. It could not get through her teeth. I had to bring our own fruit blender from home. I bought it a while ago for Linh on our anniversary. Anyway, her main course meal was blended congee. To be exact, these were the daily diet:
  • 3 x Ensure Milk Can
  • 6 x Bowl of congee 
  • 1 x Glass of orange juice
  • 1 x Glass of grape juice or apple juice
Because Linh's couldn't feed herself, I feed her using the following procedures:
  1. Linh laid on the bed.
  2. I raised her back about 45 degrees angle.
  3. I used the big syringe: 
  4. Suck the blended congee.
  5. Pump it into her mouth.  
  6. Naturally, the blended congee would flow to the mouth, down the throat through the gaps on her teeth.
My partner consumed the food this way for the entire month in the hospital. During this time, I contacted my mum from Australia to buy us medicines for scar treatment. Those medicines were amazing, Linh still using it everyday since the last 2 years.

Family and Friends

Linh has a lot of visitors during the first week. I saw many of her friends cried. These visitors were very important for her. They were great supporters. Nonetheless, only a few came back on the second weeks. I, Linh's mother and her step father were around most of the time. I visited Linh everyday. Occasionally, I slept most of the time on my visit. I knew that I couldn't do much, but my presence would encourage Linh to recover much faster.

Home sweet home

Linh was really strong. I wonder how she could consume a lot of the same food every single day. She left the hospital earlier than her room mates even though their injuries were not as serious.

Anyway, we were informed by Dr. Hien Duc that her mouth would be sealed for at least another month. That's mean another month of blended congee. At least, it would be much better than staying at the hospital.

Seal removed

A month later, the seal was removed. He mouth was full of blood after removing the seal. We were advice that she could only consume soft food. Well, anything should taste good now. So it doesn't really matter.

Lost sense

Linh's told me that she lost the sense on lips and chin a while ago after the accident. Occasionally, Linh unintentionally bit her lips whilst eating because she could not feel it. We contacted Dr. Hien Duc, she advised:
This is normal. Some nerves were cut during the operation. But they will reconnect later.
Thanks God! After about a year, her sense fully recovered. That's better. I didn't feel like kissing the living dead lips.

Pregnancy 

Last week, I was informed by Linh that I will be dad. I was so happy. The sort feeling that could not be expressed. We lost a pregnancy once. I fear that it could happen again.

I didn't want Linh to get pregnant for years. The reason was we both not ready yet. I was a youth social worker in Australia whilst doing University degree. I think I knew what children really need. This is what ready really mean from my point of view:
  • Must be able to spend at least 30 minutes a day with my child for at least the first 7 years. This is the most important period of the development of the brain of children.
  • Take a walk with my wife 30 minutes daily after dinner during the pregnancy period.
  • Must do more research about the psychology of kids. 
We both trying to be ready now. I already quited my current job in Vietnam. I'll get another as soon as I go back to Australia. The environment in Australia is much better than Vietnam. It should be number one in the world. I made a commitment to myself that I will not work as hard as I did during the past years. My family is much more important. I would do the best I could for my wife and my child.

Our story is endless. Yet, I have a feeling it has just begun.

Preparing to go to Australia

In order to provide our kid the best possible life, we have to go to Australia. The following picture story will illustrate what we have done so far: 

Requirement Elicitations
Cong is doing the statutory declaration.
Linh writing our story history from her aspect.   
I went to  my friend office in the Suh Wah Tower to get him to do the
statutory declaration. Giang is the Director of Vina Security.
He got his own lawyer which can be the prescribed person for
the statutory declaration. Very convenience for us.
Cong help us finding the old images on his laptop.
OMG, there are over 5,500 of them in an unordered list.
I have to preview every single one of them.
Linh continue writing her story. She is very slow.
Well, she is pregnant. I don't want to put to much pressure on her.
I was playing with the remote control of the camera.
Finally, I got it working.
Now, I can take pictures of us without the help from other people.
Getting the document verified, certified in Australia is easy. In contrast, it's the pain in the ass to get any document certified in Vietnam. Here is one of our experience. Criminal record for Linh is required by the department of immigration of Australia, we went to the local police station where Linh lived many years ago. We must do the paperwork there even if it's thousands of miles away!  A cop informed us:
The person in charged is on vacation. He will be back next week.
I wondered if I am in the 21st century. We asked for the form, they didn't even have it. There is no such form. We went back home to ask the local cop I know. He showed us how to write it. We got it done. we went back to the other police station to hand in the application. One of the cop questioned:
Is this how the application must be done?
Every form or application must goes through the cops. If cops doesn't know how to do it, what do they expect from people like us.

For every form, we must go back and forth at least 3 times. This is how you do it in Vietnam:
  1. Buy the form from the local police station, if the have it. Otherwise, you must write your own in the correct way. 
  2. Complete the form. Hand it in. They will tell you when you can pick it up. They will not inform you if they have not complete it. You have to go there to find out!
  3. Pick up your form.
Well, we got most if not all of the required documents done. We are ready to go now!

Saturday, July 17, 2010

InnoDB crash recovery after power failure

On the Friday, 16th July 2010. There was a power outage at our data center in LA. After power is restored, MySQL service refused to start. I checked the error log and realized InnoDB has been crashed.
 
  1. The first thing I do is copy the raw database file as backup before doing anything:
    sudo cp -R /var/lib/mysql /var/lib/mysql-crash
     
  2. Edit the MySQL configuration file:
    sudo vi /etc/mysql/my.cnf
  3. Insert the following line in [mysqld] section to force InnoDB recovery mode:
    innodb_force_recovery = 1

    From MySQL manual:
If you are able to dump your tables with an option value of at most 4, then you are relatively safe that only some data on corrupt individual pages is lost.
I tried from mode 1 to 4, but MySQL service refused to start. That's mean I have to accept some losses. I tried mode 5 (SRV_FORCE_NO_UNDO_LOG_SCAN), still no luck. This make me really worry as mode 6 is the last option. If MySQL service doesn't start my last option would be restored yesterday's backup.

Thanks God! Mode 6 (SRV_FORCE_NO_LOG_REDO) works! MySQL service started! Nonetheless, I couldn't query any InnoDb table. Every time  I do, I got this error:
Lost connection to MySQL server during query (XXXX)
When I tried to use mysqldump, I got the following error:
Couldn't execute 'show table status like '__session'': Lost connection to MySQL server during query (XXXX)
I tried to ignore the __session table, but the next table came up with the same problem and so on.

It took me hours to look for solutions on the Internet. Again, the best solution was restore from backup. Another solutions is restore InnoDB from only an .ibd file. Solution from www.chriscalender.com would work well if I enable innodb_file_per_table option. This allowed each InnoDB table to have its own tablespace like MyISAM storage engine. There would be an .ibd file created for every InnoDB table. But it's too late now. I can still extract the data from the .ibd raw file, but it would cost me a lot of time and effort.

I almost gave up!

Until now, I still don't know what made me change the recovery mode to 1 and restart MySQL service. Eureka, MySQL server restarted without any error.

Now, I backup all databases using the following command:
mysqldump --routines --triggers --single-transaction --quick -uroot -p --all-databases > all-dbs-100716.sql

In order to restore, I shutdown MySQL service and renamed the crashed database datadir. I installed the new database structure and restored everything back to just before the crashed using the following commands:
sudo mysql_install_db
mysql -uroot mysql < all-dbs-100716.sql

Thanks God! After the investigation, the corrupted table was __session. Our PHP session data are stored in the database to enable session between sub-domain. Some data from this table is lost, but it doesn't matter at all.

Here are some lessons learned:
  1. Enable innodb_file_per_table. In the worst scenario, we can restore InnoDB from only an .ibd file.
  2. It's good that we backup our database daily. Here is a simple command which can be executed from cron job:
    mysqldump --routines --triggers --single-transaction --quick -uroot -pXXX database-name | gzip -9 > database-name-$(date +%F).sql.gz
  3. Change the InnoDB recovery mode from 1 to 6. If you cannot dump the databases, change back to mode 1. It might work! At least in our case. We already replicate the test with another server with the same crashed data.
  4. When doing the recovery, change MySQL port to any other port instead of 3306. This make sure that all other services cannot access MySQL. No DELETE/UPDATE/INSERT statements can be performed in recovery mode. But it doesn't hurt to take extra precautions.
  5. innodb_log_file_size is recommended to be about 25% of system RAM. Personally, I think this only apply to smaller/older server with less than 4GB RAM. In my case, I have innodb_log_file_size = 1GB even though my system have 16GB RAM. I don't think log file bigger than 1GB will do any benefit. However, setting the right figure would greatly reduce the insert and recovery time by at least 10 folds. Our database is about 2GB with more than 10 millions records. The default innodb_log_file_size is 5MB, which would takes forever to restore. I will do a test on this for the exact figures.
I am glad that I went through all these troubles. My old man told me over and over again that no pain, no gain!

Tuesday, July 13, 2010

Installing Zend Debugger for Ubuntu

I am still seeing so many people using var_dump(). I think most of us spend more than 50% of our time debugging. There is no excuse for investing some time for a better debugging tool. This guide will show you how to configure Zend Debugger for Zend Studio under Ubuntu.

Requirements:
  • Zend Studio 7.x.x
  • Firefox with Zend Studio toolbar
Assumptions:
  • You are using Linux Ubuntu distribution. Other Linux distribution should be similar.
  • You must already have Zend Studio installed.
You need the ZendDebugger.so extension loaded in order to enable Zend Debugger. This PHP extension comes with Zend Studio.

Finding ZendDebugger.so
If Zend Studio is installed, you can locate ZendDebugger.so as follow:
  1. sudo updatedb
    Update the database of all the files and directories in our system. This command should be run by the cron job everyday. You may omit this step unless Zend Studio is newly installed.
  2. locate ZendDebugger.so
    Find the exact path to ZendDebugger.so
Expected results:
/home/user/Zend/ZendStudio-7.2.1/plugins/org.zend.php.debug.debugger.linux.x86_5.3.7.v20100625/resources/php5/ZendDebugger.so
/home/user/Zend/ZendStudio-7.2.1/plugins/org.zend.php.debug.debugger.linux.x86_5.3.7.v20100625/resources/php53/ZendDebugger.so
Load ZendDebugger.so extension
I do not recommend editing the php.ini file as we can easily create a mess in there. Instead, we should create a new configuration file under /etc/php5/conf.d directory. All configuration files end with ini under that directory will be loaded every time PHP execution is called. We can easily maintain our configuration that way:
sudo cat > /etc/php5/conf.d/zend_debugger.ini
Paste from command line (ctrl+shift+v):
zend_extension=/full/path/to/ZendDebugger.so
zend_debugger.allow_hosts=127.0.0.1, 192.168.0.1/16
zend_debugger.expose_remotely=always
done with ctrl+c.
zend_debugger.allow_hosts - which hosts allowed to debug, separated by comma.
zend_debugger.expose_remotely - telling the web browser that Zend Debugger is enable on this server.

If you are using PHP 5.3, you must use .../php53/ZendDebugger.so. Otherwise, use .../php5/ZendDebugger.so.


Restart apache server:
sudo service apaches restart
Hopefully, there is no error. Otherwise, check the path to your ZendDebugger.so or the version of ZendDebugger.so you are loading. Most of the problem occur there.

Confirm Zend Debugger is installed
Create a test page as follow:
cat > test.php
Paste from command line (ctrl+shift+v):
<?php
echo phpinfo();
done with ctrl+c.
If you see the following image, your Zend Debugger is successfully configured on your server. In my case, it's just my personal laptop.


Let's debug...
Open Firefox with Zend Studio toolbar, go to your website click on the Debug button as show below:



Enjoy! But please remember, It is twice as difficult to debug a program as to write it. Therefore, if you put all of your creativity and effort into writing the program, you are not smart enough to debug it.
Anonymous
Enhanced by Zemanta

Saturday, July 10, 2010

Vietnam - 4. Simplifying

How do I simplify the following problems?
Super long functions
Make staffs understand that ONE function should do ONE and only ONE specific task! Normally, the a function should contain no more than 20 LOC for our PHP web projects, excluding comments and line separators. Unless, it's a controller function.

Big fat controllers
To simplify the project, we should keep the controller skin, model fat!
Why? All the logics are in the controller, we shouldn't make it more complicated than it should be!

Logics found in the views
All the logics should be in the controller. The purpose of the view is displaying the data. The decoration should be in the CSS. Sound simple, but making all staffs understand this concept is not as simple as it should be. I need to give them concrete examples.

Zend_Form not being used
Most of our staffs do not understand Zend_Form. They think it's too complicated. I have to show them a concrete example of Zend_Form. The code from controller has been reduce from about 100 LOC to about 20 LOC.
Here are some features from Zend_Form:
  • Has a lot of built in validators. Can validate number, string, phone number, credit card...
  • Separate the code from HTML
  • Can be decorated with Zend_Decorator
  • Reusable code
  • Easier to debug
Zend_Form is quite complex, example and documentation can be found here:
http://akrabat.com/php/simple-zend_form-example/
http://framework.zend.com/manual/en/zend.form.html

Variable name has no meaning
This is very hard to simplify! One simple rule is no abbreviation.
As most of the data type we are dealing with are string, number, array, Zend_Db_Table_Row, Zend_Db_Table_Rowset, therefore, I defined the following rules for our developers:
  • Zend_Db_Table_Row - variable must end with Row. E.g.: $userRow
  • Zend_Db_Table_Rowset - variable must end with Rowset. E.g.: $userRowset
  • Array - we use plural to indicate array or self-describing name. E.g.: $userRows, $usernames, $userProfile
  • String - normal variable name. E.g.: $username, $firstName,...
  • Number - normal variable name. E.g.: $userAge, $earning,...
The most important concept I've taught our staffs about naming convention are:
  • Variable/Class names should be noun unless you have a good reason for it not to be noun.
  • Function names must be verb.
  • Always use self-describing names.
  • Never use shortcut.
English is a second language for our developers, therefore, we have to limit the vocabularies being used.
  • All functions return a boolean must start with is, has, can.
  • Function start with set accepts only ONE input parameter. E.g.: setEmail($email), setAge($age), setPassword($password)...
  • Function start with update accepts an array as input parameter. E.g.: updateUserProfile($userProfile), updatePostalAddress($postalAddress), updateCreditCardInfos($creditCardInfos)...
  • We have a lot of problems with naming the action controller. Here are some examples of inconsistency: getUsersAction, listUsersAction, showUsersAction,... I forced all developers to name it show. In fact, any action name from controller that involve displaying data must be started with show. Similar for edit/update/change & delete/remove/del & add/insert/insert-new/new...
Magic numbers
Magic numbers can be eliminated by moving to a constant file.

Global variables
Global variables can be used but it need to be well explained & self-describing. However, we should try to minimize the use of global variables.

It cost me a lot of time to put our staffs on track. Here are some fundamental rules for my staffs:
  • All functions must have comments and @author.
  • Global variables must have comments.
  • Write short simple functions.
  • No magic numbers.
  • Variable and function names must be self-described.
  • No abbreviation.
  • If you think that section of code you've wrote is complex, then it is! Find a way to simplify it.
Everything should be made as simple as possible, but not simpler. Albert Einstein.

    Wednesday, July 7, 2010

    Vietnam - 3. Welcome to the real world

    Please check my previous post if you haven't read it Standardizing.

    After a few lectures about standardizing, simplifying, planning... Our staffs start working on the new project. I am quite busy designing other system whilst taking care of the servers. I let the staff work alone for one whole week!

    Week 1:
    Objective: Get the job done using the standards.

    Results:
    I expect the front end of the site to be completed. Yes, it is! I tested the site and found a few bugs. I dug into the code to fix it. Omg, I cannot believe that I could not understand what's going on! Here are some of the problems found:
    1. Big fat controllers
    2. Logic found in views
    3. Models not being used much
    4. Zend_Form is not used at all
    5. Only a handful number of functions is found
    6. Variable name has no meaning
    7. LOOP in LOOP in LOOP
    8. Hardly see any comment
    9. Global variables are widely used
    10. Magic numbers everywhere
    I decided to inspect the CSS code, I found the following problems:
    1. Inline style everywhere
    2. ID selectors are widely used instead of class selectors
    3. Many ID selectors having the same name
    4. Normalization not being used
    5. Short hand not being use much
    6. Magic numbers everywhere, they are not even nice number. Imo, nice number are number that easy to remember and can divide many other numbers. Odd number should be avoided. 
    The biggest problem is none of the standards specified is followed.

    Well, one thing I cannot deny is they work hard and willing to learn. Remember, professionals built the Titanic, amateurs built Noah's Ark.

    Monday, July 5, 2010

    Vietnam - 2. Standardizing

    Existing Office
    There isn't any problem with setting up the office Vietnam as we already have an existing office with about 20 CSR. The CSR are working around the clock. We moved in, share the existing facilities.

    SVN & Linux
    Initially, I setup the subversion and local development environment. As a Linux geek, I forced everyone to use Linux, Ubuntu distribution. I don't see the need for Windows at all. Here are some reasons I think Linux is better. At least for our PHP developers.
    • Free, easy to install
    • No drivers needed
    • Haven't got any complaint from our staffs about virus
    • Represent our server environment
    • Staffs cannot do much beside working
    • The list is endless...
    There are many cases you need Windows. Please do not argue here as I don't want to end up fighting the never ending war between Windows and Linux.

    Coding Standard
    I divided the coding standard to 3 sections:
    1. PHP - Most of our web projects are based on the Zend Framework. Hence, we use the Zend Framework coding standard.
    2. Database - Coding standard for SQL is a little bit tricky. I couldn't find any standard that suit our needs. I have to invent my own standard. Here are some guidelines:


      • Database name: lowercase, usually project name
      • Table name: plural, uppercase first letter, then CamelCase. Only the last word is plural. E.g.: UserProfiles
      • Reference table name: we use the word Maps to indicate. E.g.: UserGroupMaps
      • Field name: singular, uppercase first letter, then CamelCase. E.g.: FirstName, UserId
      • Primary key: should be the singular table name follow by Id. E.g.: UserId
      • Avoid using `-` and spaces
      • All table, field, functions, triggers, stored procedure names should be as meaningful as possible.
      • Never use abbreviation. Some people understand others don't, so avoid using it.
      • SQL keywords must be CAPITALIZED
    3. CSS - All our web projects are using jQuery extensively and we are planning to keep it that way. jQuery/UI using hyphen `-` as word separator for CSS, we will stick with it. The key is making the class name as meaningful as possible.
    The key here is to make everyone using the same simple standard. Talking the same language. Thinking of the same concept.

    I long know simplicity is the key! Can I simplify it?

    Friday, July 2, 2010

    Vietnam - 1. Outsourcing

    After working as a CTO (I considered myself more like a System Designer) for a small telco Filanity Corp. for 6 months. I realized the importance of outsourcing.

    Our head office is located in Huntington Beach, California. However, we'd like to reduce the software development cost. I recruited a team of 10 developers in Vietnam.
    • 1 x HTML/CSS/Photoshop Designer
    • 1 x Photoshop/Flash Designer/Developer
    • 8 x PHP Developers
    I've live in Australia for almost 20 years. However, my Vietnamese is pretty good. There isn't any problem communicating with the Vietnamese developers.

    The cost for the developers has been reduced significantly. A senior PHP developers would only cost us about $500 USD/month.

    When hiring people in Vietnam, the following issues should be considered:
    • Extremely hard to get Linux programmer.
    • Spaghetti code.
    • "Instant noodle" code. Most programmers are trained for that purpose. Most of the projects they've done are small projects. No maintenance is required.
    • They can get the tasks done, but other people or teammate cannot understand.
    • Don't be surprised if you see function with more than 100 lines of complex code.
    • Wheels will be reinvented, many are not even round!
    Well, they are quite smart. They just need to be trained!

    After all, practice made perfect! Actually, only perfect practice made perfect!