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

OOP and GUI: what to implement where?

About six months ago I put on a full-stack developer hat at my job and started working on a tool comprised of a GUI and a database. The client has requested that the tool be written in Python, so I've been working with the company PyQt license to…
Or Bairey-Sehayek
  • 193
  • 1
  • 1
  • 8
0
votes
4 answers

In Ruby, Idiomatically and cleanly improve on this use of split and map to turn string input to a 2d int array (i.e. a matrix)

I suspect there's a cleaner, more idiomatic, Ruby-way to solve this puzzle than what I've made. I'm too new to Ruby, though, to confirm. All my searches have not addressed the question of how to best write Ruby in the examples I give below. The…
Ben Ph
  • 9
  • 4
0
votes
2 answers

How to do addition operations intuitively with datetime in AutoHotKey?

I find that there are two ways to calculate the date in AutoHotKey: Use EnvAdd, which is synonymous with var += value Convert the date to the YYYYMMDDHH24MISS format, and calculate it as if it's a regular number, then convert back to date…
Ooker
  • 1,969
  • 4
  • 28
  • 58
0
votes
1 answer

How to pass two inputs to %>% operator in R

Originally I have this code which I am trying to simplify and improve readability using %>% operator. #Get Sunday's from 2018-01-01 till today d = seq(as.Date("2018-01-01"),Sys.Date()+365,by='day') HolidayList =…
Stupid_Intern
  • 3,382
  • 8
  • 37
  • 74
0
votes
2 answers

How can I improve the usability/readability of Toad

I have installed Toad 12.8 and I had a pretty big mistake in executing code. I executed code out of sequence, despite triple checking my work. Some how the tab I had selected was unselected and another script was ran. I still wince in…
0
votes
3 answers

Is it better to have one setter method or multiple for objects with a fixed number of fields?

I have a class with a member variable of type object. This object has a fixed number of fields. I'm trying to decide if I should use one setter function or multiple to mutate these fields. To make the question more concrete, I've written the…
Legend123
  • 348
  • 4
  • 16
0
votes
3 answers

Best practices: a Property, a Function or ToString?

I am trying to determine a best practice when writing code to get the string representation of a custom class. Imagine we have the following: public class DoubleParameter { public double Value { get; set; } public string Description { get;…
0
votes
0 answers

Which is better Branched if-else if construct vs continue statement in loop?

Out of the two code snippets below, does any of the approach has some benefit over the other? for(int i:list) { if(condition 1) { //do something continue; } if(condition 2) { //do something continue; } …
Faiz Kidwai
  • 463
  • 5
  • 26
0
votes
1 answer

More Variables for More Readable IF/Conditional?

Question: Is it better to have more variables to allow a conditional to be "more readable" or is it cleaner to have less variables but a harder to read conditional? I read this which says less variables. I think their solutions look LESS readable (…
seesharp
  • 101
  • 1
  • 14
0
votes
1 answer

Java Naming - byte buffer reader/writer or input/output stream?

Looking through a couple different projects I can see two different namings for the same items. Which one is correct/wrong or is more universally understood vs the other? Project 1: //reading byte[] data; InputStream is = new InputStream(data); int…
kay
  • 451
  • 1
  • 3
  • 13
0
votes
0 answers

Readability using matrix input

I realised that matrices are a lot faster for storing numeric data than any other format in R. Interestingly they can also be used to speed up my plotly code. Which is desirable because recalculating plotly-plots e.g. in a shiny app can be…
5th
  • 2,097
  • 3
  • 22
  • 41
0
votes
0 answers

Singleton constructor with arguments (JavaScript)

Premises Before angry hearts start blaming the singleton pattern and related practices, or criticizing this matter with theoretical crusades, I state that the question represents a real issue in the real life, analysed by people with a bit of brain…
yodabar
  • 4,651
  • 2
  • 33
  • 38
0
votes
2 answers

How do I avoid repeatedly typing methods that create nodes and append nodes?

I have researched my question and not come up with any thing. I may be lacking the proper buzz words that relate to the question... I have a method inside of an object that creates p elements and then appends them to an unorderedlist, it works…
Tylor
  • 309
  • 4
  • 9
0
votes
1 answer

Shorter way to make properties read-only

I read on many sites that if I want to create a read-only property, I should use the property decorator. Like this: class MyClass(object): def __init__(self): self._a = None @property def a(self): return self._a I think this is a…
Praind
  • 1,551
  • 1
  • 12
  • 25
0
votes
3 answers

Can I use a table from the WITH clause in the IN clause?

In attempt to write more readable SQL code by following this recommendation, I'm trying to use the WITH clause. It works here: WITH t AS ( SELECT * FROM TABLE1 WHERE COL1 = 'foo' …
d_w
  • 85
  • 6