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
3
votes
2 answers

What is a term in Java?

I am implementing a application that calculated the readability of Java files with the readability formula proposed by Posnett, Hindle and Devanbu (here). The formula is: z = 8.87 - 0.033 * Volume + 0.40 * Lines - 1.5 * Entropy They say that Entropy…
João Alves
  • 185
  • 1
  • 5
  • 14
3
votes
1 answer

Kotlin lambda parameter vs. abstract value

How is better to pass a lambda function to a class that is used as parent: to pass it as a parameter or to define it in the pasrent class as an abstract lambda and then override it in a child class? To pass it as a parameter: open class Weapon(val…
S. Entsov
  • 53
  • 6
3
votes
5 answers

What are the drawbacks of using a method which calls a delegate for every row in SqlDataReader?

When I find a new idea, I always stick with it, and am unable to see any weak sides of it. Bad things happen when I start to use the new idea in a large project, and discover some moths later that the idea was extremely bad and I shouldn't use it in…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199
3
votes
2 answers

Static and non-static version of the same function in C#

I have my own implementation of the GetUserId() function made static to be able to retrieve the ID in static context. But I also have many places where I use standard GetUserId() function built into an asp.net UserManager library. My fix for not…
Michał Gacka
  • 2,935
  • 2
  • 29
  • 45
3
votes
3 answers

What's the most readable way to write nested functions in javascript?

Example this code I wrote doesn't seem as readable as it could be: function getShortMessages(messages) { return messages.filter((messages) => { return messages.message.length < 50 }).map((object) => { return object.message …
Dany M
  • 113
  • 2
  • 2
  • 9
3
votes
2 answers

naming of physical quantities in python

I would like to establish a good naming scheme for physical/mathematical quantities used in my simulation code. Consider the following example: from math import * class GaussianBeamIntensity(object): """ Optical intensity profile of a…
3
votes
1 answer

Anyone knows a ruby library that works like Readability?

Readability is a javascript program who transform a html page in a more readable one. I'm looking for a Ruby implementation, or something similar, anyone knows a library with this characteristics?
Nisanio
  • 4,056
  • 5
  • 34
  • 46
3
votes
3 answers

Formatting data quantity/capacity as string

A common task in many programs is converting a byte count (such as from a drive capacity or file size), into a more human readable form. Consider 150000000000 bytes as being more readable as "150 GB", or "139.7 GiB". Are there any libraries that…
Matt Joiner
  • 112,946
  • 110
  • 377
  • 526
3
votes
3 answers

Determine if variable is one of several values in Lua

I have a value armyName and need a function that checks if it is one of 8 values. As I'm quite new to Lua, I'm looking for what the best way to do this kind of check is. This works: local function isPlayerArmyName(armyName) return armyName ==…
Jeroen De Dauw
  • 10,321
  • 15
  • 56
  • 79
3
votes
1 answer

Detecting syllables in a word containing non-alphabetical characters

I'm implementing readability test and have implemented simple algorithm of detecting sylables. Detecting sequences of vowels I'm counting them in words, for example word "shoud" contains one sequence of vowels which is 'ou'. Before I'm counting them…
dfens
  • 5,413
  • 4
  • 35
  • 50
3
votes
3 answers

Is K&R teaching bad readability?

It has been a while since I looked at C (still learning) and I just got back into the K&R book. I just had a go to Exercise 5-3 (p107). Write a pointer version of the function strcat that we showed in Chapter 2: strcat(s,t) copies the string t to…
alex
  • 479,566
  • 201
  • 878
  • 984
3
votes
1 answer

Lua Spaghetti Modules

I am currently developing my own programming language. The codebase (in Lua) is composed of several modules, as follows: The first, error.lua, has no dependancies; lexer.lua depends only on error.lua; prototypes.lua also has no…
user6245072
  • 2,051
  • 21
  • 34
3
votes
4 answers

Why C# doesn't accept the boolean operators as words ("and", "or", "not" ,..etc) with the current operators?

My if stetement: if (!string.IsNullOrEmpty(Person.Name)) // some code I think the "!" operator is less readable when writing imperative code, Are you agree with me the following code is more readable? if (not…
Homam
  • 23,263
  • 32
  • 111
  • 187
3
votes
1 answer

Can qgraph render edge labels outside the actual edge?

I'm trying to insert edge labels outside the actual edge in my qgraph for readability purposes. I particularly don't like the option of include a white bg below the label, it screws up the edge. According to the manual, it is possible to adjust edge…
eFF
  • 267
  • 3
  • 17
3
votes
4 answers

Is it appropriate to use a series of lambda functions to define class functionality?

In a recent discussion, a friend and I have disagreed over the following use of lambda functions to define class functionality. When creating an object with dynamic values, should the dynamic values be passed using lambdas, or provided using…
FThompson
  • 28,352
  • 13
  • 60
  • 93