Research, Dev, Share

Moving My Blog

Posted in Software Development by Khang Vo on March 21, 2011

Hi all,

I finished all my blogs/posts/comments to my new blog: vodkhang.com

Please visit me at that address

Thanks for following my blog

Advertisements

Freelancer Lessons and Strategies

Posted in Career, Freelance, Learning, Management, Programming Language, Software Development by Khang Vo on January 23, 2011
freelancer jobs

freelancer jobs

As my plan in Adelaide, I want to get some job to earn money as well as keep me up to date with industry technologies. However, this turns out to be much harder than I believe when Adelaide is such a small city that does not have many IT companies here.
Then, I started my second option in my plan to looking for freelancer jobs and going to websites that offer freelancer jobs to see what I can get from there, and things are growing up fast enough and I learnt some key lessons over the my new job.

 

Price

Price was my first concern over deals and bid to get accepted a project. However, I can see that most of times, price is not the top priority for employers. What they care is they can have a high quality product in a short amount of time with a reasonable price. My strategy is to pick a fixed hourly rate for myself when competing and then just calculating over the number of hours I need to work and give them a general price.
I try to convince people about quality, in many terms: communication and product. I think it is true for any work with clients to try to exceed their expectations, try to understand their problems well and do exactly what solves their problems. The price can be higher but we can save time, money and make people feel safe, they would hire us. So, don’t aim for only price. Put one that is reasonable and prove clients that it is worth every penny

Outsourcing

This is always a way to cut down the business cost. People hire me because they want to look for more reasonable price with the same quality. And I can make another step to outsource them back to Vietnam developers. It cut down the price for me and the client and I can save my time to more important jobs, such as studying in my university 🙂 (Supposed to be the most important one)

There are certainly more aspects about management when you have to do outsource and communication with customers when both of these are remote only. I don’t forget about technology lessons that I learnt and expect to learn and work over these freelancer works. These will be shared on the next entry.

References:

Image source: http://freelancejobfeed.blogspot.com/

Why should we join and support community?

Posted in Community, Competition, Learning, Open Source by Khang Vo on January 15, 2011

There are always people keep asking me the same question: “Why do I actively join free community like Stackoverflow/BarcampSaigon/MobileDevCamp/My Blog/Top Coder? What is the value and the benefit?”. It is nice that people ask this question and actually think about it. And I hope that I can answer them fully with this post somehow.


vodkhang on stackoverflow

1/ Fun.

It is fun. Really? Yeah, it is actually fun. Wait a little bit, why is it fun for working? I love playing game, I love to see my level going up and my mark changes everyday, I love beating the top challenging problem. It is just so fun there. If you still suspect this for somehow, I would rather ask you why you play football and play guitar in the church outside of working time. If you think this is not a good example because people don’t have headache over those things, then we take a look at some others. Do you play chess? Why do people play chess and what is the value and benefit when playing chess? If you can figure out the answer at this point of time, then we are done. It is fun, that should be it.

At this point of time, if you still don’t feel anything fun to do so, I don’t know if you should continue reading about other benefits: brand advertising, learning and contributing. If you don’t get fun out of the work, especially the overtime work, it is hard to persuade the goal just by other visible benefits. Moreover, these benefits are only long-term seeing and require lots efforts and time.

2/ Brand Advertising/Social Networking & Trust.

Brand Advertising and Social Networking is important. When you actively join communities, you get to know more people and more people get to know about you. Nobody knows if these people turn out to be your next employer or your next friend that can help you out in the difficult situations.

I partly believe in the theory that sometimes, we should hire people that we are familiar and can trust rather than hiring some talented stranger. So, when people can see how you engage to help the community, people started to trust you. The more people know about you, the more people may trust you. And when people can trust you, they can give you the chance to work together or hire you as an employee or even work for you.

Moreover, these things are not built overnight, there is no overnight success. It may take you couple of months, or even years to write a blog and only your friends read it. It is the same with answering on stackoverflow, topcoder. It takes years for you to reach to an acceptable point that people start to recognize your name/your company’s name.

3/ Learning & Contributing.

Open Source

Now, we go to the last reason. It is the last not because it is the least important reason, it may be the most important reason for many people. However, many people want to see the something visible, something that either gives them lots of money or reputation to move forward to their career first. So, I just leave them read things they want to read first.

It is so obvious. When you answer something in stackoverflow, it is either help you to solid your knowledge or help you to think deeply to debug. I really like debugging on stackoverflow, it is challenging. You have to find the bug as soon as possible, and sometimes, you don’t have debugger, you don’t even have IDE to help you. You just read over the code, verify each line of the code and try your best to guess the part that can create the bug. That’s challenging and fun, actually.

References:

http://iphonedevelopment.blogspot.com/2010/12/non-deterministic-problems-aka-finding.html

