Board index » cppbuilder » Re: programming style
Jonathan Benedicto
![]() CBuilder Developer |
Jonathan Benedicto
![]() CBuilder Developer |
Re: programming style2005-03-05 03:32:38 AM cppbuilder5 QuoteWell, But, thank you for the explanation. Jonathan |
Vladimir Stefanovic
![]() CBuilder Developer |
2005-03-05 03:34:22 AM
Re:Re: programming styleQuoteLearning how to code the most popular way would help -- Best regards, Vladimir Stefanovic |
Jonathan Benedicto
![]() CBuilder Developer |
2005-03-05 03:35:07 AM
Re:Re: programming styleQuoteYes, it is. The * ties to the identifier, not to the type. {smallsort} |
Jonathan Benedicto
![]() CBuilder Developer |
2005-03-05 03:36:10 AM
Re:Re: programming styleQuoteMe too, but there was some reason not to use '\t' which I cannot |
Rudy Velthuis [TeamB]
![]() CBuilder Developer |
2005-03-05 03:37:55 AM
Re:Re: programming style
Vladimir Stefanovic wrote:
QuoteI remember some rules which were we strongly recomended you'll see a range of styles. What I find strange though, is that Borland has a style guide for Delphi, but not for its own C++ code. -- Rudy Velthuis [TeamB] rvelthuis.bei.t-online.de "God is love, but get it in writing." -- Gypsy Rose Lee. |
Benjamin Pratt
![]() CBuilder Developer |
2005-03-05 03:38:00 AM
Re:Re: programming styleQuote
more intuitve for several reasons. A) The type is pointer-to-TMyClass, thus the type is more clearly defined. B) Is is consistent with the common syntax for references: TMyClass& mc; C) It is consistent with common type-cast syntax: (TMyClass*) or static_cast<TMyClass*>() The downside is in declaring multiple pointers of the same type, but this honestly is rare, and any complex system is going to have exceptions. It doesn't cost much to declare each on a sperate line, like TMyClass* mc1; TMyClass* mc12; alternativly: TMyClass* mc1, * mc2, * mc3; The best solution would be if C++ devieated from C and defined TMyClass* as the type, thus TMyClass* m1, mc2, mc3 would declare three pointers. But to keep compatibility with C, the * is officially a modifier to the variable. I think we can agree that declaring both pointers and objects in a single line is not wise. Hence, (ptr) (ptr) (obj) (ptr) TMyClass *mc1, *mc2, mc3, *mc4; should never be used and there is no real need for this *feature* within the context of C++. IMO, TMyClass* should be the type. Thus the TMyClass* syntax gets as close to that definition while still supporting C compatibilty. I'm sure not everyone agrees, but one thing I'm sure we can all agree on is this: TMyClass * mc1; //is very bad. |
Vladimir Stefanovic
![]() CBuilder Developer |
2005-03-05 03:41:41 AM
Re:Re: programming styleQuote>Me too, but there was some reason not to use '\t' -- Best regards, Vladimir Stefanovic |
Benjamin Pratt
![]() CBuilder Developer |
2005-03-05 03:42:28 AM
Re:Re: programming style
Most IDEs including BCB have a setting to convert tabs to spaces.
"Jonathan Benedicto" < XXXX@XXXXX.COM >wrote in message Quote>I remember some rules which were we strongly recomended |
Jonathan Benedicto
![]() CBuilder Developer |
2005-03-05 03:44:54 AM
Re:Re: programming styleQuoteshould never be used and there is no real need for this *feature* QuoteI'm sure not everyone agrees, but one thing I'm sure we can all |
Vladimir Stefanovic
![]() CBuilder Developer |
2005-03-05 03:47:05 AM
Re:Re: programming styleQuoteWhat I find strange though, is that Borland has a Best regards, Vladimir Stefanovic |
Rudy Velthuis [TeamB]
![]() CBuilder Developer |
2005-03-05 03:55:48 AM
Re:Re: programming style
Vladimir Stefanovic wrote:
Quote>What I find strange though, is that Borland has a community.borland.com/soapbox/techvoyage/article/1,1795,10280,00. html -- Rudy Velthuis [TeamB] rvelthuis.bei.t-online.de "Sometimes a scream is better than a thesis." - Ralph Waldo Emerson (1803-1882) |
Alex Bakaev [TeamB]
![]() CBuilder Developer |
2005-03-05 04:04:54 AM
Re:Re: programming style
Jonathan Benedicto wrote:
QuoteTStringList* Str1, Str2; .a |
Chris Uzdavinis
![]() CBuilder Developer |
2005-03-05 05:16:21 AM
Re:Re: programming style
"Jonathan Benedicto" < XXXX@XXXXX.COM >writes:
Quote>Not my preference. I prefer my { to line up with my } and with the -- Chris (TeamB); |
Chris Uzdavinis
![]() CBuilder Developer |
2005-03-05 05:17:57 AM
Re:Re: programming style
"Alex Bakaev [TeamB]" < XXXX@XXXXX.COM >writes:
QuoteJonathan Benedicto wrote: that was one of the motivating factors for why we chose to have space on both sides of the * and & chars in type declarations. -- Chris (TeamB); |
Ed Mulroy [TeamB]
![]() CBuilder Developer |
2005-03-05 05:21:52 AM
Re:Re: programming styleQuotestruct MyStruct{ You will learn why the next time you are tired and frustrated in a debugging session because things do not work as they should only to finally notice the brace. This is the same issue as is illustrated by the semicolon in this while line (which is not one of yours) as you sit there in your debugging session wondering why executable-statement only executes once: while (condition); executable-statement; Quotefor(int t=i;t<x.Length();t++){ Post incrementing when it is not required is at best no less efficient than pre-incrementing but syntactically suggests that a post increment is needed, which it is not. For C++ classes and structures, including and especially STL-related items, post-increment can be expensive in both code size and execution time. Never use t++ when ++t will do. Quote}else{ Quoteenum TMyEnum { meOne, meTwo, meEtc }; it stand out. If it has enough enum values to line wrap I prefer it to be formatted much as a structure declaration is done. Using your brace style that might be something like this: enum TMyEnum { meOne, meTwo, meThree, meFour, meFive, meEtc }; . Ed QuoteJonathan Benedicto wrote in message |