<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ## 第九章 The pseudocode Programming Process 偽代碼編程過程 ### Summary of Steps in Building Classes and Routines ### 創建一個類的步驟: - 創建類的總體設計 - 創建類的子程序 - 復審并測試整個類 ### 創建子程序的步驟: - 設計子程序 - 檢查設計 - 編寫子程序的代碼 - 復審并測試代碼 以上過程均是迭代進行. ### 為何使用偽代碼編程過程 ? - 用類似英語的語句來精確描述特定的操作 - 避免使用目標編程語言中的語法元素. - 在本意的層面上編寫偽代碼.用偽代碼去描述解決問題的方法的意圖,而不是去寫如何在目標語言中實現這個方法. - 在一個足夠低的層次上編寫偽代碼,以便可以近乎自動地從它生成代碼.  ### 通過偽代碼編程過程創建子程序 - 檢查先決條件 - 定義子程序要解決的問題 - 這一子程序將要隱藏的信息 - 傳給這個子程序的各項輸入. - 從該子程序得到的輸出. - 在調用程序之前確保有關的前條件成立(如輸入數據的取值位于特定范圍之內,有關的流已經初始化,文件已經打開或者關閉,緩沖區已經填滿或清空等) - 在子程序將控制權交回到調用程序之前,確保其后條件的成立(如輸出數據位于特定范圍之內,流已經初始化,文件已經打開或者關閉,緩沖區已填滿或清空等). - 為子程序命名. - 決定如何測試子程序. - 在標準庫中搜尋可用的功能. - 考慮錯誤處理. - 考慮效率問題. - 研究算法和數據類型. - 編寫偽代碼. - 考慮數據. - 檢查偽代碼. - 在偽代碼中實驗一些想法, 留下最好的想法(迭代進行). ### 編寫子程序的代碼 : - 從偽代碼開始 - 寫出子程序的聲明 - 編寫第一條和最后一條語句,然后將偽代碼轉換為高層次的注釋 - 每條注釋下面填充代碼 - 檢查代碼 - 收尾工作 - 迭代以上過程,完成 ### 標準示例: ```java ====================pseudocode process======================== The routine outputs an error message based on an error code supplied by the caolling routine.The way it outputs the message depends on the current processing state, which itretrieves on its own .It returns a vlue indicating success or failure. set the default status to “fail” look up the message based on the error code if the error code is valid if doing interactive processing , display the error message interactively and declare success if doing commnad line processing, log the error message t othe command line and declare success if the error code isn’t valid, notify the user that an internal error has bean detected return status information ============================End Pseudocode Process========================== /* The routine outputs an error message based on an error code supplied by the caolling routine.The way it outputs the message depends on the current processing state, which *itretrieves on its own .It returns a vlue indicating success or failure. */ Status ReportErrorMessage(ErrorCode errorToReport){ // set the default status to “fail” Status errorMessageStatus = Status_Failure; // look up the message based on the error code Message errorMessage = LookupErrorMessage( errorToReport); // if the error code is valid if( errorMessage.validCode()){ // determine the processing method ProcessingMethod errorProcessingMethod = CurrentProcessingMethod(); // if doing interactive processing, display the error message // interactively and declare success if(errorProcessingMethod == ProcessingMethod_Interactive){ DisplayInteractiveMessage( errorMessage.getText()); errorMessageStatus = Status_Success; } // if doing command line processing, display the error message to command // line and declare success else if ( errorProcessingMethod == ProcessingMethod_CommandLine){ CommandLine messageLog; if( messageLog.Status() == CommandLineStatus_OK){ messageLog.AddToMessageQuene(); errorMessageStatus = Status_Success; } else{ // cann’t do anything because the routine is already // error processsing } } else{ // cann’t do anything because the routine is already error processing } // if the error code isnot valid, notify the user that // an internal error has bean detected else { DisplayInternactiveMessage(“Internal Error : Invalid error code in ReportErrorMessage()”); } // return status information return errorMessageStatus; } ``` // CHECKLIST: The Pseudocode Programming Process ### 核對表:偽代碼編程過程 - 是否檢查過已滿足所有的先決條件? - 定義好這個類要解決的問題了嗎? - 高層次的設計是否足夠清晰? 能給這個類和其中的每一個子程序起一個好的名字嗎? - 考慮過該如何測試則合格類及其中每一個子程序了嗎? - 關于效率的問題,你主要從穩定的接口和可讀的實現這兩個角度考慮嗎? 還是主要從滿足資源和速度的預期目標的角度考慮過呢? - 在標準函數庫或其他代碼庫中尋找過可用的子程序或者組件了嗎? - 在參考書中查找過有用的算法嗎? - 是否用詳細的偽代碼設計好每一個子程序呢? - 你在腦海里檢查過偽代碼嗎? 這些偽代碼容易理解嗎? - 關注過那些可能讓你重返設計的警告信息了嗎?(比如關于全局數據的使用,一些看上去更適合放到另一個類或子程序中的操作等) - 是否把偽代碼正確地翻譯成代碼? - 你反復使用了偽代碼編程過程了嗎?有沒有根據需要把一些子程序拆分成更小的子程序? - 在作出假設的時候有沒有對它們作出說明? - 已經刪除掉那些冗余的注釋了嗎? - 你是否采用了幾次迭代中的最好的那次結果?還是在第一次迭代之后就停下來? - 你完全理解你的代碼嗎?這些代碼容易理解嗎? ### 中文要點: - 創建類和子程序通常都是一個迭代的過程。在創建子程序的過程中獲得的認識常常會反過來影響類的設計。 - 編寫好的偽代碼需要使用易懂的英語,要避免使用特定程序語言中才有的特性,同時要在意圖的層面上寫偽代碼(即描述該做什么,而不是要怎么去做)。 - 偽代碼編程過程是一個行之有效的做詳細設計的工具,它同時讓編碼工作更容易。偽代碼會直接轉化為注釋,從而確保了注釋的準確度和實用性。 - 不要只停留在你所想到的第一個設計方案上。反復使用偽代碼做出多種方案,然后選出其中最佳的一種方案再開始編碼。 - 每一步完成后都要檢查你的工作成果,還要鼓勵其他人幫你來檢查。這樣你就會在投入精力最少的時候,用最低的成本發現錯誤。 ### English Key Points: - Constructing classes and constructing routines tends to be an iterative process. Insights gained while constructing specific routines tend to ripple back through the class’s design. - Writing good pseudocode calls for using understandable English, avoiding features specific to a single programming language, and writing at the level of intent—describing what the design does rather than how it will do it. - The Pseudocode Programming Process is a useful tool for detailed design and makes coding easy. Pseudocode translates directly into comments,ensuring that the comments are accurate and useful. - Don’t settle for the first design you think of. Iterate through multiple approaches in pseudocode and pick the best approach before you begin writing code. - Check your work at each step and encourage others to check it too. That way, you’ll catch mistakes at the least expensive level, when you’ve invested the least amount of effort.
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看