Image Sources:

http://stackoverflow.com/users/flair/227698.png

http://en.flossmanuals.net/floss/publish/WordPress/rsrc/WordPress/Introduction/icon_big.png

http://t0.gstatic.com/images?q=tbn:ANd9GcQj7UR1webcv1NlEzFaRpAUeudZjWyOYYAA27iiaxot4X9vdDa2

Applyzer – more statistics for iPhone Apps

Posted in Iphone, Statistics by Khang Vo on December 19, 2010

 


Review example from Good Reader

Review example from Good Reader

Just a quick note and introduction over Applyzer : a website that gather all reviews from all countries and rankings of your app in those countries. This is a good thing because iTune does not allow you to view all reviews at the same time and switching the country is so painful that nobody will ever do it. The ranking is also good that let you decide to focus on some countries rather than others if your app requires a little bit localization

 

Windows Phone 7 v.s iPhone Presentation in Barcampsaigon

Posted in C#, Iphone, Objective-C, Software Development, Windows Phone by Khang Vo on December 12, 2010
Windows Phone 7 and iPhone Presentation

Windows Phone 7 and iPhone Presentation

Here is my presentation with Nghia Dang on the topic comparing the differences between Windows Phone 7 and iPhone Development. I share it here for others who cannot come. Contact me (vodkhang@gmail.com) or Nghia (nghiadang@kms-technology.com) if you have any questions:

Kms-Technology

Property, Synthesize and Dealloc – Code Generation

Posted in Iphone, Objective-C, Software Development by Khang Vo on November 25, 2010

This is my new generation script, mainly copied from here with some improvements to meet my needs:

– Change the dealloc to [self.variable release] instead of [self.variable dealloc];
– Change the @outlet variable to check for the “UI” prefix rather than letting it put IBOutlet everywhere or I have to use 2 scripts at the same time.
– Add some of my own into the assign list

XCode Code Generation

The second one is not a perfect solution for IBOutlet but considering that it doesn’t harm much except let some annoying IBOutlet out.

Twitter: XAuth + Sharing

Posted in Iphone, Open Source, Software Development, Twitter by Khang Vo on October 31, 2010

Showing a place for logging and sharing a tweet in Twitter with my new library. You now can use XAuth without even understanding about how it works and you also have a nice facebook-style pop up.

For details about XAuth and how to use the XAuth functions, you can follow this link: Aralbalkan’s blog and his feather apps.

For showing a Twitter Pop up Dialog, I appreciate the effort of DDSocialDialog and the quick image is like this:

DDSocialDialog for Twitter

My Career – A year look back and fro

Posted in Career, Intelligent System, Iphone, Software Development, Usability by Khang Vo on October 25, 2010

vodkhang's career stepIt has been almost one year from my first full time job day (4/11) and since that day I have learnt a lot of things and sharing lots of things in my blog, stackoverflow, facebook and twitter. I will try to summarize and make a general view for my career in the last year.

Web Development
My first work is Scala researching – a still hot technology and growing quickly until now.

Although currently, I do not work much in Web Development, but I will try, for sure, come back to this field again. Why? My vision about this field is still hot, highest and most challenging technology for scalable system is still here with the born of lots of things like Cloud Computing, Google App Engine, Scala, Ruby and Clojure. Maybe my next programming language for the web is Ruby. I already have the intention to jump into here. Hope that my colleagues in KMS can help me to catch up this technology fast.

The good thing about Web Development now is that we have Google App Engine and some App Store for the web is growing. With the born of Cloud OS which will happen soon, I hope that I will have the time and chance to come back, either individually or as a developer in the company.

Artificial Intelligence
This area is cool by its name and it is part of a reason I went to Melbourne last year. I had chance to work full time on it and even it was not a success, I learnt a lot from it. What I think is that I will try to focus on Computer Vision and Machine Learning (and may be Agent system) with the intention to apply them into iPhone someday. Why is iPhone? Because I still need to do something with commercial purpose and dealing with iPhone will at least give me some financial benefit in short term. And with iPhone and client technology, I don’t have to deal with massive amount of database problem which I have no chance to practice.

Related to Artificial Intelligence, I intended to take Phd from years ago. However, my decision now is something industry oriented rather than academic environment. I appreciate the academic environment, which is good to work and learn what you like but for now, I think I do not prefer it.

Mobile Development

I came to this area by luck, I didn’t really intend to jump into. iPhone programming is cool by its design, working in limited environment and dealing with memory management. There is another challenge for building iPhone app for me is how to make it the best for user, in other terms, usability.

