1. 到了新公司,他繼續完善了這個程序
==> He has NO right to 繼續完善了這個程序. Period.
原公司 can sue 他.
2. There is No such things as 獨立開發, or 程序開發並不是他的正職.
He did the job on his company's machine, it belongs to the company.
3. If your 朋友給 his manager 所有源代碼 and the manager knows
part of the codes was developed before your 朋友 joined the new company,
then 原公司 can sue 新公司.
even his new manager does not know the developement process,
原公司 can ask 新公司 to pay fee for using the codes.
4. your 朋友 has NO 知識產權 for any of the codes. The best he can do
is become the inventor of the codes, but still not the owner.