Questions tagged [code-readability]

Code-Readability is how easy it is to understand a piece of code. Whether it be reading someones code, or writing your own.

Code-Readability is how easy it is to understand a piece of code. Whether it be reading someones code, or writing your own. This includes Coding Conventions, positioning of white space, declaration of variables and among other coding practices.

337 questions
10
votes
11 answers

sentimental code

I've come across an article that discusses the issue of "code admiration". Basically, the author talks about how developers should be more skeptic about code they write. How we may "admire" our code too much, attach our-self to it, making us more…
unknown
10
votes
7 answers

Most elegant way to deal with singles/plurals?

Say you're making a blog software, and want to show the number of comments an entry got. You might do it this way: [Entry title] [Content........] [ Comments] Which might result in: [Entry title] [Content........] 5…
Ali
  • 261,656
  • 265
  • 575
  • 769
9
votes
1 answer

Python Shelve Module Memory Consumption

I have been assigned the task of reading a .txt file which is a log of various events and writing some of those events into a dictionary. The problem is that the file can sometimes get bigger than 3GB in size. This means that the dictionary gets too…
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241
9
votes
5 answers

Tools and techniques to improve comprehension of unfamiliar code?

I've realised that my greatest weakness as a programming student is my poor ability to comprehend other people's code. I have no trouble whatsoever with 'textbook' code, or clearly-commented code, but when given a program of a few hundred lines,…
Eilidh
  • 1,354
  • 5
  • 21
  • 43
9
votes
8 answers

Managing number of brackets in clojure

I am new to clojure and the main thing I am struggling with is writing readable code. I often end up with functions like the one below. (fn rep ([lst n] (rep (rest lst) n (take n (repeat (first lst))))) ([lst n out] (if …
Jim Jeffries
  • 9,841
  • 15
  • 62
  • 103
8
votes
2 answers

Where to place __all__ in a Python file?

I am wondering, what the standard placement in a Python file for __all__? My assumption is directly below the import statements. However, I could not find this explicitly stated/asked anywhere. So, in general, where should one place __all__? Where…
Intrastellar Explorer
  • 3,005
  • 9
  • 52
  • 119
7
votes
4 answers

How Do I Avoid Line-Break Padding?

My biggest gripe with HTML is that line breaks add a tiny bit of space between elements. (jsFiddle.) This can screw up layouts where child elements are sized to exactly fit their parents. I read somewhere that you can remove this implicit padding -…
Maxpm
  • 24,113
  • 33
  • 111
  • 170
7
votes
4 answers

Is it okay and/or normal to use #include to put large chunks of repetitive code into a separate file?

I have been dissecting some code and I saw something I haven't seen before, and I was wondering if it is a good/bad practice and if it is normal. Basically there is a header file with a class definition for a class with a bunch (around 90) of pure…
7
votes
1 answer

How can I get @getter and @setter?

I often see the following annotations in code: @Getter @Setter public int test = 1; I know I can create getter and setter methods using this annotations. But which classes/library do I need to use these annotations?
Shapci
  • 155
  • 2
  • 2
  • 5
7
votes
4 answers

How to reduce code bloat in C from error handling & debugs

Consider this function: int get_result(int *result) { int err = 0; int number = 0; if (result == NULL) { printf("error: null input\n"); return -1; } err = get_number(&number); if (err != 0)…
Akeel
  • 301
  • 1
  • 7
7
votes
1 answer

Pipe a single object and process it without For-EachObject

Original Question I a piping a single string and processing it with For-EachObject as follows: "Test" | % { $_.Substring(0,1) } It seems wrong to process a single piped item using For-EachObject, partly because it's misleading to future code…
Shaun Luttin
  • 133,272
  • 81
  • 405
  • 467
7
votes
14 answers

What the ugliest API for a relatively well known library that you have seen, and why and how could it be improved?

I have been looking at the differences between Lucene 2.9 particular the redone tokenstream API and it just occurs to me its particularly ugly compared to the old just return a new or repopulate the given with values if your reusing said Token. I…
mP.
  • 18,002
  • 10
  • 71
  • 105
6
votes
7 answers

chunk of code that's called only once - merits own method?

From observing source code for various Android applications (not written by me), I noticed a pattern of placing certain pieces of code into their own methods, although there really isn't any code reuse, because those methods are only called once…
an00b
  • 11,338
  • 13
  • 64
  • 101
6
votes
2 answers

Dealing with type changing side effects in TypeScript

This is more of an open Question on how to deal with functions that have type altering side effects in TypeScript. I know and strongly agree with the notion, that functions should have as few side effects as possible, if any. But sometimes, it is…
6
votes
3 answers

Reasoning behind no space between Generic brackets in Java

Looking at GenericWhitespaceCheck in Checkstyle docs, Left angle bracket (<): should be preceded with whitespace only in generic methods definitions. should not be preceded with whitespace when it is precede method name or following type…
Adwait Kumar
  • 1,552
  • 10
  • 25
1 2
3
22 23