I usually wrap my lines of code so that they take up to 80 characters.
Which packaging looks best to you?
// (A) std::vector<MyLongClassName::size_type>* myvector = new std::vector<MyLongClassName::size_type>(); bool isOneOrAnother = hereIsOneLongCondition && hereIsAnotherOne; // (B) std::vector<MyLongClassName::size_type>* myvector = new std::vector<MyLongClassName::size_type>(); bool isOneOrAnother = hereIsOneLongCondition && hereIsAnotherOne;
I know this is arbitrary, but is there an agreement or preferred method?
I would select (B), but for a boolean, I could add not completely necessary parsers, and then align the values inside them. I would add parens just because my emacs would not do this for me without them.
bool isOneOrAnother = ( hereIsOneLongCondition && hereIsAnotherOne );
Another possibility for the second statement (sometimes):
bool isOneOrAnother = hereIsOneLongCondition && hereIsAnotherOne;
. -, Microsoft , . # , ...
, : # . # . # . # .
, , , . , , , , , () , , . , - , , , .
, .
, (B), , :
(B) javascript <cough> broken </cough> . , , , , .
<cough> broken </cough>
. , -
bool someCondition = ( hereIsOneLongCondition && hereIsAnotherOne && hereIsYetAnother && ohNoHereIsMore);
:
bool someCondition = Foo();
Foo() - :
bool Foo() { bool result = true; if (!hereIsOneLongCondition) { result = false; } if (!hereIsAnotherOne) { // this was added to fix such-and-such bug result = false; } // etc return result; }
, , , . .
Source: https://habr.com/ru/post/1731131/More articles:Xcode - iPhone SDK Zombies - debuggingHow to make a simple sound equalizer for iPhone? - iphonePassenger + nginx: placing the Rails application in a subdirectory - ruby-on-railsSys.WebForms.PageRequestManager._initialize does not appear on my ASP.Net page - ajaxМножество множеств в R - functionкак создать леса для модели, которая уже существует - ruby-on-railsPHP - displaying the status of the form processing - mootoolsDeploying Asp.net (web installer) - installerСтруктурирование структуры и кода RSpec для тестов с очень большим охватом? - namespacesPlease recommend a deployment method in a Linux box on a LAN - linuxAll Articles