<ruby id="h6500"><table id="h6500"></table></ruby>
    1. <ruby id="h6500"><video id="h6500"></video></ruby>
          1. <progress id="h6500"><u id="h6500"><form id="h6500"></form></u></progress>
            • 軟件測試技術(shù)
            • 軟件測試博客
            • 軟件測試視頻
            • 開(kāi)源軟件測試技術(shù)
            • 軟件測試論壇
            • 軟件測試沙龍
            • 軟件測試資料下載
            • 軟件測試雜志
            • 軟件測試人才招聘
              暫時(shí)沒(méi)有公告

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

            Google對外發(fā)布C++編碼規范

            發(fā)布: 2011-3-09 10:41 | 作者: 網(wǎng)絡(luò )轉載 | 來(lái)源: 領(lǐng)測軟件測試網(wǎng) | 查看: 125次 | 進(jìn)入軟件測試論壇討論

            領(lǐng)測軟件測試網(wǎng)

            Google對外發(fā)布C++編碼規范

            Google的C++編碼規范對外發(fā)布,引起了業(yè)內開(kāi)發(fā)人員的廣泛關(guān)注。

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

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

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

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

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

            “土豆”也表示,“Google的C++編碼規范沒(méi)有說(shuō)的這么好吧,至少我看Webkit的源碼中,明顯蘋(píng)果的代碼比Google的代碼漂亮些,也容易看些,受不了Google源碼中的N多下劃線(xià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

            延伸閱讀

            文章來(lái)源于領(lǐng)測軟件測試網(wǎng) http://kjueaiud.com/

            TAG: google Google


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

            軟件測試 | 領(lǐng)測國際ISTQBISTQB官網(wǎng)TMMiTMMi認證國際軟件測試工程師認證領(lǐng)測軟件測試網(wǎng)

            老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月
              <ruby id="h6500"><table id="h6500"></table></ruby>
              1. <ruby id="h6500"><video id="h6500"></video></ruby>
                    1. <progress id="h6500"><u id="h6500"><form id="h6500"></form></u></progress>