資料來源:http://blog.ponyfoo.com/2014/01/20/how-to-design-great-programs
- 做好一件事
- 提供良好API介面
- ```README``導向開發
- Open Source
- 撰寫測試
If your design has a single goal, then it will be that much easier to make it into a reusable component which you can utilize across projects, and maybe even open-source if you feel so inclined. One of the features of developing open-source software is that you force your programs into focused things. You or others can benefit from that reusability in other projects. Developing open-source projects also forces you to document the API, helping you think about the purpose of each API member.
偉大程式都是單一目的設計。如果設計成單一目的,容易打造可重用的元件,也許你會想要open source。開發open source軟體特色之一,是你可以提高你的程式成為焦點,你或其他人可以從可重用性(reusability)專案獲益。開放open source專案也強迫你去撰寫API文件,幫助思考每個API之目的。
Let us define API interfaces as a consumer-facing interface for a component, regardless of transport. An API might be any of:
-
The methods exported by a JavaScript package
-
Those exposed by a module in that package
-
The CLI interface to a command-line program
-
REST API endpoints provided by a web application
-
由JavaScript套件匯出方法
-
透過套件模組接觸
-
CLI作為命令式程式介面
-
Web應用程式提供REST API端點
I find that these translate quite nicely to human interaction design as well, and I find that I treat both with the same kind of respect more and more, even if I strive to meet different goals in each case. Design the interface as if consumers didn't have a clue about your code. They really don't. Most people won't even look at the code you write, and thus the interface should be intuitive and easy to use. Similarly, it should be documented well enough that people don't have a reason to look at your code. I'll add more thoughts on documentation in the next section.