Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
I'm not sure if I understand what you mean by "few" in this case. Do you mean that there are too few devs who don't add the opening brace on the same line as the declaration, i.e. you're in favour of
"
foo
{
"
...or the opposite, that you wonder why there are some devs that do this, i.e. you're in favour of
"
foo{
"
? -
Personally I'm in favour of
"
foo
{
"
because the opening and closing braces are aligned on the same indentation level, making the code easier to overview and debug. IMHO. -
@TerriToniAX, I'm in the favor of the second style. BTW, you're the first one to give some sensible reason other than "I've been doing this from day 1"
-
httpeed567yHaving the same indentation is why I did it originally, now it's a habit - I do get younger devs pointing out the editor highlighting support regularly though!
-
This is a very classic question that comes up every now and then, like variableName vs variable_name. It actually matters very little (at least to me), but is the subject of debates that take an undeserved amount of time and energy from devs.
"Correcting" insignificant coding flavour like this seems like a waste of time though. Considering what a "huge" problem this is to many devs, perhaps the makers of IDEs such as Visual Studio etc., should actually address it by making it an option and format the code automatically for each user. -
@TerriToniAX, for me I'll refactor it if I have to work on it for two or more days, it's worth effort for me as it doesn't distract me from actual logic throughout. Plus there for sure are plugins that do it for you.
-
Being distracted by unimportant things like this is common among devs. To you, linebreak before brace is a problem, to me autocomplete of closing tags/braces is disturbing like hell, and autocorrect while typing makes it compelety impossible to type anything! And to some third dev, it's something else that distracts or annoys the crap out of them. I think that this high sensitiveness among devs is evidence that most of us have some sort of mental disorder, although most haven't been diagnosed. Perhaps the instance one becomes a developer, one should automatically be diagnosed with something like "Hypersensitive Developer Disorder" ;) And those of us who immediately start thinking of hard drives, "Compulsory Acronymizing Disorder".
-
@mayank9856 I wouldn't call it refactoring if only removing/adding white space. Dunno the exact definition though so you may present another view if you like, but to me refactoring is when, for example, replacing a bunch of if...else if...else if... with a switch statement, or breaking up a lengthy function into multiple smaller functions (or vice versa).
-
@TerriToniAX, yeah my bad. The end result of refactoring should be to improve the nonfunctional aspects which in this case doesn't happen.
-
solecki187yI simply follow language conventions 'cause of consistency, but I prefer opening on the same line.
-
elazar10307yThe argument about having the same indentation is simply wrong. In the same-line style you have the same indentation for the definition (e.g. "for") and the closing brace, which is just as easier to review.
-
I just follow jetbrains code format. And frankly, my dear, I don't give a damn. (But i do about tabs)
(I will push you down the stairs..) -
@pagongski Yeah, thanks for reminding me about another thing. Correct indentation is absolutely mandatory to me too, even more important than the things I already mentioned. When I see something like this,
if(<some expression>)
{
<some tabs>}
I can go MAD I tell you *pounding the palm of my had against my forehead* :D
Related Rants
-
droegelor7My CTO in the 'good old times', when he still talked to me and shared his wisdom, once told me what I should k...
-
AmyShackles15I couldn’t think of a quote to do, so decided to do a function instead. Duff’s device! (You know, in ca...
-
chenb0x8Solutions Architect: What version of CentOS are we using? Me: 7 SA: Why not 8?
I genuinely want tp know why few devs don't add the opening brace on the same line as method/class declaration ??
Whenever I find a piece of code which follow such style a part of me cries thinking of the time I'll be spending first correcting...
undefined
why not
programming style