Difference between a module, library and a framework

前端 未结 9 1564
走了就别回头了
走了就别回头了 2020-12-07 07:13

In popular programming speak, what is the difference between these terms and what are the overlaps?

Any related terms I\'m missing out?

9条回答
  •  忘掉有多难
    2020-12-07 07:51

    My ASCII art interpretation of what I understood from other answers:

    +-----------------------------------------------+
    |  ...........................  ..............  |
    |  : f1() f2()  :  f3()      :  : f4() f5()  :  |
    |  :            :            :  :            :  |
    |  : l1_module1 : l1_module2 :  : l2_module3 :  |
    |  :            :            :  :            :  |
    |  --library1-----------------  --library2----  |
    |                                               |
    |   application.c                               |
    |                                               |
    |       #include l1_module2                     |
    |       #include l2_module3                     |
    |                                               |
    |       int main() {                            |
    |           # case 'reload'                     |
    |           f5();                               |
    |           # case 'start'                      |
    |           f1();                               |
    |           # case 'stop'                       |
    |           f4();                               |
    |       }                                       |
    |                                               |
    +-----------------------------------------------+
    
    .................................................
    : FRAMEWORK_X                                   :
    :                                               :
    :     application start                         :
    :     ...                                       :
    :     application reload                        :
    :     application stop                          :
    :     ...                                       :
    :...............................................:
    

    What happens:

    1. Developer installs library1 and library2 so that they can use functions provided inside modules of these.

    2. They then include l1_module1 and l2_module3. (They do not need l1_module2 for now).

    3. Now they can use the functionality of f1, f2, f4 and f5, So they write their application.

    4. Now, since they want to use the application inside some FRAMEWORK_X, they must implement the interface that this framework needs: so that the framework can call the application.

    Some notes:

    • In practice, there is always some framework. For example, the OS is framework for your application (which is why you define main())! Or you could say that the bootloader is framework for your OS and the BIOS is framework for your bootloader etc.

提交回复
热议问题