문제

According to Wikipedia, Eric S. Raymond said that one of the 17 Rules of Unix is the "Rule of Generation", stating that:

Developers should avoid writing code by hand and instead write abstract high-level programs that generate code. This rule aims to reduce human errors and save time.

How is this rule to be interpreted in a modern context of languages that abstract away memory management (ex. Java's GC) or other low level bit-twiddling tasks? Does this rule still apply?

도움이 되었습니까?

해결책

He doesn't mean little IDE utilities that create boilerplate for you, which you must modify. He's referring to more comprehensive code generation that you shouldn't have to touch. You make changes to the higher level and regenerate.

The canonical Unix example would be Yacc, which uses a high-level grammar to generate complex parsing code. Other examples:

  • An SQL query.
  • A domain-specific language, like many web frameworks use for route handling.
  • A GUI builder.

The basic idea is to write in as high an abstraction level as possible, as close to the natural representation as possible.

다른 팁

In “modern” C++, the manta “don’t write code — use algorithms.” is the same general idea. The “generation” is done with templates and reuse, so you don’t touch manual looping and elementary code slogging.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 softwareengineering.stackexchange
scroll top