规范3
目录文档 所有的目录下都需要具有README文档,其中包括: 该目录的功能及其包含内容 一个对每一文件的在线说明(带有link),每一个说明通常还应该提取文件标头的一些属性名字。 包括设置、使用说明 指导人民如何连接相关资源: 源文件索引 在线文档 纸文档 设计文档 其他对读者有帮助的东西 考虑一下,当每个原有的工程人员走了,在6个月之内来的一个新人,那个孤独受惊吓的探险者通过整个 工程的源代码目录树,阅读说明文件,源文件的标头说明等等做为地图,他应该有能力穿越整个工程。 -------------------------------------------------------------------------------- Use a Design Notation and Process Programmers need to have a common language for talking about coding, designs, and the software process in general. This is critical to project success. Any project brings together people of widely varying skills, knowledge, and experience. Even if everyone on a project is a genius you will still fail because people will endlessly talk past each other because there is no common language and processes binding the project together. All youll get is massive fights, burnout, and little progress. If you send your group to training they may not come back seasoned experts but at least your group will all be on the same page; a team. There are many popular methodologies out there. The point is to do some research, pick a method, train your people on it, and use it. Take a look at the top of this page for links to various methodologies. You may find the CRC (class responsibility cards) approach to teasing out a design useful. Many others have. It is an informal approach encouraging team cooperation and focusing on objects doing things rather than objects having attributes. Theres even a whole book on it: Using CRC Cards by Nancy M. Wilkinson. -------------------------------------------------------------------------------- Using Use Cases A use case is a generic description of an entire transaction involving several objects. A use case can also describe the behaviour of a set of objects, such as an organization. A use case model thus presents a collection of use cases and is typically used to specify the behavior of a whole application system together with one or more external actors that interact with the system. An individual use case may have a name (although it is typically not a simple name). Its meaning is often written as an informal text description of the external actors and the sequences of events between objects that make up the transaction. Use cases can include other use cases as part of their behaviour. Requirements Capture Use cases attempt to capture the requirements for a system in an understandable form. The idea is by running through a set of use case we can verify that the system is doing what it should be doing. Have as many use cases as needed to describe what a system needs to accomplish. The Process Start by understanding the system you are trying to build. Create a set of use cases describing how the system is to be used by all its different audiences. Create a class and object model for the system. Run through all the use cases to make sure your model can handle all the cases. Update your model and create new use cases as necessary. -------------------------------------------------------------------------------- Open/Closed Principle The Open/Closed principle states a class must be open and closed where: open means a class has the ability to be extended. closed means a class is closed for modifications other than extension. The idea is once a class has been approved for use having gone through code reviews, unit tests, and other qualifying procedures, you dont want to change the class very much, just extend it. The Open/Closed principle is a pitch for stability. A system is extended by adding new code not by changing already working code. Programmers often dont feel comfortable changing old code because it works! This principle just gives you an academic sounding justification for your fears :-) In practice the Open/Closed principle simply means making good use of our old friends abstraction and polymorphism. Abstraction to factor out common processes and ideas. Inheritance to create an interface that must be adhered to by derived classes. -------------------------------------------------------------------------------- Design by Contract The idea of design by contract is strongly related to LSP . A contract is a formal statement of what to expect from another party. In this case the contract is between pieces of code. An object and/or method states that it does X and you are supposed to believe it. For example, when you ask an object for its volume thats what you should get. And because volume is a verifiable attribute of a thing you could run a series of checks to verify volume is correct, that is, it satisfies its contract. The contract is enforced in languages like Eiffel by pre and post condition statements that are actually part of the language. In other languages a bit of faith is needed. Design by contract when coupled with language based verification mechanisms is a very powerful idea. It makes programming more like assembling specd parts. -------------------------------------------------------------------------------- 其他杂项 这一部分包含着各种各样的该做的和不该做的。 在需要用到离散的数值使,不要使用浮点数变量。采用浮点数来做循环计数器无异于向自己的脚 开枪。测试浮点数时总要使用 ,永远不要用 = 或 => 。 不要使用程序自动美化器,得益于好的程序样式的主要的人就是程序员自己,特别是刚开着手代 码、算法设计的程序员,使用程序自动美化器仅仅能根据语法来更正程序,因此当对空白和缩进 的注意有很大需要时,它是不可能做到的。正常的细心注意细节的程序员们能很好的用清晰直观 的样式来完成一个函数或文件(换句话来说,一些直观的样式是意向的规定而不是程序自动美化 器能读懂的智慧)。马虎的程序员应该学习细致的程序员,不要依赖程序自动美化器来增加程序 的可读性。最初的美化器是必须分析源代码的程序,复杂的美化器不值得通过这样获得好处,美 化器最好用于生成总的机器建立(machine-generated)格式代码。 对逻辑表达式第二个 = 不小心的忽略是一个问题,以下显得混乱而且更像是错误: if ($abool= $bbool) { ... } 程序员在这里真的是要赋值么?一般常常是,但通常又不是这样。这样避免引起这样的混乱呢?解 决方案就是不要这样做,利用显式和隐式的判断测试,推荐的方法是在做测试前先做赋值: $abool= $bbool; if ($abool) { ... } -------------------------------------------------------------------------------- 使用if (0)来注释外部代码块 有时需要注释大段的测试代码,最简单的方法就是使用if (0)块: function example() { great looking code if (0) { lots of code } more code } 你不能使用/**/,因为注释内部不能包含注释,而大段的程序中可以包含注释,不是么? -------------------------------------------------------------------------------- Different Accessor Styles Why Accessors? Access methods provide access to the physical or logical attributes of an object. We disallow direct access to attributes to break dependencies, the reason we do most things. Directly accessing an attribute exposes implementation details about the object. To see why ask yourself: What if the object decided to provide the attribute in a way other than physical containment? What if it had to do a database lookup for the attribute? What if a different object now contained the attribute? If any of the above changed code would break. An object makes a contract with the user to provide access to a particular attribute; it should not promise how it gets those attributes. Accessing a physical attribute makes such a promise. Implementing Accessors There are three major idioms for creating accessors. Get/Set class X { function GetAge() { return $this->mAge; } function SetAge($age) { $mAge= $age; } var $mAge; } One Method Name class X { function Age() { return $mAge; } function Age($age) { $mAge= $age; } var $mAge; } Similar to Get/Set but cleaner. Use this approach when not using the Attributes as Objects approach. Attributes as Objects class X { function Age() { return $mAge; } function rAge() { return &$mAge; } function Name() { return mName; } function rN

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

メモ帳++7.3.1
使いやすく無料のコードエディター

SublimeText3 中国語版
中国語版、とても使いやすい

ゼンドスタジオ 13.0.1
強力な PHP 統合開発環境

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SublimeText3 Mac版
神レベルのコード編集ソフト(SublimeText3)

ホットトピック

vivox100s と x100 携帯電話はどちらも vivo の携帯電話製品ラインの代表的なモデルであり、それぞれ異なる時代における vivo のハイエンド技術レベルを代表するものであるため、2 つの携帯電話にはデザイン、性能、機能に一定の違いがあります。この記事では、消費者が自分に合った携帯電話をより適切に選択できるように、これら 2 つの携帯電話を性能比較と機能分析の観点から詳しく比較します。まずはvivox100sとx100の性能比較を見てみましょう。 vivox100s には最新の機能が搭載されています。

インターネットの急速な発展に伴い、セルフメディアという概念が人々の心に深く根付いてきました。では、セルフメディアとは一体何でしょうか?その主な特徴と機能は何ですか?次に、これらの問題を 1 つずつ検討していきます。 1. セルフメディアとは何ですか? We-media は、その名前が示すように、あなたがメディアであることを意味します。これは、個人またはチームがインターネット プラットフォームを通じてコンテンツを独自に作成、編集、公開、配布できる情報媒体を指します。新聞、テレビ、ラジオなどの従来のメディアとは異なり、セルフメディアはよりインタラクティブでパーソナライズされており、誰もが情報の制作者および発信者になることができます。 2. セルフメディアの主な特徴と機能は何ですか? 1. 敷居が低い: セルフメディアの台頭により、メディア業界への参入の敷居が低くなり、煩わしい機材や専門チームは必要なくなりました。

小紅書が若者の間で人気になるにつれ、ますます多くの人がこのプラットフォームを使用して、自分の経験や人生の洞察のさまざまな側面を共有し始めています。複数の小紅書アカウントを効果的に管理する方法が重要な問題となっています。この記事では、Xiaohongshu アカウント管理ソフトウェアの機能のいくつかについて説明し、Xiaohongshu アカウントをより適切に管理する方法を探ります。ソーシャルメディアが成長するにつれて、多くの人が複数のソーシャルアカウントを管理する必要があることに気づきます。これは小紅書ユーザーにとっても課題です。小紅書アカウント管理ソフトウェアの中には、コンテンツの自動公開、スケジュールされた公開、データ分析、その他の機能など、ユーザーが複数のアカウントをより簡単に管理できるようにするものがあります。これらのツールを通じて、ユーザーはアカウントをより効率的に管理し、アカウントの露出と注目を高めることができます。さらに、Xiaohongshu アカウント管理ソフトウェアには、

PHP は、Web 開発で広く使用されているサーバー側スクリプト言語です。その主な機能は、動的な Web コンテンツを生成することです。HTML と組み合わせると、リッチでカラフルな Web ページを作成できます。 PHP は強力で、さまざまなデータベース操作、ファイル操作、フォーム処理、その他のタスクを実行でき、Web サイトに強力な対話性と機能を提供します。次の記事では、詳細なコード例を使用して、PHP の役割と機能をさらに詳しく説明します。まず、PHP の一般的な使用法である動的な Web ページの生成を見てみましょう: P

WeChat Reading App のモバイル版は非常に優れた読書ソフトウェアです。このソフトウェアにはたくさんの書籍や作品が含まれています。ワンクリックでオンラインで検索して読むだけでいつでもどこでも読むことができます。すべて公式に認可されており、異なります。本の種類もきれいに並べられており、ゆっくりと本を読みながら快適に読書を楽しむことができます。さまざまなシナリオの読書モードを切り替え、書籍の最新章を毎日継続的に更新し、複数のデバイスからのオンライン ログインをサポートし、本棚への一括ダウンロードをサポートします。インターネットの有無にかかわらず読むことができるため、誰もがそこからより多くの知識を発見できます編集者がオンラインで詳細を説明 WeChat 読書パートナー向けにカタログの閲覧方法を宣伝します。 1. カタログを表示したい本を開き、本の中央をクリックします。 2. 左下隅にある三本線のアイコンをクリックします。 3. ポップアップ ウィンドウで書籍カタログを表示します。

Word ドキュメントは、日常の仕事や勉強で最も頻繁に使用されるアプリケーションの 1 つです。ドキュメントを扱うとき、2 ページを 1 つに結合する必要がある状況に遭遇することがあります。この記事では、読者が文書レイアウトをより効率的に扱えるように、Word 文書内の 2 ページを 1 ページに結合する方法を詳しく紹介します。 Word 文書では、用紙や印刷コストを節約したり、文書をよりコンパクトに整頓したりするために、2 ページを 1 つに結合する操作が通常使用されます。 2 つのページを 1 つに結合する具体的な手順は次のとおりです。 ステップ 1: 操作する必要がある Word を開きます。

「VSCode について: このツールは何に使用されますか?」 》初心者でも経験豊富な開発者でも、プログラマーとしてはコード編集ツールを使わずにはいられません。数ある編集ツールの中でも、Visual Studio Code (略して VSCode) は、オープンソースで軽量かつ強力なコード エディターとして開発者の間で非常に人気があります。では、VSCode は正確に何に使用されるのでしょうか?この記事では、VSCode の機能と使用法を詳しく説明し、読者に役立つ具体的なコード例を提供します。

IDE を使用して Go 関数のドキュメントを表示する: 関数名の上にカーソルを置きます。ホットキーを押します (GoLand: Ctrl+Q; VSCode: GoExtensionPack をインストールした後、F1 キーを押して「Go:ShowDocumentation」を選択します)。
