How do you use your brackets

How do you use your brackets

Attached: Screenshot_20191226-181929__01.jpg (1080x448, 94K)

Jesus fucking Christ what is this savagery?

FYI, those are braces.
Brackets are [ ]
Parentheses are ( )

I hate OP and his brackets more than niggers

now my fucking mind is broken, thanks OP

Horrifying. Almost as bad as Egyptian braces

KYS LOL FAGGZOR ++

You are a bad person, OP.

This seems like appropriatethread to ask something that bothers me:
When i want to execute function, with long list of arguemnts, i want to format it, so that it fits single screen width. How would you format that?

I would generally format this:
>fn(arg1, arg2, ... argn);
like this:
>fn(
> arg1
> ,arg2
> ...
> ,argn
>);
but i feel that is unsatisfactory. Any ideas?

In java you can define a function with any number of the same type of argument using the ... operator

Or maybe use an array.

But in general, a lengthy list of arguments could be a sign that something needs to be refactored

Used something like this but still, too many parameters.

Attached: nigger.png (294x132, 4K)

I do exactly this, but only if it's past 80 characters.

What do you guys think of:
> variable_names_like_this
or
> variableNamesLikeThis
?

Depends on the language. Personally I only use underscores for variables in DB programming but I've also seen that for public static final constants. But, for some reason, I only do all uppercase when using underscores.

e.g.

VARIABLE_NAME is fine but variable_name is not

In general, though "camel-case" is the preferable on most situations

I try to stick to the language's coding conventions but I prefer snake case, more readable and easy to show private/out of scoped variables.

Functions with a long list of arguments are hard to read and should be avoided. If you can't change it, wrap it like . If it's up to you, then rewrite it into a class where there are different functions for setting variables / small groups of variables.
In PHP:
$foo = MyClass()->setArg1(arg1)
->setArg2(arg2)
->setGroupArgs(arg3, arg4, arg5);
variableNamesLikeThis most of the time

I don't agree with all caps for variables, I only use all caps for constants:
>#define BIT_MASK_2 4

Also, how do underscores help with variable scopes?

I use python

Mainly in javascript when setting positional variables for a callback function such as ajax.
id=id will raise an exception. (Context: gantt with custom html attributes.)

Attached: asdasdasda.png (718x238, 17K)

I dont use brackets at all
Brackets are shit
Java is shit, the sytax is shit and the compiler is shit
Imagine writing this public static shit for every function
Imagine writing system.out.print(); instead of just print()
>try python

Imagine not learning anything and just using someone else's library to do all the heavy lifting...

Often I have trouble finding the end of a function with Python. Indents are not a good indicator if I need to move a function. Whereas brackets in most editors/ides will highlight the corresponding bracket so I know what to move.

But agreed, java is a bit wank.

well, when you think about it, many languages are just libraries on top of assembly

Well, this is not so much issue when defining function/method, but rather when calling it. Function is defined only once, whereas used multiple times.

Still, thanks for bringing this to my attention.

Why not give every argument its own row? Wouldn't that be easier to read?

Is really better to create object and then set its variables one by one? Seems more work for not so obvious gains. What am i missing?

Depending on the amount of arguments it can take up more rows than it needs to, making me zoom out/scroll back up to remember the function or another parameter.

But I haven't had to use that very often.

If you write a function to parse the object's desired arguments then it will take only a few lines to get the arguments you want.

Or you could use the 'arguments' object provided by javascript; if you use it

When i can choose, i prefer variableNamesLikeThis. I like saving underscores for when i need to make more significant delimiter in variable name. Like when i have multiple variables referring to same object:
>objectOne_attributeA
>objectOne_attributeB

Also, as user pointed out, for GLOBAL_CONSTANTs.

Pretty much this

>Well, this is not so much issue when defining function/method, but rather when calling it
This is true. But still, I'd take a look at what exactly those parameters are and where they're coming from.

Maybe these values should be in a config file or pulled from a DB?

Or maybe your objects need a bit more breaking down? e.g. Is one "god" object responsible for most of the logic? That could lead to a huge string of params being passed. If so, spreading and isolating the responsibilities should be considered.

I use them like checkstyle conventions of google. That's how I learned on university..

Functions with many parameters are to be frowned upon. If your object needs that many parameters to exist, you should think of breaking it down in smaller parts, or using a configuration object to pass appropriate parameters.

> ->
This is absolutely evil and goes against RAII principles (Resource acquisition is initialization). Once an object is created, its attributes should not be modified unless it's part of the business logic to modify such attributes. The attributes should be broken down into a configuration object before using a pattern like yours. See pic related.

Attached: foocfg.png (411x128, 8K)

derped up the variable names but you understand.

The gain is readability. If you have a small project though then I guess don't bother.
Function names help a ton - no need to remember what argument is nth.
And if you need to call the function multiple times, but with a few different arguments, then you don't need to pass all of them again.
$foo = new OP()->setAge(19)->setGender('neutral')->setIQ(80);
$foo->getPost(); // Get original post
$foo->setIQ(120)->getPost(); // Get post after increased IQ
Isn't that just one object that holds another object that holds attributes that you change. What's the difference? Are you saying objects shouldn't have variables? I imagine the config object makes things slightly less computationally expensive but who cares.

The only proper way to do this is
>fn(arg1,
> arg2,
> arg3,
> ...rest
>)

but ONLY if the params don't fit on a single line.

> config object makes things slightly less computationally expensive
You're missing the point. A config object is designed to be modified. Your Foo object though is not designed to be partially undefined.

In your example OP object, what's the default age? What's the default gender? If you leave them undefined, your app might blow up much later only when a function that is expecting an age gets NULL instead. If your OP class imposes defaults, you are adding extra friction for some of your users, who would have to overwrite every default parameter if they do not fit their use case.

In your own application, a default OPConfig could have a predefined instance, like an "adultMale" that's male and 18 years old, from which you copy and set new fields. Typical factory pattern. Then when you create the OP with a config instance, you can crash and burn if an expected parameter was left unset, needing only one exception statement.

Attached: exceptions.png (578x233, 18K)

80 chars per line is the usual guideline. Indent each newline 5 spaces, or 1 tab. Try to line up the types in the same columns (i.e. use more blank space between arguments on one line if the name of arguments on the line above are longer).

BASED