• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    Google對外發布C++編碼規范

    發布: 2011-3-09 10:41 | 作者: 網絡轉載 | 來源: 領測軟件測試網 | 查看: 125次 | 進入軟件測試論壇討論

    領測軟件測試網

    Google對外發布C++編碼規范

    Google的C++編碼規范對外發布,引起了業內開發人員的廣泛關注。

    其中,來自硅谷的柯化成認為,這是地球上最好的一份C++編程規范,沒有之一,建議廣大國內外IT人員研究使用。

    盛大的資深開發者趙劼表示,“非常同意。Google在這方面下足了功夫,讓所有人寫出來的代碼都使用同樣的規范,就好像在工程師編程世界里普及普通話一樣。很多資深工程師剛加入的時候被迫學習編碼規范,開始不習慣,后來發現收益非淺。所謂磨刀不誤砍柴功,創業公司更應該關注!

    科泰的陳榕也認為,“希望Google索性再出版一個工具,類似早先C語言的lint,按照該規范自動排版。否則誰記得住這么多條條框框?”

    C++開發者杜昶旭給大家的建議是,“建議所有開發人員反復閱讀此編碼規范,直到可以背下來再開始寫代碼。當然,更好的做法是根據這個再補充出更具體的執行策略。學校里這些知識老師強調的太少,提前自學吧!

    當然,也有不同的聲音,來自大連的sagasw就認為,“關于Google的C++編碼規范,不知為何突然又火起來,這個規范在C++社區中應用的不多,關注度遠不如Gtest,另外這個規范對于Google是有幫助的,但不是最好的,也不是一定適合每個公司的,每個決定后面都有一個tradeoff,不知這些光會用規范,那意義不大!

    “土豆”也表示,“Google的C++編碼規范沒有說的這么好吧,至少我看Webkit的源碼中,明顯蘋果的代碼比Google的代碼漂亮些,也容易看些,受不了Google源碼中的N多下劃線!

      Example

      They say an example is worth a thousand words so let's start off with an example that should give you a feel for the style, spacing, naming, etc.

      An example header file, demonstrating the correct commenting and spacing for an @interface declaration

      // GTMFoo.h

      // FooProject

      //

      // Created by Greg Miller on 6/13/08.

      // Copyright 2008 Google, Inc. All rights reserved.

      //

      #import

      // A sample class demonstrating good Objective-C style. All interfaces,

      // categories, and protocols (read: all top-level declarations in a header)

      // MUST be commented. Comments must also be adjacent to the object they're

      // documenting.

      //

      // (no blank line between this comment and the interface)

      @interface GTMFoo : NSObject {

      @private

      NSString *foo_;

      NSString *bar_;

      }

      // Returns an autoreleased instance of GMFoo. See -initWithString: for details

      // about the argument.

      + (id)fooWithString:(NSString *)string;

      // Designated initializer. |string| will be copied and assigned to |foo_|.

      - (id)initWithString:(NSString *)string;

      // Gets and sets the string for |foo_|.

      - (NSString *)foo;

      - (void)setFoo:(NSString *)newFoo;

      // Does some work on |blah| and returns YES if the work was completed

      // successfuly, and NO otherwise.

      - (BOOL)doWorkWithString:(NSString *)blah;

      @end

      An example source file, demonstating the correct commenting and spacing for the @implementation of an interface. It also includes the reference implementations for important methods like getters and setters, init, and dealloc.

      //

      // GTMFoo.m

      // FooProject

      //

      // Created by Greg Miller on 6/13/08.

      // Copyright 2008 Google, Inc. All rights reserved.

      //

      #import "GTMFoo.h"

      @implementation GTMFoo

      + (id)fooWithString:(NSString *)string {

      return [[[self alloc] initWithString:string] autorelease];

      }

      // Must always override super's designated initializer.

      - (id)init {

      return [self initWithString:nil];

      }

      - (id)initWithString:(NSString *)string {

      if ((self = [super init])) {

      foo_ = [string copy];

      bar_ = [[NSString alloc] initWithFormat:@"hi %d", 3];

      }

      return self;

      }

      - (void)dealloc {

      [foo_ release];

      [bar_ release];

      [super dealloc];

      }

      - (NSString *)foo {

      return foo_;

      }

      - (void)setFoo:(NSString *)newFoo {

      [foo_ autorelease];

      foo_ = [newFoo copy];

      }

      - (BOOL)doWorkWithString:(NSString *)blah {

      // ...

      return NO;

      }

      @end

    延伸閱讀

    文章來源于領測軟件測試網 http://www.kjueaiud.com/

    TAG: google Google


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>