206 lines
6 KiB
Text
206 lines
6 KiB
Text
<!--
|
||
The FreeBSD Documentation Project
|
||
|
||
$FreeBSD$
|
||
Original revision: 1.18
|
||
-->
|
||
|
||
<chapter id="introduction">
|
||
<chapterinfo>
|
||
<authorgroup>
|
||
<author>
|
||
<firstname>Murray</firstname>
|
||
<surname>Stokely</surname>
|
||
<contrib>Contributed by </contrib>
|
||
</author>
|
||
<author>
|
||
<firstname>Jeroen</firstname>
|
||
<surname>Ruigrok van der Werven</surname>
|
||
</author>
|
||
</authorgroup>
|
||
</chapterinfo>
|
||
<title>簡介</title>
|
||
|
||
<sect1 id="introduction-devel">
|
||
<title>在 FreeBSD 開發程式</title>
|
||
<para>好了我們開始吧!我想你的 FreeBSD 已經安裝好了,而且已經準備好要用它寫點程式了吧?
|
||
但是要從哪裡開始呢?&os; 有提供寫程式的程式或環境嗎?
|
||
身為 programer 的我可以做什麼呢?</para>
|
||
|
||
<para>本章試著回答你一些問題,當然,單就 programming 程度來說可分很多種層次,
|
||
有的人只是單純當興趣,有的則是他的專業,
|
||
本章主要內容是針對程式初學者,
|
||
當然,對於那些不熟 &os; 的程式開發者而言,本文件內容也是十分實用的。</para>
|
||
</sect1>
|
||
|
||
<sect1 id="introduction-bsdvision">
|
||
<title>The BSD Vision</title>
|
||
|
||
<para>為了讓你寫出來的程式在 &unix; like系統上具有良好的使用性、效能和穩定性,
|
||
我們必須跟你介紹一些程式概念(original software tools ideology)。 </para>
|
||
</sect1>
|
||
|
||
<sect1 id="introduction-archguide">
|
||
<title>程式架構指南</title>
|
||
|
||
<para>我們想介紹的概念如下</para>
|
||
|
||
<itemizedlist>
|
||
|
||
<listitem><para>在整個程式還沒寫完前,不要增加新的功能。</para></listitem>
|
||
|
||
<listitem><para>另外一個重點就是,讓你自己選擇你的程式將會具有何種功能,
|
||
而不是讓別人決定,不想要去滿足全世界的需求,除非你想讓你的程式具有擴充性或相容性。</para></listitem>
|
||
|
||
<listitem><para>千萬記住:在沒有相關經驗時,參考範例程式碼所寫出來的程式,
|
||
會比自己憑空寫出來的好。</para></listitem>
|
||
|
||
<listitem><para>當你寫的程式沒辦法完全解決問題時,最好的方法就是不要試著要去解決它。</para></listitem>
|
||
|
||
<listitem><para>若用 10% 的心力就能輕鬆完成 90% 的工作份量,就用這個簡單法子吧。</para></listitem>
|
||
|
||
<listitem><para>盡可能地簡化問題的複雜。</para></listitem>
|
||
|
||
<listitem><para>提供機制(mechanism),而非原則(policy)。
|
||
比方說,把使用者介面選擇權交由使用者來決定。</para></listitem>
|
||
|
||
</itemizedlist>
|
||
|
||
<para>以上摘自 Scheifler & Gettys 的 "X Window System" 論文</para>
|
||
|
||
</sect1>
|
||
|
||
<sect1 id="introduction-layout">
|
||
<title><filename class="directory">/usr/src</filename> 的架構</title>
|
||
|
||
<para>完整的 FreeBSD 原始碼都在公開的 CVS repository 中。
|
||
通常 FreeBSD 原始碼都會裝在 <filename class="directory">/usr/src</filename>,
|
||
而且包含下列子目錄:</para>
|
||
|
||
<para>
|
||
<informaltable frame="none" pgwide="1">
|
||
<tgroup cols="2">
|
||
<thead>
|
||
<row>
|
||
<entry>Directory</entry>
|
||
<entry>Description</entry>
|
||
</row>
|
||
</thead>
|
||
|
||
<tbody>
|
||
<row>
|
||
<entry><filename class="directory">bin/</filename></entry>
|
||
<entry>Source for files in
|
||
<filename>/bin</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">contrib/</filename></entry>
|
||
<entry>Source for files from contributed software.</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">crypto/</filename></entry>
|
||
<entry>Cryptographical sources</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">etc/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/etc</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">games/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/games</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">gnu/</filename></entry>
|
||
<entry>Utilities covered by the GNU Public License</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">include/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/include</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename
|
||
class="directory">kerberos5/</filename></entry>
|
||
<entry>Source for Kerberos version 5</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">lib/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/lib</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">libexec/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/libexec</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename
|
||
class="directory">release/</filename></entry>
|
||
<entry>Files required to produce a FreeBSD release</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">rescue/</filename></entry>
|
||
<entry>Build system for the
|
||
<filename class="directory">/rescue</filename> utilities</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">sbin/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/sbin</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">secure/</filename></entry>
|
||
<entry>FreeSec sources</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">share/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/share</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">sys/</filename></entry>
|
||
<entry>Kernel source files</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename class="directory">tools/</filename></entry>
|
||
<entry>Tools used for maintenance and testing of
|
||
FreeBSD</entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename
|
||
class="directory">usr.bin/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/bin</filename></entry>
|
||
</row>
|
||
|
||
<row>
|
||
<entry><filename
|
||
class="directory">usr.sbin/</filename></entry>
|
||
<entry>Source for files in <filename
|
||
class="directory">/usr/sbin</filename></entry>
|
||
</row>
|
||
</tbody>
|
||
</tgroup>
|
||
</informaltable>
|
||
</para>
|
||
</sect1>
|
||
</chapter>
|