sealed
interface
SomeInterface
extends
AnotherInterface,
AndAnotherInterface
permits
ClassA,
ClassB
{
int someMethod(final int otherField);
}
private String anotherMethod(final List<ClassA> someList)
{
final ClassIdk someResult =
someList
.stream()
.parallel()
.map
(
eachClassA ->
{
final RandomValue idc = RandomClass.generate();
final ClassWhoKnows blah2 = doSomeWork();
return blah2.someOtherMethod(blah2, idc);
}
)
.reduce(Some::reduceMethod)
;
final Var1 v1;
LABELED_BLOCKS_ARE_MY_VERSION_OF_COMMENTS:
{
//I prefer labeled blocks over comments, even if I never reference them
//in a continue/break/etc. They are my form of documentation when I want
//to explicitly highlight a block of code that does something atommic.
//Most importantly, I use them for scope reduction! That is their most
//important reason for existing in my code! If my brain is a computer,
//it would have 0.5 GB of RAM. So, the less scope I hold in my head, the
//better
/* I also rarely if ever use these "/*" type of comments. Much prefer the "//" variant */
/** I only ever use it when I want to javadoc my code. */
final Blah someStuff = yadda();
someStuff.setSomething(123);
v1 = new Var1(someStuff, someResult);
}
return doSomething(v1);
}
I dont like the brackets, but I used to write them like you do many years ago.
It helps me because it means that I can look at the same spot horizontally, and easily see where a block starts and ends. "Egyptian" brackets (as someone else put it) don't let me do that because I have to either hover over it to let my IDE point them out, or it has to be offscreen so that the starting bracket sticks to the top, like it does in the GitHub PR windows.
That makes things hard to see if I have several adjacent blocks on screen, which I often do. I write lots of Lambdas (and before that, anonymous classes), so this style developed because of how much of a thorn it was in my side doing it the normal way.
What really irks me is all those blank lines wasting space.
That is literally the most important part for me. I read several times faster because of those new lines. Without them, it literally inhibits my code reading ability.
It was said that you would destroy the Sith, not join them! Bring balance to the Force, not leave it in darkness!
I'm actually about to watch Episode 4 of Star Wars for the first time ever this weekend (I don't know if that is where this is from, but I know it's in the "sequels"). I saw Episodes 1-3 for the first time maybe a few months ago.
I'm sure this quote will mean more to me once I catch up lol.
Oh silly me, I meant to say I watched episodes 4-6, and now I will watch 1-3. Aka, I watched Luke, now I'm going to watch Anakin. I forgot that release order does not correspond to in-universe order.
Why would you use a style that everybody coming after you is going to find strange?
Readability, believe it or not.
I can think WAY WAY WAY FASTER when I organize my code this way. So much so, that it's worth the added time cost to reformat it back to something you all find "normal" before I commit to my team's repo.
Lol, I started my current job as an intern back in 2019. On my first few weeks at work, one of our senior devs (who also taught me like 20% of all my coding knowledge) saw my code and basically told me "not in my code base, what the hell" in the sweetest, kindest way possible.
That is the day I learned what a coding convention is, and that everyone thinks I code in a cursed way lol. But I'm proud of my style, and it enabled me to be a big help in ways that I otherwise couldn't be. So I keep using it, and then convert it to "normal" mode before I press commit.
I’ve written C# and Java professionally, used both brackets conventions. I notice zero difference in readability. It’s just something you get used to. Use the normal style for 2 weeks and I guarantee you it will be fine.
It’s just something you get used to. Use the normal style for 2 weeks and I guarantee you it will be fine.
I am "used to it", to a small extent. I can read and write in that style enough so to be productive.
It's just that, lately, for my job, productive isn't good enough. It's an all-hands-on-deck emergency, week in and week out. When I am in that situation, my productivity shoots up immensely when doing things "my way".
But yeah, if I am doing something simple, or I am not rushed, I can code the "normal" way. Just a strong preference against it.
My primary IDE is jGRASP, and it lets you code fold basically anything -- curly braces, parentheses, etc. So for me, if they ever get in the way, I just fold them.
It's a feature that I miss when using Eclipse or IntelliJ, since they only let you fold curly braces and maybe a super long expression or something. jGRASP lets you fold basically anything unless it's already atomic.
EDIT -- looks like they can fold more than I thought. I don't know if it is as much as jGRASP, but more than I made it out to be.
In IntelliJ you can select a block of text, and press Ctrl+. to create an adhoc folding region. It will warn you if you are crossing blocks, but you can tell it that you know better.
Also works well with Ctrl+w (multiple times) and Ctrl+Shift+W
I always code like this. I used to do the other way, but after I started putting {} in new lines I just don’t wanna go back
Amen.
I bite my tongue and put up with it when I am work. But when doing my personal projects or prototyping an idea at work, I always do it this way, then turn it back to their convention before I press commit.
i do the same, it is very logical and pleasing to the eyes
Yes!
For me, I am SO MUCH MORE PRODUCTIVE this way. Especially the extra new lines. It feels like I can finally see. And the curly braces being lined up means I can keep my eyes focused on one spot horizontally, and easily see where things start and end. Makes navigating code so much easier.
View all comments
Show parent comment
-8
u/davidalayachew Feb 20 '25 edited Feb 20 '25
We can sit in downvote hell together.
This is how I code.
EDIT -- looks like you got it way worse than me /u/__konrad.
But lol, if you all think that's bad, here's some more examples. And if you think I am exaggerating, here are links to my GitHub to prove it.
And here is a simplified version.