I learnt lots of things about usability over last few months after reading some books: “Don’t make me think” and “User Interaction Design”. This viewpoint is a little bit from a designer’s perspective rather than a developer’s one. This is cool and make me understand more about users. To be honest, before I do iphone development, I am scared of designing (both in terms of graphics and interaction) and I don’t get love in it. But now, I think I can do at least interaction design well.

Other stuff
Working in iPhone let me have time to learn something else that I am scared about. Git in terminal for example. I am scared of terminal and scripting and all those administration stuff before. I am also trying to do a lot of testing in iPhone, from UI Automation Testing to Unit Testing which make me fall in love. I love the Google Testing Blog’s Term: “If it ain’t broke, you’re not trying hard enough”. Now, I feel so bad for anytime I cannot make a software crashed :). It is also good that I am still looking forward to improving my productivity day by day, automation process, hot keys and dual monitor was what I achieved. The next stuff will be emacs, for example.

My current love in technology can be said: “user, automate and scale”.

PS: To be honest, I hope that this is the first time I can focus 150% into working and researching. For the whole last year, I had to spend so much time in university assignments, exams and then GRE. Those things do not just take off my time but also kill my energy and passion so fast, while those things are either not challenging, boring or just I do not love it.

Become Master of XCode (part 2)

Posted in Objective-C, Software Development by Khang Vo on September 27, 2010

I recommend you to have some few experience with XCode before trying to touch some of the techniques here, especially code generation because it may contain subtle bugs and if you are just a newbie, it is not easy to solve. You may also want to take a look at my first part: Become Master of XCode
Many of the techniques are learnt from “Becoming productive in XCode”

3/ Code Generation Scripting

The most common and boring problem that iPhone developers usually have is writing again and again: private instance variable, @property, @synthesize and then dealloc. It is not just boring but also easy to make mistake. Currently, I found that there is a useful way for developers to generate all @property, @synthesize and dealloc based on the instance variable.

Go into User Script, create your own group and script name:

Copy the script from Github (thanks to AllanCraig) and put into. Don’t forget your hot key to trigger the code generation. You may also need to configure the script a little bit to fit your own purpose and coding convention

4/ Code Template (Text Macros)

They have 2 main kinds of code templates: the built in text macros and your text macros:

a/ Default Text Macros:

Xcode already includes lots of text macros like: init, dealloc, fore (for each), fori (normal for loop over array). See a long list in XCode Completion Macros.

Here is the path for the built in Text Macros:

/Developer/Applications/Xcode.app/Contents/PlugIns/TextMacros.xctxtmacro/Content/Resources/

b/ Your own Text Macros:

You can put more Text Macros into Xcode by understanding and writing the Text Macros yourself. The file location for your Text Macros is: ~/Library/Application Support/Developer/Support/Xcode/Specifications

Here are some samples Text Macros that I will work through to get you the feeling of the Text Macros. I hope that after I exlain it, you can create your own.

{
  Identifier = objc.dealloc;
  BasedOn = objc;
  IsMenuItem = YES;
  Name = "Dealloc Method Definition";
  TextString = "- (void) dealloc$(BlockSeparator){\n\t<#!deallocations!#>
\n\t[super dealloc];\n}\n";
  CompletionPrefix = dealloc;
}

Identifier : the id of your method

BasedOn : the programming language of your macro. Here is objc

Name : a descriptive name

Text String: the text string will replace your Macros:

${BlockSeparator} :  the way you specify the spaces in your code, you can configure it through terminal and script

<#!deallocations!#> : a placeholder with the text deallocations.

[super dealloc]; : the text appears in your macros

5/ File and Project Templates

You can change your file and project templates, there is not much to say here. You have a built in project and file templates in:

/Developer/Platforms/iphoneOS.platform/Developer/Library/Xcode/Project Templates

/Developer/Platforms/iphoneOS.platform/Developer/Library/Xcode/File Templates

But you should create your own file and project templates in:

~/Library/Application Support/Developer/Shared/Xcode/Project Templates

~/Library/Application Support/Developer/Shared/Xcode/File Templates

You may want to copy some from the default templates and modify. The reason that you should put in your own folder is that if Xcode is upgraded, it will not delete your modification

Reference:

http://cocoawithlove.com/2008/06/hidden-xcode-build-debug-and-template.html

Become Productive in Xcode

iPhone App Performance Optimization

Posted in Algorithm, Iphone, Performance, Software Development by Khang Vo on September 13, 2010

iphone performance

Working in a power limited environment like mobile, and especially, iPhone here, we soon have to face with performance problem in many different kinds. Different than the web model where web front end (javascript) do some (usually not much) processing – also browsers support you a lot, iPhone native application usually has to do quite a lot of processing.

Image Source

For iPhone native app, you cannot add any hardware to help you to have better performance. The only way you can try to deal is to deal with the software code itself. I will list some few problems and solutions that I figure out these days when I really focus on optimization. The list is applicable somehow to other mobile areas like Android or limited environment like embedded device

