Questions tagged [readability]

Readability is a subjective parameter used to measure an aspect of code quality. It is based on the assumption that code should be easily comprehensible by humans, both in its form and in its meaning.

Readability is a subjective parameter used to measure an aspect of code quality. It is based on the assumption that code should be easily comprehensible by humans, both in its form and in its meaning.

To improve code readability, the following is usually considered:

  • The code is written such that a person with poorer programming skills will be able to understand what is written.

  • Adding descriptive comments to explain every step of the way.

  • Using proper indentation and white spaces.

  • Choosing object\variable names that describe their purposes.

  • Referencing the algorithm and the responsible authors.

730 questions
4
votes
3 answers

Can/Should I replace this GOTO statement in C#

using goto seems natural in here. A project needs to read pdf file, a pdf file can be one of below. Not Protected Protected with password1 Protected with password2 Protected with password3 A file can only be accessed with correct password, there…
Rm558
  • 4,621
  • 3
  • 38
  • 43
4
votes
10 answers

Java: Best practices for turning foreign horror-code into clean API...?

I have a project (related to graph algorithms). It is written by someone else. The code is horrible: public fields, no getters/setters huge methods, all public some classes have over 20 fields some classes have over 5 constructors (which are also…
java.is.for.desktop
  • 10,748
  • 12
  • 69
  • 103
4
votes
6 answers

Why is there so much poorly indented code out there?

The more I browse the code to open source projects in languages that aren't Python, the more I realize that it seems a lot of programmers don't believe in proper indentation. (I won't mention any projects specifically to avoid having anyone take…
dsimcha
  • 67,514
  • 53
  • 213
  • 334
4
votes
2 answers

How to effectively read and write Lisp code?

I'm currently learning Lisp, and I think that I got the basics (I'm using the excellent book Land of Lisp, and so far I've read and worked through about a quarter). I try to create my own Lisp programs, based on what I already learned. Somehow, it…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
4
votes
2 answers

Using Unicode in source files and and lack of unicode symbols

Ever since I learned that clang was able to compile c++ source files written in Unicode, I began to use it heavily when writing math-related code. Compare uₙ₊₁ᵖ = A*uₙ + B*uₙ₋₁; uₙ₊₁ᶜ = π * Aₜₒₜ; uₙ₊₁ = uₙ₊₁ᵖ + uₙ₊₁ᶜ; and u_n1_p = A*u_n +…
Bérenger
  • 2,678
  • 2
  • 21
  • 42
4
votes
1 answer

Readability vs. Maintainability: Condensing statements to loops

Firstly, an example of what I'm referring to: UINT f, i, s; CONST UINT k[5] = { VK_LBUTTON, VK_RBUTTON, VK_MBUTTON, VK_XBUTTON1, VK_XBUTTON2 }; for (f = RI_MOUSE_LEFT_BUTTON_DOWN, i = 0, s = RI_KEY_MAKE; f != RI_MOUSE_WHEEL; f <<= 1, i += s, s =…
user2379628
4
votes
11 answers

Simplifying if statement logic

I have seperated out a test to determine if two schedule items overlap because of the unreadability of it. Is there any application to assist in simplifying a logic statement? Example: (originally a faulty example, but exposes reasons I request…
Brett Allen
  • 5,297
  • 5
  • 32
  • 62
4
votes
1 answer

Better pythonic idiom for this repeated piece code pattern

I find myself using this code pattern quite a bit, and every time I do I think there might be a better, clearer way of expressing myself: do_something = True # Check a lot of stuff / loops for thing in things: .... if (thing ==…
cemulate
  • 2,305
  • 1
  • 34
  • 48
4
votes
8 answers

In what order should I place properties, events, functions, function overrides, etc. in C# classes?

When creating a new C# class I am not certain of what the best logical order for declaring properties, event delegates, functions, function overrides, etc. are and what considerations should be taken into account when deciding on that order.…
Chris Magnuson
  • 5,780
  • 7
  • 34
  • 37
4
votes
3 answers

APL readability

I have to code in APL. Since the code is going to be maintained for a long time, I am wondering if there are some papers/books which contain heuristics/tips/samples to help in designing clean and readable APL programs. It is a different experience…
Oleksandr Nechai
  • 1,811
  • 16
  • 27
4
votes
3 answers

Loupe Magnification with White Text & Clear Background on Iphone

You guys helped so much with my last question, I figured I'd give you a shot at another. I have written an app with a theme that uses a dark blue glassy background and white / gray text and labels. The textfields in my app have clearcolor…
Taylor
  • 240
  • 1
  • 10
4
votes
3 answers

CSS letter-spacing and proportional fonts

So I know that my question is pretty technical, but basically I would like to know specifically how the following CSS affects the display of text in

tags. p { letter-spacing:2px; font-family:"Georgia"; } I know that Georgia is a proportional…

4
votes
2 answers

Does extracting functions incur performance penalties?

I am iterating through a large array (10^5 items) and performing an operation on each. for (var row in rows) { switch (operator) { case "op1": row += 1; break; case "op2": ... case "opN": break; } } For…
stinkycheeseman
  • 43,437
  • 7
  • 30
  • 49
3
votes
4 answers

Python: How to make my 4-coloring checker more readable

I was trying to write a general program to check The 17x17 problem SOLVED!, 4-coloring of a17x17 grid with no monochromatic rectangles. Solution link: 17.txt. This is what I wrote: from itertools import product def is_solution(myfile,m,n): """…
ChessMaster
  • 529
  • 1
  • 4
  • 12
3
votes
3 answers

How can I hide long class paths in stack traces to make them readable?

Often stack traces can get so verbose from long class paths that they are very painful to read. Here's an example: 1) No implementation for…
Jeff Axelrod
  • 27,676
  • 31
  • 147
  • 246