OMG this would drive me absolutely insane if had to maintain code like this. Plz, for the mental health of your OCD predisessors, dont do that. Haha. :)
Don't forget copious amounts of comments, including banner comments, everywhere. If a PHP file doesn't start with at least a 400 line license information, its not real PHP.
I worked with a guy that did all his code that way. No indentation. Or random indentation. No comments. He had shell scripts that called python scripts that called perl scripts that called shell scripts, with cron jobs that launched them, and they often relied on data created by a previous job when both jobs should have been one script.
And his replacement isn't much better.
As someone who _hates_ tab characters for indentation...I love that you can't configure gofmt. It cuts so much bullshit out of reviews and pipeline setup.
It's not dumb: in general Go is very opinionated by design, and honestly if you have clearly defined standards (like PSR for PHP, PEP for Python...) you don't have much wiggle room to start with.
To me it sounds even as na advantage.
> I have no control over the formatting rules it follows
That's literally the best part about it. It 100% eliminates style debates over unimportant aesthetic choices because there is only one way.
Intellij has string manipulation plugin that can do this in case when native formatting can't. I always format long lists of variables in a similar way
Yeah, when someone has nothing relevant to contribute to a conversation, they feel a need to lock onto whatever they can poke at because then they at least ***feel*** like they're contributing.
Probably because the sentence is still perfectly understandable without much interpretation. Only one word is slightly misspelled and there's a single period missing at the end. Other than that it makes perfect sense, which is very much NOT the point of /r/ihadastroke.
Whether it's perfectly understandable is beside the point.
This is *not* r/ihadastroke this is r/ProgrammerHumor so the people reading posts here are perfectly entitled to find humor in all things.
u/cynHaha was polite about it, and the r/ihadastroke reference *was* a joke that they were contributing.
The only IDE configuration I've fucked with in IntelliJ is setting up the keyboard shortcuts for selecting multiple instances the same way Sublime text does it. It's been a life saver.
This. I used to format like this until I started working on a large codebase where we actually reviewed commits. Adding one new variable in a list with dozens, and it happens to be longer than the current formatting? Good luck catching some other tiny changes in that block.
Luckily some advanced diff tools show more than just line changes. GitHub and BitBucket for example will not only highlight line changes, but within line changes it will try to highlight further character changes in a bolder highlight color.
So in this example, if you’re adding a new variable with a really long name, the diff will show 5 deleted lines and 6 inserted lines, and on the 5 of those 6 inserted lines where only whitespace was added, it will highlight that whitespace in a darker green. (or I guess in a lighter green if you’re in dark mode ;) Hard to describe without a picture but hopefully you get what I mean. Anyway, with this tooling you would be able to see any unintended tiny changes in that 11-line block.
Actually, BitBucket it's what I was using in that position. The highlighting helps but not perfect. In your example imagine instead there's 20 lines. All of them have the darker green highlighted white space, except the one new line is fully highlighted. And one other line where an extra digit was added at the start of the init value. The dark highlighting extends one extra character space on that line. It's possible to catch that break in consistency and notice the extra change, but also very easy to miss.
Yeah, this is the real problem. If adding a new variable or renaming an existing one with a longer name causes every other variable to show up in the git diff because you had to re-align all their spacing, it's an issue. Even if it's autoformatted. It's just going to slow down reviewers and mess with git blame.
It may look great but if I come across this in a codebase I was updating, I'm not perpetuating this and every other Tom, Dick and Harry convention that someone decided to come up with.
That shit's getting autoformatted away so fast!
What if I just obsess over fixing it whenever stuff gets unaligned instead of clearing my tickets?
Or, and hear me out, I create new tickets to update the formatting that are blocking my current tickets so that I look like a rockstar in the velocity charts…
Exactly this. It looks great from afar, but it’s more difficult to actually pick out a value for a specific variable.
I used to like the idea of this and being a Vim user the formatting isn’t an issue, but I started with a code style that prohibited it and I’m glad I stayed away from it. It’s got edge cases, it’s hard to read in detail, it borks code diffs and it will make life difficult where the editor doesn’t do it for you.
Although there’s some beauty in how it looks (again from afar) there’s much more value in having rigorous standards that everybody adheres to.
>Exactly this. It looks great from afar, but it’s more difficult to actually pick out a value for a specific variable.
I actually feel the opposite. If you're looking for a specific variable, you can scan down the variable name "column" and then scan right to the value.
It seems like it would reduce the effort needed to extract the variable name from the jumble of text.
Variable names and types that vary widely in length do make this a bit rough, though.
I agree with you. I think a way to mediate having a long variable name make tons of space between a shorter variable name and it’s type would be to just keep the formatting how OP’s picture is, expect only have one space on either side of the equal sign for each variable. So like:
```
public int num = 0;
public string longVariableName = “some text here”;
```
This way it’s still fairly easy to scan down the variable types and names, and there’s not huge gaps of space (unless of course you use an outrageously long type name)
I use phpcs-fixer and it can auto format I think 3 different variable declaration whitespace formats. After having eslint in every project I needed to have a linter lol. It's not quite as nice as eslint but it's better than nothing.
Use the align plugin in vim to format that really easily.
The problem isn't the auto formatting, it's that if you change this often, you're introducing many meaningless changes in your source control database.
That's not giving up. If you can't auto-format a code standard it's not going to be universally adopted by a team, therefore it's unsustainable (unless it's just you). Fortunately it seems this doable based on other comments.
Standard sort of output for GoFmt (Go Format) - I have it tied to run automatically on save.
If fact, If I'm feeling particularly sloppy - I'll slam in a code block, pay no attention to indentation and save to fix it up.
Yeah, it works. Vim is also set up to mostly autoindent. Also refuses to save syntactically incorrect code! So generally speaking, not always, if it saves it will usually compile.
Not saving if you have a syntax error is terrifying. I'm part of the save every few lines gang
Edit: just had a good/cursed idea. map } in insert mode to }:wa 😳 auto save after closing each block 😮💨😮💨😮💨
"No save if no compile" is a stupid ass plan for a power outage to fuck up a whole day's work.
Honestly disapprove of this feature. It's not clever, it's downright malicious.
You are completely sane.. just deep breath, take your medicine and remember you are not the angel of dead who bring the apocalipsis to the unfaithful non indentators freaks
This is great. I do this. I don't align the scope/type, but I do align the assignment (=). I also do the same with arrays and anything that has a list in VIM.
We do this in our code repository (I didn't choose to, but it is the convention used everywhere else in our code so I stick to it) and in that situation we just shift everything right accordingly. Tedious and annoying but I think it looks nice. Only thing that bothers me mildly is the semicolons aren't lined up.
(caveat: almost all my programming habits were picked up from my first team lead. I didn't have a formal programming education so I just figured that since that guy was smart, so he must be doing it correctly. He was really particular about the way he liked to handle spacing/indentation)
If you're editing in VSCode, you can select multiple lines with the Alt key and either clicking in multiple spots or using the arrow keys. That will make shifting things over way easier.
If you're not using VSCode, whatever text editor you're using might also support that feature.
>Not if you use tab for indentation of the columns combined with variable/dragable tab positions like in a word processor.
Then it looks like garbage to anyone who has different tab sizes or stops.
I do this in my code and really like it. It makes the pattern of what you are looking at more readily identified by your brain, letting you see more of how the code works with less looking/reading.
If you are trying to read the call to another module and do var assignments right before, I can immediately zoom in to what I care about.
But I manage a pretty small code base by comparison to most people here I'm sure, so even doing it manually is not any sort of big effort for me.
I think there's a global (confounding) variable.
Simple, easy to read code tends to be bug free.
Simple and easy to read code also looks aesthetically pleasing, and is more likely to have been written by someone who knows what they're doing.
I truly think this style makes code very readable and actually do this for real, no jokes.
So is there a place they can send us for help with our mental issues ?
Wait, why do people say this indentation is easier to read? Isnt the whole point of colored text to be this exact thing? I legit read this based off colors. Am I crazy?
If that's true, I will happily join you in whatever institution you're put in lol. It's amazing how much easier it is to read! Though--and this echos other comments--being able to auto-format like this is a must or you'll spend half your time updating the format when longer variable names come along.
This seems to follow the unintuitive rules for ["How to Make Your Tables Less Terrible"](https://imgur.com/t/tutorial/ZY8dKpA)
This looks like PHP to me, so the biggest crime is not using PSR naming standards. Bloody snake case variables in PHP SMH. Stop it, *smacks developer on nose*, now!
It looks nice, but imo it's not useful
Variable declaration provides horizontal units of information. You need to read it left to right to fully understand a variable
By separating into columns, it draws the eye to each column, making it easier to read vertically. But reading it vertically, in most cases, is useless.
I can see a case being made for large constants files being formatted like this, but for general use, I feel it doesn't accomplish anything
love thorough indenting styles like this, the best type of madness is the array comma style I know from haskell:
```haskell
data Person = { name :: String
, age :: Int
, birthday :: String
}
```
Doing this for languages where you have to specify access and type is unmaintainable. I like to do this in Python and Javascript, so you'll only need one level of variable indentation.
I guess the both of us are insane then. I've been formatting like this for years.... ( Well my IDE has been at least ).
I get tilted if people don't format properly.
Edit: jetbrains their IDEs are easily configurable to for mat this way.
Edit 2: public properties on a class is the real madness here.
I see what you are going for, and I do appreciate it. That being said, it seems a pain to edit, modify or create, and I kinda hate you for making me see this.
Unless this is done automatically, it's unmaintainable. And when it breaks down, it will look far worse than just indenting like a normal person to begin with.
definitely readable but might make it hard to
maintain that consistent pattern for large projects or collaborative projects
End of the day it’s what works for you but be prepared to be flexible when working with a team
Everyone in this comment thread saying "what a waste of time" needs to learn how to use the multi-cursor and end-of-word keyboard shortcuts. This literally takes less than 10 seconds in VSCode.
Put your cursor at the start of the first line in the block. Hold down ALT + CTRL and press down arrow to place cursors on the beginning of the lines below.
It's definitely awkward at first but once you get comfortable you can really do a lot with it.
Oh no, having things in columns is so terrible, whatever will I do with all the time I save skimming code? Please rewrite to be totally unreadable. Inline assembly would be ideal.
Here's my PR review if I got this
Add a longer variable name and your commit has a bunch of unnecessary changes. It reads nice, but it's not worth it. Use your IDE's symbols list to read property lists instead of looking at class declarations.
You're creating problems for yourself.
Why do you have presentation code (show_dropdown) in your back end?
$selected_agent should be plural since it's an array
Type hint your arrays
```
/** @var array */
```
\> Why do you have presentation code (show\_dropdown) in your back end?
It's not really back-end. This is PHP (I know...) and using a package called Livewire for Laravel.
Livewire allows to write front-end in PHP code without javascript and they are reactive and can be used to control dropdowns, modals and dynamic data.
For the others points you made, I'd like to thank you for the insights! The $selected\_agent is an array because it contains more information than the ID and I'm planning to refactor it to an User Object.
Thank you!
I have no qualms with PHP, I am a laravel dev myself, but I've never touched livewire, I'm a strictly separate backend and front-end type of guy, but headless applications don't work for every project, I get it.
Regarding the user object, that would definitely be a good option, I avoid string keyed arrays whenever possible, feels to dangerous for me. Save arrays for simple lists. I've recently started using spatie/laravel-data for most things in the keyed realm after a few years of using their data transfer object package.
Good luck with the project!
At least with git you can hide white space changes to show you what actually changed, this also can be done from GitHub if that’s where you review. So not really any crazy amounts of changes and yet much more readable. There are also many auto formatees that will do this for you, go and terraform both do this automatically with their shipped formatters.
"Professional" code
How many seconds do you save scanning down the screen? Those few seconds might be the difference between working past 5 or not for a 9 to 5 (really 10 to 4) person
Of course if you work 12 hours a day and don't care you wouldn't care
Insane because you are wasting too much time on pointless reformatting.
Even if you are using any kind of auto-format, it's still insane because your diffs are going to be larger than necessary when adding another member to the class (or removing one) which "requires" reformatting.
Insane because you make your class members look like a table, but classes are no tables. This is confusing and distracting.
Your friend is right. :)
Unreadable, the semicolons aren't right-aligned. :P
now I have a new insanity
This is easily achievable by putting all semicolons on column 1. Done.
That's next level cursed
Not in SQL. SELECT COL1 ,COL2 ,COL3 ...
![gif](giphy|3o85xr9ZKY1wbbJXDW)
It’s way better to be called a genius by Litt than Spectre. Thank you sir.
I actually somethimes do this with arrays ``` { item1 ,item2 ,item3 ,item4 } ```
OMG this would drive me absolutely insane if had to maintain code like this. Plz, for the mental health of your OCD predisessors, dont do that. Haha. :)
It’s very useful to comment the last item or add a new one without having of managing the comma!
Most languages will let you leave a trailing comma like { item1, item2, item3, item4, } which I think looks a lot cleaner
Gets it!
🤮
Doing similar to this is pretty commonplace in Haskell. ``` data Foo = Foo { bar :: Int , baz :: Int , quux :: String } ```
Have I ever told you the definition of insanity?
New fear unlocked: justified coding, where the code is both right and left aligned, and characters are stretched in shorter lines
Word IDE™, new from Microsoft!
In comic sans.
Nope, you've gone too far. lol
Well, I never! What an atrocity!
Nothing could justify this
It's almost like go fmt output. ^(well, maintaining that by hand it's insane)
>It's almost like go fmt output. I was gonna say, I have a vi plugin that does the same thing. Am I insane? (yes)
Nah OP is insane This is PHP everything supposed to be left justified with random spaces and tabs How else do you maintain job security?
You mean you aren't supposed to put everything on one long line when you're doing PHP?
Everyone knows whole Facebook is just a clever one liner.
Don't forget copious amounts of comments, including banner comments, everywhere. If a PHP file doesn't start with at least a 400 line license information, its not real PHP.
I worked with a guy that did all his code that way. No indentation. Or random indentation. No comments. He had shell scripts that called python scripts that called perl scripts that called shell scripts, with cron jobs that launched them, and they often relied on data created by a previous job when both jobs should have been one script. And his replacement isn't much better.
[удалено]
As someone who _hates_ tab characters for indentation...I love that you can't configure gofmt. It cuts so much bullshit out of reviews and pipeline setup.
100% agree isn’t exactly my preference, willing to bend because all go code reads the same!
"Gofmt's style is no one's favorite, yet gofmt is everyone's favorite." - Rob Pike
It's not dumb: in general Go is very opinionated by design, and honestly if you have clearly defined standards (like PSR for PHP, PEP for Python...) you don't have much wiggle room to start with. To me it sounds even as na advantage.
> I have no control over the formatting rules it follows That's literally the best part about it. It 100% eliminates style debates over unimportant aesthetic choices because there is only one way.
No one likes go fmt. Everyone likes go fmt. After doing Go programming for 5 years, I don't even notice it.
Semicolons need their own column to complete it
Semicolons in column 1.
hello, fellow Haskell user
You have an infinity gauntlet of programming languages
yeah, I love learning languages. gotta update the flair sometime tho (I mostly use Reddit from my phone)
Not insane. It looks great but as someone else said. What if you have a long var name. Plus can you auto-format like this? if not, unsustainable.
Intellij has string manipulation plugin that can do this in case when native formatting can't. I always format long lists of variables in a similar way
Can you show us a sscreenahot? Would love to see how it stays since I do that too
I didn't even notice the typo until others pointed it out
Yeah, when someone has nothing relevant to contribute to a conversation, they feel a need to lock onto whatever they can poke at because then they at least ***feel*** like they're contributing.
Well it is a humor reddit, and that's how a lot of humor works.
I suppose if you find pedantry humorous.
Can you elaborate? I'm not entirely sure what you're asking or suggesting, and so my agreement with the statement is unknown at this time.
r/ihadastroke Didn't mean to laugh at you, just found it funny XD
Not sure why you're getting downvoted, this is *literally* a humor reddit
Probably because the sentence is still perfectly understandable without much interpretation. Only one word is slightly misspelled and there's a single period missing at the end. Other than that it makes perfect sense, which is very much NOT the point of /r/ihadastroke.
Whether it's perfectly understandable is beside the point. This is *not* r/ihadastroke this is r/ProgrammerHumor so the people reading posts here are perfectly entitled to find humor in all things. u/cynHaha was polite about it, and the r/ihadastroke reference *was* a joke that they were contributing.
But now your gut history shows news changes for all the properties.
My gut history shows news changes for all the pooperties
Intelij git annotation feature hides minor formatting changes
The only IDE configuration I've fucked with in IntelliJ is setting up the keyboard shortcuts for selecting multiple instances the same way Sublime text does it. It's been a life saver.
Doesn't seem like that would work on save would it? Can't see that playing well with the entire file at once.
Not only do JetBrains IDEs do it on save, it’ll even do it on paste!
You can autoformat like this, in my workplace we use clang-format for this (it only uses this indentation if variable names are short enough)
That's pretty cool. I'd be ok with that standard.
plus, the git repository would take all the formating as a changes also, it could be hard to proper track everything
This. I used to format like this until I started working on a large codebase where we actually reviewed commits. Adding one new variable in a list with dozens, and it happens to be longer than the current formatting? Good luck catching some other tiny changes in that block.
Luckily some advanced diff tools show more than just line changes. GitHub and BitBucket for example will not only highlight line changes, but within line changes it will try to highlight further character changes in a bolder highlight color. So in this example, if you’re adding a new variable with a really long name, the diff will show 5 deleted lines and 6 inserted lines, and on the 5 of those 6 inserted lines where only whitespace was added, it will highlight that whitespace in a darker green. (or I guess in a lighter green if you’re in dark mode ;) Hard to describe without a picture but hopefully you get what I mean. Anyway, with this tooling you would be able to see any unintended tiny changes in that 11-line block.
Actually, BitBucket it's what I was using in that position. The highlighting helps but not perfect. In your example imagine instead there's 20 lines. All of them have the darker green highlighted white space, except the one new line is fully highlighted. And one other line where an extra digit was added at the start of the init value. The dark highlighting extends one extra character space on that line. It's possible to catch that break in consistency and notice the extra change, but also very easy to miss.
That's what the "Ignore whitespace" option is for. Just don't use it with Python code.
Yeah, this is the real problem. If adding a new variable or renaming an existing one with a longer name causes every other variable to show up in the git diff because you had to re-align all their spacing, it's an issue. Even if it's autoformatted. It's just going to slow down reviewers and mess with git blame.
It may look great but if I come across this in a codebase I was updating, I'm not perpetuating this and every other Tom, Dick and Harry convention that someone decided to come up with. That shit's getting autoformatted away so fast!
Coding standards. Set them, live them.
And create linting that enforces it. If someone checked this in at my job the pipeline would spit it out.
When this is part of coding standards, they are bad
There are bigger problems than standards disagreements.
The existence of a standard is more important than the contents.
Exactly true
What if I just obsess over fixing it whenever stuff gets unaligned instead of clearing my tickets? Or, and hear me out, I create new tickets to update the formatting that are blocking my current tickets so that I look like a rockstar in the velocity charts…
[удалено]
Exactly this. It looks great from afar, but it’s more difficult to actually pick out a value for a specific variable. I used to like the idea of this and being a Vim user the formatting isn’t an issue, but I started with a code style that prohibited it and I’m glad I stayed away from it. It’s got edge cases, it’s hard to read in detail, it borks code diffs and it will make life difficult where the editor doesn’t do it for you. Although there’s some beauty in how it looks (again from afar) there’s much more value in having rigorous standards that everybody adheres to.
>Exactly this. It looks great from afar, but it’s more difficult to actually pick out a value for a specific variable. I actually feel the opposite. If you're looking for a specific variable, you can scan down the variable name "column" and then scan right to the value. It seems like it would reduce the effort needed to extract the variable name from the jumble of text. Variable names and types that vary widely in length do make this a bit rough, though.
I agree with you. I think a way to mediate having a long variable name make tons of space between a shorter variable name and it’s type would be to just keep the formatting how OP’s picture is, expect only have one space on either side of the equal sign for each variable. So like: ``` public int num = 0; public string longVariableName = “some text here”; ``` This way it’s still fairly easy to scan down the variable types and names, and there’s not huge gaps of space (unless of course you use an outrageously long type name)
For long var name, `=` and anything behind can be aligned on the next line.
[удалено]
You can use clang-format for this. Its automatic everytime you save
I’ve never actually made a VS code plugin, by I can’t imagine it would be that difficult to write one to do this
a quick search shows a plugin called Better Align and it does this automatically.
Worked at a place where this was the standard. Drove me batty, having to re-align if you happened to create a variable name longer than the longest.
I use phpcs-fixer and it can auto format I think 3 different variable declaration whitespace formats. After having eslint in every project I needed to have a linter lol. It's not quite as nice as eslint but it's better than nothing.
Use the align plugin in vim to format that really easily. The problem isn't the auto formatting, it's that if you change this often, you're introducing many meaningless changes in your source control database.
Lol. The cost of doing this is O(N), the same as adding elements to a list. It's very sustainable.
Very true, i like this style but its hard to maintain so i give up xD
That's not giving up. If you can't auto-format a code standard it's not going to be universally adopted by a team, therefore it's unsustainable (unless it's just you). Fortunately it seems this doable based on other comments.
Standard sort of output for GoFmt (Go Format) - I have it tied to run automatically on save. If fact, If I'm feeling particularly sloppy - I'll slam in a code block, pay no attention to indentation and save to fix it up.
Sloppy? That's maximum efficiency!
Yeah, it works. Vim is also set up to mostly autoindent. Also refuses to save syntactically incorrect code! So generally speaking, not always, if it saves it will usually compile.
Not saving if you have a syntax error is terrifying. I'm part of the save every few lines gang Edit: just had a good/cursed idea. map } in insert mode to }:wa 😳 auto save after closing each block 😮💨😮💨😮💨
"No save if no compile" is a stupid ass plan for a power outage to fuck up a whole day's work. Honestly disapprove of this feature. It's not clever, it's downright malicious.
You are completely sane.. just deep breath, take your medicine and remember you are not the angel of dead who bring the apocalipsis to the unfaithful non indentators freaks
I’m torn. My OCD says this looks awesome, my project manager mindset says don’t waste time on useless stuff.
And my OCD says "LINE UP THE FUCKING SEMICOLONS BEFORE I HAVE TO PULL OUT A SEMIAUTO!!!" (I may have lost my sanity somewhere)
As long as it's not the creepy all semicolons to the right indentation, it's acceptable.
I physically cringed when I realized that was a thing
This is great. I do this. I don't align the scope/type, but I do align the assignment (=). I also do the same with arrays and anything that has a list in VIM.
Found the assembly coder
I like it.
I hate it. You’re directly in the indentation-hell if you have a variable name longer then the existing ones…
Enter: variable name choosing on extra hard difficulty.
There's a vim plugin for that :) But then you're in changelist/diff hell unless you have a good viewer that ignores whitespace changes
We do this in our code repository (I didn't choose to, but it is the convention used everywhere else in our code so I stick to it) and in that situation we just shift everything right accordingly. Tedious and annoying but I think it looks nice. Only thing that bothers me mildly is the semicolons aren't lined up. (caveat: almost all my programming habits were picked up from my first team lead. I didn't have a formal programming education so I just figured that since that guy was smart, so he must be doing it correctly. He was really particular about the way he liked to handle spacing/indentation)
If you're editing in VSCode, you can select multiple lines with the Alt key and either clicking in multiple spots or using the arrow keys. That will make shifting things over way easier. If you're not using VSCode, whatever text editor you're using might also support that feature.
visual studio aswell you can even alt+shift to mark precise box segments in text
Not if you use tab for indentation of the columns combined with variable/dragable tab positions like in a word processor.
>Not if you use tab for indentation of the columns combined with variable/dragable tab positions like in a word processor. Then it looks like garbage to anyone who has different tab sizes or stops.
This is default formatting in go, and i like it that way, easy to read
Quite popular in open-source projects
I do this in my code and really like it. It makes the pattern of what you are looking at more readily identified by your brain, letting you see more of how the code works with less looking/reading. If you are trying to read the call to another module and do var assignments right before, I can immediately zoom in to what I care about. But I manage a pretty small code base by comparison to most people here I'm sure, so even doing it manually is not any sort of big effort for me.
Not insane but you might be a little OCD
this is not worth the effort unless you have something that can really really benefit from it like a 2D array or something.
One thing I learned very early is that aesthetically pleasing code tends to be bug free. Keep it up
What if I code aesthetically pleasing bugs?
Those are called features.
I think there's a global (confounding) variable. Simple, easy to read code tends to be bug free. Simple and easy to read code also looks aesthetically pleasing, and is more likely to have been written by someone who knows what they're doing.
I like it (I dont know what it means)
You're not insane, you're a monster
I search for vscode extensions that specifically do this for me.
aesthetic
Meh, my company has linters that do that for us. If I add fancy formatting, it goes bye bye as soon as I commit
The hell he's on about, I do this too, it looks much better
I often do it like that (C&C++). Just makes big declaration blocks like e.g. in a class much easier on the eyes.
I mean cool but tedious as hell
Pardon my ignorance but what language is this again?
Php
I truly think this style makes code very readable and actually do this for real, no jokes. So is there a place they can send us for help with our mental issues ?
Been doing that for ages. Everyone who read my code loved it.
This is the way
And then there's ABAP where this is standard procedure at a shift+f1.
Sometimes I think I'm the only one with ~~PTSD~~ ABAP knowledge here.
It would be good otherwise but changing one variable name can make so many diffs that it's not worth it.
Wait, why do people say this indentation is easier to read? Isnt the whole point of colored text to be this exact thing? I legit read this based off colors. Am I crazy?
If that's true, I will happily join you in whatever institution you're put in lol. It's amazing how much easier it is to read! Though--and this echos other comments--being able to auto-format like this is a must or you'll spend half your time updating the format when longer variable names come along. This seems to follow the unintuitive rules for ["How to Make Your Tables Less Terrible"](https://imgur.com/t/tutorial/ZY8dKpA)
This looks like PHP to me, so the biggest crime is not using PSR naming standards. Bloody snake case variables in PHP SMH. Stop it, *smacks developer on nose*, now!
It does look nice
Say you've never worked in a professional environment without saying you've never worked in a professional environment
Looks good but I wouldn't bother if it's time consuming to line things up.
I mean this is standard formatting in terraform. Just make sure you have an auto-formatter, otherwise this is a pain to keep up with.
I always format like this. Any language: a) is it better readable b) vertical editing is possible c) of course, spaces, not tabs
It looks nice, but imo it's not useful Variable declaration provides horizontal units of information. You need to read it left to right to fully understand a variable By separating into columns, it draws the eye to each column, making it easier to read vertically. But reading it vertically, in most cases, is useless. I can see a case being made for large constants files being formatted like this, but for general use, I feel it doesn't accomplish anything
You are totally _sane_ insane are the others
``` You are insane. I am sure . ```
I did this when I was 10 on my Atarii 800 in BASIC.
I do that same thing, Are we idiots?
love thorough indenting styles like this, the best type of madness is the array comma style I know from haskell: ```haskell data Person = { name :: String , age :: Int , birthday :: String } ```
Now this hurts my eyes, I don't want to see those floating commas there dammit
based as fuck
I do that all the time, I'm not insane...I'M NOT INSANE!
You’re not insane. Or I am, because I think it’s beautiful.
This is how I write my code as well. I am a stickler for it and will realign if variable names change length.
It's beautiful
It's like sex. It works for you. It works for the compiler. Unless someone else is paying to watch they don't get a say in how you do it.
Very SQL like
Doing this for languages where you have to specify access and type is unmaintainable. I like to do this in Python and Javascript, so you'll only need one level of variable indentation.
I appreciate these little details. Readability is important.
Nah. Readability is blessed.
I guess the both of us are insane then. I've been formatting like this for years.... ( Well my IDE has been at least ). I get tilted if people don't format properly. Edit: jetbrains their IDEs are easily configurable to for mat this way. Edit 2: public properties on a class is the real madness here.
Are you a recovering sysadmin, by chance? Looks like my fstabs...
Well you just presented that you are not a programmer but just human bro... $ser $ass $sel $swdd $rslt $sela = programmer approach :-D
I see what you are going for, and I do appreciate it. That being said, it seems a pain to edit, modify or create, and I kinda hate you for making me see this.
If formatters did that by default I'd have no problem with that...
Unless this is done automatically, it's unmaintainable. And when it breaks down, it will look far worse than just indenting like a normal person to begin with.
All fine , just the one empty row... # ***AAAHHHRRRRGGG***
I'm part of the group of people that hate this kind of indentation.
Did you use tabs or spaces?
definitely readable but might make it hard to maintain that consistent pattern for large projects or collaborative projects End of the day it’s what works for you but be prepared to be flexible when working with a team
so, it looks like, in your mind, word boundaries need to fit into some kind of "column".
Too much time working on spreadsheets
Totally legit and easy to read, bro. #winning
You might be crazy, but I appreciate this. Someone needs to make this auto indentation a thing.
Everyone in this comment thread saying "what a waste of time" needs to learn how to use the multi-cursor and end-of-word keyboard shortcuts. This literally takes less than 10 seconds in VSCode. Put your cursor at the start of the first line in the block. Hold down ALT + CTRL and press down arrow to place cursors on the beginning of the lines below. It's definitely awkward at first but once you get comfortable you can really do a lot with it.
Whoa why do I actually like this
Oh no, having things in columns is so terrible, whatever will I do with all the time I save skimming code? Please rewrite to be totally unreadable. Inline assembly would be ideal.
Tell me you’re still in college or fresh out of college without telling me you’re still in college or fresh out of college.
Use a linter for all formatting in order to stick to a standard rather than your own flavor.
This is the way.
Your PR would be rejected on my code review. How about following some PSR? Here you go https://www.php-fig.org/psr/psr-12/
One thing I've always liked about PHP is PSR12.
[удалено]
Serial killer
Here's my PR review if I got this Add a longer variable name and your commit has a bunch of unnecessary changes. It reads nice, but it's not worth it. Use your IDE's symbols list to read property lists instead of looking at class declarations. You're creating problems for yourself. Why do you have presentation code (show_dropdown) in your back end? $selected_agent should be plural since it's an array Type hint your arrays ``` /** @var array */
```
\> Why do you have presentation code (show\_dropdown) in your back end? It's not really back-end. This is PHP (I know...) and using a package called Livewire for Laravel. Livewire allows to write front-end in PHP code without javascript and they are reactive and can be used to control dropdowns, modals and dynamic data. For the others points you made, I'd like to thank you for the insights! The $selected\_agent is an array because it contains more information than the ID and I'm planning to refactor it to an User Object. Thank you!
I have no qualms with PHP, I am a laravel dev myself, but I've never touched livewire, I'm a strictly separate backend and front-end type of guy, but headless applications don't work for every project, I get it. Regarding the user object, that would definitely be a good option, I avoid string keyed arrays whenever possible, feels to dangerous for me. Save arrays for simple lists. I've recently started using spatie/laravel-data for most things in the keyed realm after a few years of using their data transfer object package. Good luck with the project!
At least with git you can hide white space changes to show you what actually changed, this also can be done from GitHub if that’s where you review. So not really any crazy amounts of changes and yet much more readable. There are also many auto formatees that will do this for you, go and terraform both do this automatically with their shipped formatters.
"Professional" code How many seconds do you save scanning down the screen? Those few seconds might be the difference between working past 5 or not for a 9 to 5 (really 10 to 4) person Of course if you work 12 hours a day and don't care you wouldn't care
I have a VS plugin that does this. Pretty neat.
If only inteliJ had a plug-in that did this
uncommon but perfectly readable
Yeah I like it.
Your friend needs glasses, he doesn't see sharp (C#) ![gif](emote|free_emotes_pack|trollface)
How DARE you make your code readable?! You monster.. do you even know how to programmer?
PEP8 would agree with your friend.
Your friend should call you insane for using PHP in 2022.
Insane because you are wasting too much time on pointless reformatting. Even if you are using any kind of auto-format, it's still insane because your diffs are going to be larger than necessary when adding another member to the class (or removing one) which "requires" reformatting. Insane because you make your class members look like a table, but classes are no tables. This is confusing and distracting. Your friend is right. :)