1/ Benchmark

It is a really traditional advice, but you always have to remember to benchmark your code, even by using simple tools like NSLog or Instrument tool. You should only care about places that is slow in terms of your test rather than trying guess and error possible places.

2/ Test on iPhone device

This is another traditional advice but people usually forget. You have to test on the real iPhone device. Let me give you an example: on my iPhone simulator, a method runs within 1 second, but in my iPhone device, it takes 8 seconds, a huge difference.

So, when you test your app on the iPhone device, don’t just test for UI, memory or features that the simulator doesn’t have. Remember testing the performance as well.

3/ Multithreading and the main thread

Some people may come to you and tell you that iPhone device just has 1 core and you never need to care about multithreading. It is just WRONG.  You still need to do a lot of multithreading to reach a good level of optimization.

The main thread will do the user touch event handler and view rendering. Then, if you use the main thread for some calculation that takes a lot of time then your UI just become frozen or not smooth when you scroll.

For UI like UITableView where users scroll between many cells, the runtime will run a loop over visible cells and set the contents. Because this process runs in a row not concurrently, and it will not allow you to view or scroll the UITableView until it returns all cells, you can possibly let some of the cell content run on another thread. (more about performance on UITableViewCell part).

The other reasons for using thread are well-known, heavy IO and network processing, all of them block processing and you need thread so that your main thread is not block

But, be CAREFUL, Multithreading comes with its own disadvantages. For rendering the view, you should do it on the main thread or somtimes, your app will just crash randomly. Another traditional reason is that the CPU has to switch too much between threads and it takes more time than usual to finish a task

4/ Use Memory wisely

Some questions on stackoverflow that I sometimes see shows a scare feeling about memory. It is right that iPhone has limited memory but it doesn’t necessarily mean that you should use it as least as you can.

The right mind you need to keep is using that limited memory smartly. We all know the priority of speed is Memory > File and Local IO > Network, the fastest access is always using memory cache for the data. There are some problems for memory caching in iPhone:

    – You have to respond to 1 method in every UIViewController:  (void)didReceiveMemoryWarning. In this method, you have to smartly release some memory cache of data to reduce your memory usage. 

    – Know what/when to cache something in memory. There are lots of Caching algorithms outside from simplest ones like: Random Replacement, Least Recently Used, Most Recently Used. It is also an issue of caching big images or caching lots of small images. It all depends on your app. For my app, my main view contains lots of thumbnail images that need displaying fast and the user can wait for seeing big images. So, we cache a lot of images (60-100) for just 2 MB of memory.

5/ Algorithms and Data Structure

For my case, I didn’t really need to solve big performance issue with Algorithm and Data Structure, but in a limited environment, a small mistake may lead to a big deal and hard to detect. My case was that I need to merge 2 data arrays from the network using some unique characteristics of elements.

The app works really well in the Simulator for about 50-100 for each array (less than 0.5 second) . However, when I tested on the device, the time surprised  me, 8 seconds (16 times slower). It cost me 1 hour to detect that I use 2 for loops through 2 arrays which means O(n2), and then, I changed it to a dictionary which reduced the algorithm to O(n) and took me back to 1 second.

What I learnt here is that even we don’t ever need to deal with Massive Data, we still need to be careful about some algorithm and data structure. 50 elements are nothing in a desktop or server scale but can cause a huge issue on limited environments in iPhone. Another lesson is a remind for me that I should always test on the real device

6/ Reuse Cell (UITableViewCell)

This part is quite unique for iPhone but may be good for other people to learn. In iPhone, we have a concept of UITableView for displaying a list and a table can contain a lot of cell.

The problem is that rendering the Cell (or generally the UIView), takes lots of time and can cause the app to look like stuck when it is scrolling. Usually, if you use the default UITableViewController template, the template already gives you the code for reusing the UITableViewCell.

The only problem is when you create a custom UITableViewCell using some usual tutorials like this and this (especially using Interface Builder), they forget to tell you that setting a CellIdentifer in the UITableView is not enough to reuse a cell. What you need to do is to set it in InterfaceBuilder or write a method to return it. I know that many people will forget it and think that they still reuse the cell, but they don’t. I suffer the same problem until I did benchmark and found the problem recently.

Here are 2 good techniques:

Copied from Stackoverflow, this question:

1st way: Just implement a method with the appropriate method signature:

- (NSString *) reuseIdentifier {
  return @"myIdentifier";
}

2nd way:

How to Reuse a Cell in Interface Builder

References:

1/ Web Caching, wikipedia

2/ Web Caching, Stanley Luong’s course material

3/ Stackoverflow – reuseable Cell

4/ Stackoverflow – custom UITableViewCell