Wrapper
母语的写作功能,其唯一目的是在外部图书馆中指定这些功能。 目标是尽可能少用母语。 例如,将数据类型从母语翻译成外部图书馆语言等。
当外部图书馆:
- written in a more efficient language than the native code (eg, a C++ library called from Python)
- large/complex and would be time-consuming or error prone to translate
- regularly updated; in a well-maintained library the interfaces (what your wrapper is concerned with) will change less often than the implementation of the features; so if you have wrappers around the functionality, updating to a new version of the library should be fairly straightforward
Porting
港口只是从一种语言翻译成另一种语言。 总的说来,尽可能维持同样的逻辑。
港口在下述情况下具有意义:
- the native language is more efficient than the external library
- the library is simple and one wants to save on the overhead involved with wrapping
- one intends to make and maintain changes to the ported code in the native language
- there are no plans to use the external library in its own language
- one wants to learn one or both of the languages involved
Re-Write
想把重温成一个港口,有许多令人振奋。 目标是利用当地语言的特点,以某种方式改进图书馆(效率、可读性等)。
重新计算在港口的所有相同情况下都是有意义的。 决定是否建造一个简单的港口或完全翻新,通常会成为一个问题:
- Is there a better way to implement the features of the external library in the native language?