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
4 answers

How to split a statement into multiple lines?

What would be the proper Pythonic way to break the first line of the below expression (to appear on multiple lines) so it can be more readable: if props.getProperty("app.auth.idp.strategy") == '' or props.getProperty("app.auth.idp.strategy") ==…
Simeon Leyzerzon
  • 18,658
  • 9
  • 54
  • 82
0
votes
1 answer

Joining a returned (promise-esq) Observable and a global observable

In my web app's client code I have a class responsible for a bunch of websocket IO. This class has a global itemUpdatedObservable that various parts of the UI can subscribe to to do little things. There is also a public function UpdateItem which…
0
votes
1 answer

Angular 2+: Angular way of breaking down large component.ts file

This question pertains to code organization. I am the author of an Angular package called ng-simple-slideshow. By far the longest file is the component.ts file of the slideshow. It's so long that it's becoming hard to read. What would be the…
0
votes
1 answer

Python3.6 No module named "readability.readability"

I'm trying to use readability module, but the error below occurs. How can I be able to user "readability"? /usr/local/opt/python/bin/python3.6: No module named readability.readability the command I did is below. python -m readability.readability -u…
0
votes
1 answer

How to handle outliers in this octave boxplot for improved readability

Outliers between 1,5 - 3 times the interquantile range is marked with an "+" and above 3 times the IQR with an "o". But due to this data set with multiple outliers the below boxplot is very hard to read since the "+" and "o" symbols are plotted on…
johlund
  • 137
  • 7
0
votes
2 answers

Is it worth while creating a custom annotation to show that a method is simply helping readability?

Currently working with Spring and I've been learning about methods I can use to help the readability of my code, with one example being replace complicated conditionals with an easy to understand method call. For example: private void myMethod(){ …
0
votes
2 answers

What is the best practice to use nested AsyncTasks?

In my Android app I have up to 4 asynchronous tasks that depend on each other, which means that one task has to finish before the next one can go one with the retreived data. Now this can be quite unclear at some point when the code looks something…
Bautzi89
  • 346
  • 1
  • 5
  • 21
0
votes
0 answers

How can a repeated pattern of struct assignment be condensed to a simpler expression?

I am writing code to do finite volume method operations on an NI*NJ size grid, where all the values are stored in a 1D array, defined as in comment section 1. The double loop moves through each grid element and performs calculations for the grid…
teepee
  • 2,620
  • 2
  • 22
  • 47
0
votes
0 answers

Alternative implementation of JDK's Collection.toArray(T a)

Browsing through some JDK source code I found the following implementations of Collection.toArray() and toArray(T[]) in AbstractCollection: public Object[] toArray() { // Estimate size of array; be prepared to see more or fewer elements …
Reizo
  • 1,374
  • 12
  • 17
0
votes
2 answers

Is it good practice to increment a factorial in a for loop's increment statement rather than the body of the for loop?

I am wondering if it is good practice to increment a factorial within the increment statement of a for loop rather than the body of the for loop? Below shows the factorial being incremented multiplicatively within the increment statement: for(Count…
0
votes
3 answers

More elegant way of comparing Objects implementing Comparable

I have the following objects (assuming the class Rank implements Comparable): Rank rankA; Rank rankB; I would compare them like this: if(rankA.compareTo(rankB) < 0) // rankA < rankB doSomething(); or if(rankA.compareTo(rankB) == 0) // rankA…
domisum
  • 531
  • 1
  • 7
  • 12
0
votes
1 answer

Can I make a long fish array easier to read and maintain?

I am writing a simple script in fish. I need to pass in an array as follows: set PACKAGES nginx supervisor rabbitmq-server apt install $PACKAGES But as the array gets longer it gets harder to read and maintain... set PACKAGES nginx supervisor…
lofidevops
  • 15,528
  • 14
  • 79
  • 119
0
votes
2 answers

Pythonic way of handling long method calls inside classes

Suppose we have a class class foo(): def __init__(self): self.data = 10 ... def method(self): ... self.free_indices.append(self.l[self.start_p]) var1 = self.l[self.search(var2[num])].pointer …
Nick Boe
  • 1
  • 1
0
votes
2 answers

Does chunking via itertools vs straight python buy you anything extra?

I came across two different ways to split an iterable into "chunks" (more than 1 item). One method uses itertools: from itertools import izip_longest def grouper(iterable, n, fillvalue=None): args = [iter(iterable)] * n return…
Trevor Boyd Smith
  • 18,164
  • 32
  • 127
  • 177
0
votes
2 answers

Filtering list of tuples - better readability

What is a good way( read better readability) to filter a list of tuples. I'm using tupleList.filter(_._2).map(_._1) But this does not feel readable.