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

use macros for arguments

I am trying to create a macro wrapper around a function so I could make the code more intuitive on reading. Something like instead of calling send_message_to_destination(m, d) to write send(m)to(d). #include void send_data_to(int data,…
-1
votes
3 answers

Best way to write understandable and Python-friendly code

I have this code def testing1(terms, request): dat = datetime.now(pytz.timezone(geo_timezone(request))) __start = terms['year']+'-'+terms['month']+'-'+terms['day']+'T'+'00:00:00'+dat.strftime('%z')[:-2]+':'+dat.strftime('%z')[-2:] __end…
Carlos Rodriguez
  • 833
  • 8
  • 12
-1
votes
5 answers

Is for keyword obsolete like goto in modern object-oriented languages?

Is for keyword obsolete or may become obsolete just as goto in languages like C# or Java? In a few years, will it be strange and suspicious to see an object-oriented code which uses for, like today, it's very suspicious to see gotos? In other words,…
Arseni Mourzenko
  • 50,338
  • 35
  • 112
  • 199
-1
votes
1 answer

Readable way to form pairs while available

I'm trying to turn a list into pairs, but only for as long as possible (i.e. my list can be odd, in that case I want to ignore the last element). E.g. my input is x = [0, 1, 2, 3, 4], which I would want to turn into [(0, 1), (2, 3)]. Similarly, x =…
Joost
  • 4,094
  • 3
  • 27
  • 58
-1
votes
2 answers

Is there a way to avoid encapsulating javascript in parenthesis yet still get the benefits?

Lately, I've noticed javascript convention has been shifting. Now, wherever I look, I see other developers using javascript are wrapping their functions in parenthesis to make it private (or something like that I'm not sure, javascript is a…
lilHar
  • 1,735
  • 3
  • 21
  • 35
-1
votes
1 answer

Sectioning off code with comment blocks for readability. Good or bad idea?

So I recently started programming and sometimes I feel to need to separate my code with comment blocks like…
Gary
  • 11
  • 1
  • 5
-1
votes
3 answers

Where should function prototypes be declared?

Where exactly should the prototypes be declared? For example right after the include statments, or right before the main method? I know they both compile but is one considered more standard or more redable? #include #include…
Celeritas
  • 14,489
  • 36
  • 113
  • 194
-1
votes
1 answer

Performance with unneccessary scopes

Does it decrease performance or is it bad practice if I create scopes which aren't necessary? By that I mean, creating scopes just for readability: XmlElement header = list[0] as XmlElement; if (header == null) throw new Exception("Corrupt…
SharpShade
  • 1,761
  • 2
  • 32
  • 45
-1
votes
2 answers

Improving readability without losing performance?

Let's assume that I have three functions f0, f1, f2 that all take three arguments. Let's also assume that I have a big function bigFunc to call, that takes the return values from the first three functions as arguments. I may want to make a call like…
Eternal
  • 2,648
  • 2
  • 15
  • 21
-1
votes
1 answer

null coalescing operator in accessor method

i was looking around in stackoverflow whether putting null coalescing operators within an accessor method has any performance implications. Before: private Uri _Url; public Uri Url { if(_Url == null) _Url = new…
Lee Gary
  • 2,357
  • 2
  • 22
  • 38
-1
votes
1 answer

Program/Tool for more readable Java code?

I am currently looking for a program/tool that enhances the readability of a Java code. For example that it can convert the expression x=y +z+ 3; into x = y + z + 3; or the one of public class Example { public…
user2276872
-1
votes
1 answer

SPQuery versus generic list in Sharepoint

I need to traverse through a sharepoint list and get a count of some of the column values. for eg, in office(col1), if Name(Col2), Smith(Val2) is present twice then the count=2. I have to create a webpart that displays these counts. It looks…
-2
votes
1 answer

Initialization with tuple keyword vs parenthesis in python

This question is about design and readbility, not performance: Is it more pythonic to initialize tuples with the tuple keyword, or just with parenthesis? Both do the same thing, but explicitly typing tuple is more verbose. Here's two different cases…
-2
votes
1 answer

My code for CS50x Harvard on edX problem set 2 doesn't give back the expected output

I am taking CS50x Harvard on edX, and I'm currently working on problem set 2, readability. I've compiled my code, and it should work to determine the reading level like it's supposed to. However, every time I run the program, no matter what I put in…
-2
votes
2 answers

Readability of dict.get with a default value

Here is the traditional way to get a value by key from dictionary with a default value provided as fallback: value = dictionary.get(key, default) However, I came up with leaving the default value omitted in get and using the or-trick instead: value…
Arthur Khazbs
  • 705
  • 8
  • 19
1 2 3
48
49