Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/freebsd-doc
Path: blob/main/documentation/content/zh-tw/books/developers-handbook/introduction/_index.adoc
18098 views
---
title: 章 1. 簡介
authors:
  - author: Murray Stokely
  - author: Jeroen Ruigrok van der Werven
prev: books/developers-handbook/parti
next: books/developers-handbook/tools
showBookMenu: true
weight: 2
params:
  path: "/books/developers-handbook/introduction/"
---

[[introduction]]
= 簡介
:doctype: book
:toc: macro
:toclevels: 1
:icons: font
:sectnums:
:sectnumlevels: 6
:sectnumoffset: 1
:partnums:
:source-highlighter: rouge
:experimental:
:images-path: books/developers-handbook/

ifdef::env-beastie[]
ifdef::backend-html5[]
:imagesdir: ../../../../images/{images-path}
endif::[]
ifndef::book[]
include::shared/authors.adoc[]
include::shared/mirrors.adoc[]
include::shared/releases.adoc[]
include::shared/attributes/attributes-{{% lang %}}.adoc[]
include::shared/{{% lang %}}/teams.adoc[]
include::shared/{{% lang %}}/mailing-lists.adoc[]
include::shared/{{% lang %}}/urls.adoc[]
toc::[]
endif::[]
ifdef::backend-pdf,backend-epub3[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]
endif::[]

ifndef::env-beastie[]
toc::[]
include::../../../../../shared/asciidoctor.adoc[]
endif::[]

[[introduction-devel]]
== 在 FreeBSD 開發程式

好了我們開始吧!我想你的 FreeBSD 已經安裝好了,而且已經準備好要用它寫點程式了吧? 但是要從哪裡開始呢? 有提供寫程式的程式或環境嗎? 身為 programer 的我可以做什麼呢?

本章試著回答你一些問題,當然,單就 programming 程度來說可分很多種層次, 有的人只是單純當興趣,有的則是他的專業, 本章主要內容是針對程式初學者, 當然,對於那些不熟 的程式開發者而言,本文件內容也是十分實用的。

[[introduction-bsdvision]]
== The BSD Vision

為了讓你寫出來的程式在 like系統上具有良好的使用性、效能和穩定性, 我們必須跟你介紹一些程式概念(original software tools ideology)。 

[[introduction-archguide]]
== 程式架構指南

我們想介紹的概念如下

* 在整個程式還沒寫完前,不要增加新的功能。
* 另外一個重點就是,讓你自己選擇你的程式將會具有何種功能, 而不是讓別人決定,不想要去滿足全世界的需求,除非你想讓你的程式具有擴充性或相容性。
* 千萬記住:在沒有相關經驗時,參考範例程式碼所寫出來的程式, 會比自己憑空寫出來的好。
* 當你寫的程式沒辦法完全解決問題時,最好的方法就是不要試著要去解決它。
* 若用 10% 的心力就能輕鬆完成 90% 的工作份量,就用這個簡單法子吧。
* 盡可能地簡化問題的複雜。
* 提供機制(mechanism),而非原則(policy)。 比方說,把使用者介面選擇權交由使用者來決定。

以上摘自 Scheifler Gettys 的 "X Window System" 論文

[[introduction-layout]]
== [.filename]#/usr/src# 的架構

完整的 FreeBSD 原始碼都在公開的 CVS repository 中。 通常 FreeBSD 原始碼都會裝在 [.filename]#/usr/src#, 而且包含下列子目錄:

[.informaltable]
[cols="1,1", frame="none", options="header"]
|===
| Directory
| Description

|[.filename]#bin/#
|Source for files in [.filename]#/bin#

|[.filename]#contrib/#
|Source for files from contributed software.

|[.filename]#crypto/#
|Cryptographical sources

|[.filename]#etc/#
|Source for files in [.filename]#/etc#

|[.filename]#games/#
|Source for files in [.filename]#/usr/games#

|[.filename]#gnu/#
|Utilities covered by the GNU Public License

|[.filename]#include/#
|Source for files in [.filename]#/usr/include#

|[.filename]#kerberos5/#
|Source for Kerberos version 5

|[.filename]#lib/#
|Source for files in [.filename]#/usr/lib#

|[.filename]#libexec/#
|Source for files in [.filename]#/usr/libexec#

|[.filename]#release/#
|Files required to produce a FreeBSD release

|[.filename]#rescue/#
|Build system for the [.filename]#/rescue# utilities

|[.filename]#sbin/#
|Source for files in [.filename]#/sbin#

|[.filename]#secure/#
|FreeSec sources

|[.filename]#share/#
|Source for files in [.filename]#/usr/share#

|[.filename]#sys/#
|Kernel source files

|[.filename]#tools/#
|Tools used for maintenance and testing of FreeBSD

|[.filename]#usr.bin/#
|Source for files in [.filename]#/usr/bin#

|[.filename]#usr.sbin/#
|Source for files in [.filename]#/usr/sbin#
|===