Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
cowboy beepboop
Feb 24, 2001

du -hast posted:

tbqh in this the year of our lord two thousnad and fiteen, there is basically no reason that readability should not be the top priority. there is nothing worse than having to deal with uncommented code in giant one-line conditionals

people the use ternary operators are cunsts

Adbot
ADBOT LOVES YOU

Symbolic Butt
Mar 22, 2009

(_!_)
Buglord

BONGHITZ posted:

when is this useful?

idk, this is a ruby idiom is all I know

Shaggar
Apr 26, 2006

LP0 ON FIRE posted:

i've been getting into the habit of getting rid of curly braces in if/else statements if they are one line

for example:

code:
if(object != nil){

     return YES;

}
becomes:

code:
if(object != nil) return YES;
pretty nifty if you ask me! :keke:

both of these are incorrect and should be written as


code:
if(object != nil)
{

     return YES;

}

BONGHITZ
Jan 1, 1970

all man

karms
Jan 22, 2006

by Nyc_Tattoo
Yam Slacker
love the extra empty newlines

Shaggar
Apr 26, 2006

hard tabs only

pram
Jun 10, 2001
hard tabs are disgusting and I let go fmt handle all these matters

pram
Jun 10, 2001
ruby is a garbage language that should be abolished from this fine earth

Shaggar
Apr 26, 2006
idk how anyone could seriously use spaces instead of tabs. like what the gently caress? are you using vim or something?

Valeyard
Mar 30, 2012


Grimey Drawer
Haskel has optional indentation (if you don't use brackets) its cool

pram
Jun 10, 2001
lol at failtard jumping on the Haskell clown wagon

Valeyard
Mar 30, 2012


Grimey Drawer

pram posted:

lol at failtard jumping on the Haskell clown wagon

I like indentation, but I never want to use Haskell again at this moment in time, its too hard to use

pram
Jun 10, 2001
all go code is indented. this is done automatically. it is truly the greatest of languages

Shaggar
Apr 26, 2006
lol go is deprecated.

wolffenstein
Aug 2, 2002
 
Pork Pro
i prefer
code:
if (obj != nil) { return YES; }

LP0 ON FIRE
Jan 25, 2006

beep boop

Cumt posted:

i spread my conditionals over many lines for maximum readability

code:
if
(
    (
    variable
    >
    5
    )
    &&
    something()
)
{
    something_else()
}

that almost looked like an if and else at first. v hard 2 read

LP0 ON FIRE
Jan 25, 2006

beep boop

Shaggar posted:

both of these are incorrect and should be written as


code:
if(object != nil)
{

     return YES;

}

yes, let's waste another line when you can always assume an opening curly brace will always be included in multi-line code for a conditional

Shaggar
Apr 26, 2006
you cant waste lines. this isn't the 70s

Valeyard
Mar 30, 2012


Grimey Drawer
I click Format -> Format Code and let Eclipse take care of it for me

pram
Jun 10, 2001
ecrapse

Valeyard
Mar 30, 2012


Grimey Drawer
It definitely has issues

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:
? :

Amethyst
Mar 28, 2004

I CANNOT HELP BUT MAKE THE DCSS THREAD A FETID SWAMP OF UNFUN POSTING
plz notice me trunk-senpai

Shaggar posted:

both of these are incorrect and should be written as


code:
if(object != nil)
{

     return YES;

}

nah that first brace line is a waste, it adds nothing

Amethyst
Mar 28, 2004

I CANNOT HELP BUT MAKE THE DCSS THREAD A FETID SWAMP OF UNFUN POSTING
plz notice me trunk-senpai
1TBS is perfect

Bloody
Mar 3, 2013

Shaggar posted:

idk how anyone could seriously use spaces instead of tabs. like what the gently caress? are you using vim or something?

when i use vim i use hard tabs

Bloody
Mar 3, 2013

hard tabs benefits:
each user can set them to whatever width they want without bothering anybody else
a single hard tab character can display multiple spaces of whitespace; to represent it with spaces instead of a tab character wastes valuable bytes

hard tab drawbacks:

GoldenTeeth
Jun 3, 2013

I'm the pensive looking one on the left. That's me. I'm doing serious business in there. Look at me go.

Shaggar posted:

both of these are incorrect and should be written as


code:
if(object != nil)
{

     return YES;

}

agreeing with a shaggar post

this is the cleanest, most readable way to format code

MORE CURLY FRIES
Apr 8, 2004

Shaggar posted:

you cant waste lines. this isn't the 70s

Dicky B
Mar 23, 2004

anyone who thinks you cant waste lines hasnt seen my posting

Instant Grat
Jul 31, 2009

Just add
NERD RAAAAAAGE
ternary operators are good and cool, and have made my code more better

suffix
Jul 27, 2013

Wheeee!
i omit all optional whitespace and brackets, and then i xz -9 each source file to get the maximum mileage out of my floppy disk

power botton
Nov 2, 2011

if not object:
    print("Do stuff")

compuserved
Mar 20, 2006

Nap Ghost

suffix posted:

i omit all optional whitespace and brackets, and then i xz -9 each source file to get the maximum mileage out of my floppy disk

do 'xz -9 --extreme' to be as extreme as possible

jesus WEP
Oct 17, 2004


ternary operators are extremely ftw

Instant Grat
Jul 31, 2009

Just add
NERD RAAAAAAGE

suffix posted:

i omit all optional whitespace and brackets, and then i xz -9 each source file to get the maximum mileage out of my floppy disk

i tried this with ur mom and she got extreme mileage out of my floppy disk, thx for the advice

St Evan Echoes posted:

ternary operators are extremely ftw

nice

LP0 ON FIRE
Jan 25, 2006

beep boop

GoldenTeeth posted:

agreeing with a shaggar post

this is the cleanest, most readable way to format code

i kinda am too now. i always hated it, but now i think i'm beginning to understand

i think i'm gonna try this with my next project

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
ternary operators sound v neet I will try them

Fanged Lawn Wormy
Jan 4, 2008

SQUEAK! SQUEAK! SQUEAK!
obligatory no dont

EMILY BLUNTS
Jan 1, 2005

Ternary Operator? Remember: Use it often

Adbot
ADBOT LOVES YOU

bobbilljim
May 29, 2013

this christmas feels like the very first christmas to me
:shittydog::shittydog::shittydog:

Instant Grat posted:

ternary operators are good and cool, and have made my code more better


St Evan Echoes posted:

ternary operators are extremely ftw


Fanged Lawn Wormy posted:

ternary operators sound v neet I will try them


EMILY BLUNTS posted:

!(Ternary Operator)? Remember: Use it often

  • Locked thread