I downvoted because

if we cannot read your code, we cannot help you.

Badly formatted code makes it harder to help.

If code in a post is not properly indented and formatted, it is much harder to understand it. More experienced users are forced to spend time editing the post rather than answering it.

Why this is a problem

Posting a question with poorly formatted code is much less likely to get a good answer quickly. Those who want to help have a limited amount of time to do so. They need to focus on the actual problem. When code in a post is badly formatted, it makes it much harder to read and understand. More experienced users may dedicate their limited time formatting it correctly rather than answering it. Code that contains lots of unnecessary lines or lines that are so long the code block has a horizontal scrollbar is seen as rude.

Why this is worth a downvote

It indicates the asker did not want to spend the effort asking a good question. Indentation is easy. Most IDEs have tools that format code automatically, and make it easy to increase and decrease the indent. Failure to format the code shows that not much effort was put into writing the question. It is up to the person with the question to format their code for clarity and brevity. Failing to do so is commonly seen as rude as it wastes the time of people who are–for free–trying to help.

What to do next

Code should always be in the form of a Minimal, Complete, Verifiable Example (see the Stack Overflow help center for details on how to do this).

Code should always follow the indentation standard of the language it is written in. More on indentation styles can be found on Wikipedia

Code can be made easier to read if blank lines are used to separate logical chunks, like spaces separate paragraphs. Code should avoid empty lines that do not serve any purpose at all. As a rule of thumb, code should always be “pleasing to the eye?”

Variables and functions should have clear names that describe what they do. A variable with a good name does not need a description of what it holds or why. Stack Overflow is an english-only website, and as such it is preferable to use English names.

Code should have comments where necessary. Where variable and function names should describe what they do, comments describe why. Having comments inline with code can make it easier for readers to quickly understand the code. Comments that indicate areas where problems lie are always welcome.

Code should be edited with all of these recommendations in mind, then indented four spaces from the left margin. Once complete, it can be copied directly into an edit.

Leave a comment!

Once you have done this, leave a comment to the person who sent you this link. They will be happy to retract their downvote.

Did this page help you?

This website is here for everyone’s benefit, most importantly yours! If this did not help you, or if you would like to leave feedback, please create an Issue regarding this page on GitHub, or submit an improvement directly.