[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]

Ideally, duplicated code leads to maintenance nightmare. So, Not-allowing-duplicated-code always seems to be better. But, in this article, I want to say that in some cases, code-duplication needs to be allowed.

In practice, lots of people who has different ability work together in one source code branch. In this case, if code duplication is not allowed, all developer should search all sources to find the reusable module. Let's image that there are thousands modules. Finding appropriate module is not easy. And lots of people try to customize(modify) the module for easy-reuse. If all engineers are enough good at programming and enough time to consider code quality then we don't need to worry about "customization". But, it cannot be in some cases - especially, product development. Skill level of engineers are always various and they are always pushed by project schedule. So, the shared module tends to become worse and worse in terms of its quality. (It's normal in large-size-project).

Here is merits of allowing code duplication.(There are lots of well-known-disadvantage of allowing code duplication. So, let's talk about only "Merits".)
  * There is no dependency among people. So, it's very easy to work in parallel.
  * Merging is easy, because of no-dependency and no-conflicts.
  * Bug from mistake affects only limited area. So, detecting issued part is easy.

So, practically, we need to consider what should be reused(shared) and what shouldn't.

Here is my opinion about this.
Codes that should not be duplicated.
  - codes for interface with external modules.(In App. point of view, OS, filesystem and so on can be external modules)
  - codes that are used very frequently. (ex. code for getting lengh of string. - strlen)
  - stable codes.
  - ... (anything else???)

Codes that can be duplicated.
  - parts that should be done in parallel with tight schedule and enough human resources.
  - codes that are customized very often.
  - ... (anything else???)

Hmm... I need further study...

[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]

큰 팀이 project를 할 경우, 팀내 개발자 각각의 local환경이 서로 틀려서, 문제가 생길때가 많다. ("나는 build가 잘 되는데, 너는 왜 안되느냐?" 등). 그래서 보통의 경우, 같은 project를 하는 사람들끼리는 개발환경을 통일하는 경우가 많고, 이런 개발환경에 대한 script file또한 형상관리의 대상이 되는 경우가 일반적이다. 환경을 통일하기 위해서는 각 개인의 Local환경을 공통 환경으로 Mapping시켜 주는 일이 필요한데, 보통의 경우, 환경 변수, Virtual Drive 등이 쓰인다.

예를 들면,
- 개발 root directory는 "P:\project"로 한다. => Virtual drive를 이용.
- project build directory는 %MY_PRJ%\%PRODUCT_NAME%으로 한다. 등등

그런데, 개발환경이란, 비단, file path, 개발 tool의 path, 환경 변수의 차이 등을 의미하는 것 만이 아니다. source code editor도 주요한 개발환경이라고 할 수 있다.

어느 한 'A'라는 editor에서 개발한 사람이 줄을 잘 맞추어서 정돈된 코드를 만들었다고 하자, 이 코드가 'B'라는 editor에서는, 'tab size의 차이', 'font의 width'차이 등으로 인하여 무질서 하게 보이는 경우가 허다하다. 즉, 'A'라는 editor를 기준으로한 code beautify는 'B'라는 editor에서는 무의미할 수도 있다는 말이다.
그런데 문제는 다른 개발 환경과는 달리, code editor는 개발자들에게 '통일'을 강조하기 어려운 면이 있다는 것이다. 왜냐하면, 개발자들이 다년간 사용한 editor를 바꾸게 된다면, 한동안 새로운 editor에 익숙해 지기까지 꽤나 긴 시간동안 생산성이 크게 떨어질 뿐만 아니라, 개발자 개개인의 커다란 반발을 살 가능성도 농후하기 때문이다.

따라서 차선책으로, editor 환경을 통일시키게 된다. 개개인 개발할 때는 임의의 editor환경을 사용해도 좋지만, code branch에 'submit'한다던가, 'check in'할 경우는 반드시 통일된 editor환경에서 beautify된 코드를 사용하도록 해야 한다. (사실 매번 submit혹은 check in할때마다 이런 작업을 해야 한다면, 개발자들은 차라리, editor환경을 여기에 맞추게 된다. editor환경을 바꾸는 일은 editor자체를 바꾸는 것보다는 수월하며, 또 반발 또한 작다. 왜냐하면, 이것은 editor 자체를 바꾸라는 것 보다는 당위성이 충분하기 때문이다.)
code editor 환경의 예를 들면 다음과 같은 것이 있다. (너무 복잡한 규정은 잘 지켜지지도 않고, 반발만 살 수 있음을 명심해야 한다.)

- tab은 space replacement로 하되 size 4로 한다.
- 줄바꿈은 Unix style(LF)를 따른다.
- ... etc..

[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]

It seems obvious that hardware specific software should be layered with unified interface.
This is very important to portability and debugging. In addition, this can help simulate hardware functionality in other platform - desktop PC. This is something like "Porting to PC". Programming and debugging on PC platform can increase productivity very much. Can you understand how important this is?
(Please refer "Linux" device driver interface. This is very good example!)

[[ blog 이사 과정에서 정확한 posting날짜가 분실됨. 년도와 분기 정도는 맞지 않을까? ]]
 

((To avoid misunderstanding) I am also application engineer.)
Application engineer tends to ignore HW characteristics. But, without HW, SW is useless. Even application engineer in embedded software, would better to know basic stuffs about low-layer. Here are some examples about considering these low-layer characteristics. These examples are to appeal to application engineer.

* Each assembly code line may spend different number of CPU clocks. So, counting assembly code line is useless to check CPU performance.
* Optimized code for "2 CPU + 1RAM" is totally different from the one for "2 CPU + 2 RAM for each". Besides, DMA, Bus arbiter etc may also affect to code.
* In some cases, using compressed data is faster than uncompressed one. For example, using highly-compressed-RLE data on the platform which has very-fast-CPU but slow NVRAM. In this case, dominate factor of performance is "performance of accessing NVRAM". So, compressed data has advantage on this. Besides, overhead for uncompress is very low in case of RLE.

Point in here is, "In embedded environment, even application engineer needs to know about it's HW platform where software runs on."

+ Recent posts