[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Discuss

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 46
Thread images: 5

File: img000004.png (1MB, 1440x2048px) Image search: [Google]
img000004.png
1MB, 1440x2048px
if (conditional) {

}


or

if (conditional)
{

}
>>
the occupation of lesser men
>>
The second one.
>>
>work
#2 is in the coding standard.
>home
>>only program at home when moving a game or interviewing.
>>>modding, use either or both. Who gives a shit.
>>>interview, try and look up companies std, default to the Google std if it can't be found. #1 for the most part.

https://google.github.io/styleguide/cppguide.html
>>
>>59704159
#1 is the coding standard in everything but C#.
Nobody gives a shit what google has to say.
>>
>>59703721
Whatever the coding standard says.
Either is readable, but I personally prefer the first, it is more compact.
If I am the one who makes the standard, the curly brace should only be on a separate line if it severs a purpose, like when you initialize a class.
Ex:
example::example() :
_value_a(),
_value_b()
{
//stuff
}

looks a lot better than
example::example() :
_value_a(),
_value_b() {
//stuff
}

or
example::example() : _value_a(), _value_b() {
//stuff
}
>>
>>59703721
sauce?
>>
>>59703721

> a ? b : c

Out of the way plebians, patrician coming through.
>>
Ternary if supported.

Otherwise use what the language itself suggest using.

If the language itself has no style guidelines,
fall back to the first one posted.
>>
>>59704159
>Google style guides
Not when they recommend this for HTML: https://google.github.io/styleguide/htmlcssguide.html#Optional_Tags
>>
File: Screenshot_20170402-190626_01.png (49KB, 1080x488px) Image search: [Google]
Screenshot_20170402-190626_01.png
49KB, 1080x488px
>>59704186
>
>>
>>59703721
The second one is compulsory where you are rated by your "output" and "productivity".
if (conditional) {
//stuff
} else { // save more v-space
/other stuff
}
>>
>>59706184
>pajeet metrics
Leave.
>>
>>59703721
I found the elder god tier:
if(conditional){ some_shit_here(); other_shit();}
>>
>not using higher order conditionals

if (!(err = (a > b) ? func1(a) : func2(b)))
>>
>>59703721
Literally doesn't matter.
>>
>>59706377
I'd fire any "programmer" daring to submit this to review.
>>
>>59706466
What's wrong with it?
It kills many birds in one stone and would be written in 5 + 10 lines if it was written the retard way like you suggest.
>>
>using if
>not ternary operator
plebs
>>
you guys dont know anything

// simple program to test if 1 + 1 = 2 is true
#include <iostream>

enum Booleans : bool { T = true, F = false};

void isTrue(Booleans statement, Booleans* output) {
if (statement == Booleans::T) {
*output = Booleans::T;
} else { if (statement == Booleans::F) {
*output = Booleans::F;
}
}
}

using number = int;
number main(int argc, char * * argv) {
char stringFalse[6] = {'F','A','L','S','E','\0'};
char stringTrue[5] = {'T','R','U','E','\0'};
Booleans temp;
Booleans statement;

if (1 + 1 == 2) {
statement = Booleans::T;
} else {
if (1 + 1 != 2) {
statement = Booleans::F;
}
}
isTrue(statement, &temp);

if (temp == Booleans::T) {
std::cout << (std::string(stringTrue)).c_str() << std::endl;
} else {
if (temp == Booleans::F) {
std::cout << (std::string(stringFalse)).c_str() << std::endl;
}
}
system("pause");
return -1;
}
>>
>>59706774
Everything, and if you can't see it, you do not belong in the field.
>>
>>59707242
yeah ok neet boy
>>
>>59707279
>posts unreadable unmaintainable prone-to-bugs code
>>
>>59703721
first one.
>>
>>59707242
> hard to read
> hard to debug
> hard to handle errors
> not flexible

did I miss anything?
>>
>>59707363
Improper use of the ternary operator and the implication that both functions return 0 as success.
>>
File: manga-guide-to-databases.jpg (114KB, 400x569px) Image search: [Google]
manga-guide-to-databases.jpg
114KB, 400x569px
>>59706297
>>59704590
These
>>
>>59707482
these manga guides are so trash
i didn't expect any rigor, but the information density is SO LOW that they resort to dumping entire pages worth of material without the cute drawings so the reader can catch up because they can't into pacing.
>>
if (conditional)
{

}


>Not giving tab to the brackets
Shiggty
>>
if conditional is True:
#stuff
>>
File: disney exposed.png (208KB, 476x351px) Image search: [Google]
disney exposed.png
208KB, 476x351px
>>59703721
#1

The latter looks like two separate blocks. In the first one it basically reads "here is the condition, start the block. It just reads better

The only thing that jumps out to me as being weird is the fact that the ending brace has its own line while the first one doesn't

>>59708110
That actually makes sense
>>
>{

Into the trash it goes.
>>
>>59706774
4 lines vs 1 line in pure C
>>
File: 1485864456707.jpg (362KB, 924x924px) Image search: [Google]
1485864456707.jpg
362KB, 924x924px
>>59703721
>when you realize it doesn't matter because it compiles to the same assembly
>>
>>59709460
Why don't you write all your code on one single line then?
>>
>>59703721
First
Second is only for functions, methods, classes, or objects.
>>
>>59709753
> Implying I don't
>>
The one that doesn't mindlessly waste lines.
I'm writing, not scrolling down a stupid facebook-esque site that never ends.
>>
>>59705273
>inconsistent brace spacing
>>
>>59704416
>Either is readable, but I personally prefer the first, it is more compact.
compact is less readable you dingus
>>
>>59709753
I do.
>>
>>59708110
Fuck off GNU
>>
>>59704416
Personally I use second for class/method/function definitions and first for everything else. Makes it extra clear.
>>
>>59710265
This guy gets it.
>>
>>59703721
First one, because it works better with code folding and doesn't waste vertical space, though by that argument
if (condition) {
foo();
bar();
baz(); }

would be the best.

Personally though, I think what would be the most aesthetic is
if condition do
foo()
bar()
baz()
end do
>>
>>59707212
// simple program to test if 1 + 1 = 2 is true
#include <iostream>
#include <map>

enum Booleans : bool { T = true, F = false};

void isTrue(Booleans statement, Booleans* output) {
if (statement == Booleans::T) {
*output = Booleans::T;
} else { if (statement == Booleans::F) {
*output = Booleans::F;
}
}
}

using number = int;
namespace c_plus_plus_standard_namespace = std;
using Booleans_to_c_string_map_type = c_plus_plus_standard_namespace::map<Booleans, char*>;

number main(number argc, char * * argv) {
char stringFalse[6] = {'F','A','L','S','E','\0'};
char stringTrue[5] = {'T','R','U','E','\0'};
Booleans temp;
Booleans statement;
Booleans_to_c_string_map_type boolean_to_c_string_map;

boolean_to_c_string_map[Booleans::T] = stringTrue;
boolean_to_c_string_map[Booleans::F] = stringFalse;

if (1 + 1 == 2) {
statement = Booleans::T;
} else {
if (1 + 1 != 2) {
statement = Booleans::F;
}
}
isTrue(statement, &temp);

if (temp == Booleans::T) {
c_plus_plus_standard_namespace::cout << (c_plus_plus_standard_namespace::string(boolean_to_c_string_map[Booleans::T])).c_str() << c_plus_plus_standard_namespace::endl;
} else {
if (temp == Booleans::F) {
c_plus_plus_standard_namespace::cout << (c_plus_plus_standard_namespace::string(boolean_to_c_string_map[Booleans::F])).c_str() << c_plus_plus_standard_namespace::endl;
}
}
system("pause");
return -1;
}
Thread posts: 46
Thread images: 5


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.