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

More efficient and readable nested loop

I've created an algorithm which weighs the relevance of a list of articles against two lists of keywords that correlate to attributes of the article. It works great and is super efficient... but it's a mess. It's not terribly readable, so it's…
Wesley
  • 5,381
  • 9
  • 42
  • 65
0
votes
1 answer

Not using "self." to access class properties in Matlab

I have a class that its properties are often accessed by several nested indices, it works fine, but the code is ugly and unreadable: self.beta(self.index(self.act))=self.beta(self.index(self.act))+self.alpha*self.step(self.index(self.sv)); Is…
Arya
  • 145
  • 6
0
votes
1 answer

How to improve maintainability and readability of flags

I have inherited some code that I need to maintain with a server and client. Certain settings are currently passed on to the client via a set of flags of an in-house binary protocol. e.g., if (object.has.someAttribEnum == SYS_ON) settingsFlag =…
Vort3x
  • 1,778
  • 2
  • 20
  • 37
0
votes
2 answers

Fastest and most readable way to check three booleans

Similar to what is the fastest algorithm for permutations of three condition? and Fastest way to find correct combination with set of 8 booleans I have three boolean values (called a, b, and c), each of which has a different action based on which…
BitNinja
  • 1,477
  • 1
  • 19
  • 25
0
votes
0 answers

Python readability regex

Python is about reading the code and understands what is happening. That is what I like about Python. Regex is in general hard to read. codinghorror explains this very well, and also made a suggestion to split up the regular expression in multiple…
Bernard
  • 681
  • 1
  • 8
  • 21
0
votes
1 answer

Best way to implement RAII idiom in c#

I have a class which manipulates a resource which is shared by multiple threads. The threads pass around control of a mutex in order to manage access to the resource. I would like to manage control of the mutex using the RAII idiom via a…
bfair
  • 1,101
  • 7
  • 16
0
votes
1 answer

Using data from Readability Parser API

When using the Readability Parser API in Node.js: var request =…
GBC
  • 345
  • 3
  • 8
  • 23
0
votes
1 answer

Use "readabilitySAX" on distant pages, in Node.js

I want to get the length of articles published on newspapers and magazines websites and on blogs. In a server made in Node.js, I want to use the "readabilitySAX" module (https://github.com/fb55/readabilitySAX), but I must make a mistake with the way…
GBC
  • 345
  • 3
  • 8
  • 23
0
votes
0 answers

Encoding of content

I am writing program, which collects data (title,author,article) from web page with news article. I use Readability Python library. My problem is that content(which programm) of article (if article is written in cyrillic, if article is written in…
user3363858
  • 1
  • 1
  • 1
0
votes
3 answers

Add conditional in jquery handler or inside the function?

A simple favourites system. I wrote it like this: $(".favourite").click(function(){ // It's active; deactivate it if ($(this).hasClass('active')) { changeFavourites('remove', -1); } // It's not active; activate it else { …
Francisco Presencia
  • 8,732
  • 6
  • 46
  • 90
0
votes
1 answer

Readability mobilizer in commercial a iOS app

So as the title says, does anyone know, if I can use Readability's mobilizer in a paid app? I mean like using this: http://www.readability.com/m?url=http://www.cnn.com/2013/01/11/showbiz/tv/golden-globes-tv-vineyard/index.html?hpt=hp_abar in an app…
Skiny
  • 405
  • 1
  • 4
  • 16
0
votes
4 answers

Writing to a csv file in java

I am writing a java program to write data to a csv file which fetches a key's count value from database and writes the count corresponding to each key in the file. I have accomplished it using FileWriter whose pseudocode goes like below while…
Aarish Ramesh
  • 6,745
  • 15
  • 60
  • 105
0
votes
3 answers

Defining an interface with custom datatypes: how do I keep this readable?

I'm working on a library that is somewhat complex. It offers a bunch of DLL_EXPORTed functions which use some custom structs. At the moment, those structs are defined with the functions that use them, like so: struct MyDataType { std::wstring…
cf-
  • 8,598
  • 9
  • 36
  • 58
0
votes
4 answers

How can I alter CSS styling with Javascript to make links identical to normal text?

As you may already know, links reduce readability in online text. This is especially obvious in pages like Wikipedia science articles, where every other term is wikilinked and therefore in bright blue. I'm trying to make a Firefox addon with a…
Mike
  • 1,569
  • 2
  • 14
  • 20
0
votes
0 answers

How to utilize function names to make PHP logic more readable?

I see that the world is moving toward making code as expressive as possible. Some languages have even gone as far as allowing you to easily define your own DSL. However, I”m not sure how I can bring this into languages like PHP or pure Java or most…
Parham Doustdar
  • 2,019
  • 3
  • 22
  • 41