Home 寫程式SDK, Framework and Library

SDK, Framework and Library

by 艾普利

Photo by Safar Safarov on Unsplash

前些日子突然和同事聊起了 SDK、Framework 和 Library 差別在哪裡?

就我所知 SDK 包含了一堆東西,UI、function …等等,就範圍來說是最大的,Framework 和 Library 很像,都是有一些funcation 可以讓開發人員呼叫。

嗯…感覺好像不是很清楚,還記得以前有找過資料,但是後來都忘記了,想說正好有個機會重新再把這三個東西了解更多一點

SDK

SDK(Software Development Kit) 軟體開發套件,感覺只要有帶 Kit 這個字的總是有一群東西…

A software development kit (SDK) is a collection of software development tools in one installable package. They facilitate the creation of applications by having a compiler, debugger and sometimes a software framework. They are normally specific to a hardware platform and operating system combination. To create applications with advanced functionalities such as advertisements, push notifications,etc; most application software developers use specific software development kits.

Wikipedia

SDK 除了包含 Framework 外還有compiler、 debugger。

舉例的話,對開發者來說,我們常常在工作時說的 iOS 就是一個 SDK,iOS SDK 提供 iOS App 的開發環境,當然要透過 Xcode 這個IDE (integrated development environment)工具來開發,同理也有 Android SDK。

這和使用者常常指的iOS 不一樣,iPhone 的iOS 是 Operating Systems 是負責管理App的系統,不要搞錯了喔~


Framework

Framework 就如其名,是一個框架,一個package

Software framework is an abstraction in which software, providing generic functionality, can be selectively changed by additional user-written code, thus providing application-specific software. It provides a standard way to build and deploy applications and is a universal, reusable software environment that provides particular functionality as part of a larger software platform to facilitate the development of software applications, products and solutions.

Wikipedia

Framework 基本上提供了許多可以幫助你完成應用程式的一些元件。

舉例來說,SwiftUI & UIKit 它們都是Framework ,它們提供了很多 UI 相關框架(元件)讓開發者只需要加上一些程式碼就可以完成畫面,至於像是 Text 是怎麼處理多語系與字型、List 是怎麼讓畫面可以下拉更新,這些都不需要開發者處理。


Library

Library 就是一堆函式的集合,最早在學習 C++ 的時候就知道的名詞

Library is a collection of non-volatile resources used by computer programs, often for software development. These may include configuration data, documentation, help data, message templates, pre-written code and subroutines, classes, values or type specifications.

Wikipedia

Library … 嗯…看來就是一堆可以提供你呼叫用的function、class、 data ,這個就有點難舉例了…


Library vs Framework

說起來其實 Library 和 Framework 很像,上網找了一下多數說二者之間的差別在於 Inversion of Control

Library 的話,開發者可以呼叫 Library 裡的 function 做一些處理,最後會得到結果,然後再由開發者決定要做些什麼處理,控制權是在開發者手上的

You own the control

Framework提供了框架並擁有內建行為,開發者可以依照Framework 提供的框架,填入一些程式碼,讓 Framework 來幫你處理後面的事情,你只需要在框架指定的地方寫上程式碼就行了,控制權反而是在 Framework 手上,這種情況就稱為 Inversion of Control

The framework calls you

總結

SDK : 包含 Libraries、Frameworks、Tools、Documentation ,所表示的概念比較大範圍

Framework: 提供框架(包含現成可用的程式),呼叫時通常只需要再寫上一些程式碼即可,控制權是屬於 Framework的

Library: 提供可讓開發者呼叫的 function、data、class…等,控制權是屬於開發者的

最後照慣例祝大家 Coding 愉快!!

You may also like