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
-2
votes
1 answer

is leaving redundant variables etc for readability in java performance impacting

I'm working on an optimized java library and I'm wondering if having things like int rX = rhsOffset; int rY = rhsOffset + 1; int rZ = rhsOffset + 2; int rW = rhsOffset + 3; where local variable rX is a redundant yet makes code…
Hex Crown
  • 753
  • 9
  • 22
-2
votes
1 answer

Does not declaring more than one variable in one declaration makes the code more readable?

When someone has a lot of variables, is it better to declare all the variables of the same type in one line or write one line for each variable declaration? (in terms of readability of the code) for example All in one line : int my_rank,…
MattSt
  • 1,024
  • 2
  • 16
  • 35
-2
votes
2 answers

Can I change the default response color in Linux Terminal?

It would be nice to be able to easily see the conversations I have with my computer in 'call and response' style, so my input lines are in one color, and what is returned shows in a different one.
plattitude
  • 187
  • 1
  • 1
  • 11
-2
votes
3 answers

Readability and IF-block brackets: best practice

I am preparing a short tutorial for level 1 uni students learning JavaScript basics. The task is to validate a phone number. The number must not contain non-digits and must be 14 digits long or less. The following code excerpt is what I came up with…
Peter Perháč
  • 20,434
  • 21
  • 120
  • 152
-3
votes
2 answers

Python for loop: array unpacking vs range deconstruction

I'm following a data structures and algorithms course taught in Python at the moment and the instructor always opts to unpack arrays (well, lists) using a range functions (method 2 below) instead of the kind of upacking I'm used to seeing in python.…
-3
votes
1 answer

C# Same methods for different argument type

I have this inteface: public interface ICommand { bool Execute(Vector2 commandPosition); bool Execute(GameUnit gameUnit); bool Execute(string shortcut); } And a class with these methods making same things with different argument…
ProtoTyPus
  • 1,272
  • 3
  • 19
  • 40
-3
votes
2 answers

Should one alternate between ng-hide and ng-show or use only one with different values

My question is in regard of best practice / preferred readability in Angular 1.X with ng-show and ng-hide. When using ng-hide and ng-show, is it advised to stick to one and to alternate the value I am evaluating or should i alternate between the…
Frank Visaggio
  • 3,642
  • 9
  • 34
  • 71
-3
votes
3 answers

Is it okay to use break with labels in javascript?

Is there any benefit of doing so and can it lead to readability concerns?
ripu1581
  • 300
  • 1
  • 9
-4
votes
1 answer

Clean java programming, is it a bad idea to use lambdas to generate method input parameters?

Just a quick question regarding good programming practices, Performance aside, how much of a good/bad idea could something like this be? I am oversimplifying the problem to get my point across, but is something like this totally wrong? public void…
-4
votes
2 answers

Matlab: how to redefine indexing to begin from zero? `Subscript indices must either be real positive integers or logicals.`

I have a mathematical data where it would be very convenient to have the index to start from zero like a=sparse([],[],[],30,1); >> a(0)=someValueHere Subscript indices must either be real positive integers or logicals. but Matlab by default offers…
hhh
  • 50,788
  • 62
  • 179
  • 282
1 2 3
48
49