Readability measures how easy code is to read and understand.

learn more… | top users | synonyms

-1
votes
2answers
447 views

Why is there never any controversy regarding the switch statement? [closed]

We all know that the gotostatement should only be used on very rare occasions if at all. It has been discouraged to use the goto statement countless places countless times. But why it there never ...
8
votes
5answers
629 views

Which is more maintainable — boolean assignment via if/else or boolean expression?

Which would be considered more maintainable? if (a == b) c = true; else c = false; or c = (a == b); I've tried looking in Code Complete, but can't find an answer. I think the first is more ...
4
votes
1answer
245 views

Distinguishing repetitive code with the same implementation

Given this sample code import java.util.ArrayList; import blackjack.model.items.Card; public class BlackJackPlayer extends Player { private double bet; private Hand hand01 = new Hand(); ...
54
votes
18answers
4k views

Are long methods always bad?

So looking around earlier I noticed some comments about long methods being bad practice. I am not sure I always agree that long methods are bad (and would like opinions from others). For example I ...
8
votes
3answers
593 views

What happens to programmers most oftenly while reading the code of others?

When reading others code do you usually have any troubles understanding it, Or its more usually that you question the others code about it being wrong/non-efficient/bad-formatted(etc)? Someone ...
-1
votes
1answer
181 views

Checking timeouts made more readable

I have several situations where I need to control timeouts in a technical application. Either in a loop or as a simple check. Of course – handling this is really easy, but none of these is looking ...
5
votes
5answers
1k views

Functional programming readability

I'm curious about this because I recall before learning any functional languages, I thought them all horribly, awfully, terribly unreadable. Now that I know Haskell and f#, I find it takes a little ...
3
votes
3answers
2k views

What defines code readability? [duplicate]

Possible Duplicate: How would you know if you've written readable and easily maintainable code? It is often said that readability is perhaps the most important quality-defining measure ...
16
votes
9answers
1k views

Hiding away complexity with sub functions

I am having a discussion on code style, and it's starting to sound like a "matter of taste". I strongly believe otherwise, so I'm writing this to get your opinion and learn from your arguments for and ...
15
votes
4answers
438 views

Studies on how well can a programmer understand code in unfamiliar languages? [closed]

Are there any serious studies on how well an experienced programmer who knows language X can understand code written by a competent programmer using language Y, for a good range of widely used ...
7
votes
7answers
544 views

Using empty subclasses to add to the semantics of a class hierarchy?

I was wondering whether using (almost) empty derived classes to give additional semantics to a class hierarchy was a good idea (or practice) ? Because a (not so short) example is always better than a ...
9
votes
5answers
790 views

Zero as a constant?

I have come across this programming idiom recently: const float Zero = 0.0; which is then used in comparisons: if (x > Zero) {..} Can anyone explain if this is really any more efficient or ...
10
votes
6answers
2k views

Is C# becoming harder to read?

As C# has progressed, many language features have been added. It has come to the point where it's becoming unreadable for me. As an example, consider the following code snip from Caliburn.Micro code ...
32
votes
8answers
1k views

When using method chaining, do I reuse the object or create one?

When using method chaining like: var car = new Car().OfBrand(Brand.Ford).OfModel(12345).PaintedIn(Color.Silver).Create(); there may be two approaches: Reuse the same object, like this: public ...
34
votes
15answers
4k views

Is it bad practice to name an unused variable with a single underscore?

Often when the syntax of the language requires me to name a variable that is never used, I'll name it _. In my mind, this reduces clutter and lets me focus on the meaningful variables in the code. I ...
26
votes
5answers
2k views

Is use of finally clause for doing work after return bad style/dangerous?

As part of writing an Iterator, I found myself writing the following piece of code (stripping error handling) public T next() { try { return next; } finally { next = ...
7
votes
4answers
675 views

Readability of || statements

On HTML5 Boilerplate they use this code for jQuery: <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> <script>window.jQuery || ...
1
vote
3answers
206 views

Which of these looks cleaner?

I have wrote a small method in a program to do one thing my method looks like this: public static void removeExpiredAssignments(Module module){ module.removeExpiredAssignments(); } So the ...
19
votes
7answers
2k views

while(true) and loop-breaking - anti-pattern?

Consider the following code: public void doSomething(int input) { while(true) { TransformInSomeWay(input); if(ProcessingComplete(input)) break; ...
107
votes
20answers
10k views

How would you know if you've written readable and easily maintainable code?

How would one know if the code he has created is easily maintainable and readable? Of course in your point of view (the one who actually wrote the code) your code is readable and maintainable, but we ...
10
votes
6answers
1k views

Need to make my code more readable to the other programers in my team

I am working a project in delphi 7 and I am creating a installer for the application, there are Three main parts. PostgreSQL installation/uninstallation myapplication ( setup of myapplication is ...
10
votes
4answers
652 views

Should we rename overloaded methods?

Assume an interface containing these methods : Car find(long id); List<Car> find(String model); Is it better to rename them like this? Car findById(long id); List findByModel(String ...
2
votes
2answers
162 views

Trimming script size by using array notation for frequently accessed properties

I noticed some redundancy in a script I ran through Google Closure Compiler. (function(){function g(a){var k;if(a){if(a.call)a.prototype=j,a.prototype[e]={}}else a= {};var ...
8
votes
2answers
435 views

S-expressions readability

In a nutshell and for those who didn't know it, Lisp functions/operators/constructs are all uniformly called like this: (function arg0 arg1 ... argN) So what in a C-like language you would express ...
24
votes
15answers
2k views

Does simplicity always improve Readability?

Recently, I was developing a set of coding standards for our company. (We're a new team branching out into a new language for the company.) On my first draft, I set the purpose of our coding ...
3
votes
2answers
188 views

Parameter order: size, count or the other way round

I hope this is the right forum for this ... Well, in C, the standard library uses usually (void* buffer, int size) when referring to some data buffer. I wonder if there is a rationale for this order ...
21
votes
14answers
3k views

Why do so many developers believe performance, readability, and maintainability cannot coexist?

While responding to this question, I began to wonder why so many developers believe a good design should not account for performance because doing so would affect readability and/or maintainability. ...
6
votes
6answers
333 views

Formatting 'Complex' Math

Note: by 'complex' math I mean an equation with many steps involved and a wide mix of operators. A programmer should know the order that operators are evaluated in an equation. However it can be a ...
12
votes
11answers
326 views

Should 'mathematical' functions follow mathematical notation?

I suppose this question is going to be immediately flagged as subjective, but which do you think is better: double volume(double pressure, double n_moles, double temperature) { return n_moles * ...
8
votes
5answers
375 views

When developing on an old code base, should I use Best Practices or go for Consistency [duplicate]

Possible Duplicate: Code maintenance: keeping a bad pattern when extending new code for being consistent, or not ? As my experience in programming increases with each project, I look back ...
45
votes
6answers
2k views

Refactoring into lots of methods - is this considered clean or not? [duplicate]

So, I watched as my colleague complained a bit about a project he has inherited from someone who is, shall we say, not very experienced as a programmer (intern left to his own devices on a project). ...
48
votes
9answers
6k views

Clean readable code vs fast hard to read code. When to cross the line?

When I write code I always try to make my code as clean and readable as possible. Every now and then there comes a time when you need to cross the line and go from nice clean code to slightly uglier ...
4
votes
2answers
815 views

Using lookahead assertions in regular expressions

I use regular expressions on a daily basis, as my daily work is 90% in Perl (legacy codebase, but that's a different issue). Despite this, I still find lookahead and lookbehind to be terribly ...
2
votes
5answers
331 views

Run On Sentences in Technical Writing

This is just a question to think about. When you write technical documentation and programming comments, do you ever find yourself writing run-on sentences in order to be more precise? Is packing ...
3
votes
3answers
443 views

Readability vs minimalism/compactness/conciseness in language design: are they antagonistic?

Currently, there is a discussion in the PHP-Internals mailing list regarding the implementation of a short syntax for arrays and objects, mainly [1, 2, ...] for standard arrays, ['one'=>1, ...
4
votes
1answer
295 views

Are there any actual drawbacks to self-referential method chaining?

I recently suggested a method of chaining be implemented for a certain class in a certain project so readability of the code could be improved. I got a "fluent interfaces should not be implemented ...
4
votes
2answers
331 views

Indenting/breaking jquery chains for readability

I'm curious as to how other people indent/break long jQuery chains, as I can never decide what is more readable (particularly when using .end() to "close" a block of methods e.g. ...
12
votes
4answers
2k views

Good use of try catch-blocks?

I always find myself wrestling with this... trying to find the right balance between try/catching and the code not becoming this obscene mess of tabs, brackets, and exceptions being thrown back up ...
17
votes
3answers
1k views

Must source code released under GPL be human-readable?

In a response to another question, a poster suggested that under the GPL: ...you need to provide the human readable [code], not a whitespace stripped version... Readability would seem to me to ...
31
votes
11answers
1k views

Intentional misspellings to avoid reserved words

I often see code that include intentional misspellings of common words that for better or worse have become reserved words: klass or clazz for class: Class clazz = ThisClass.class kount for count in ...
5
votes
1answer
391 views

Where can I read exemplary Scheme code?

Edi Weitz's libraries are often brought up when people ask for exemplary code in Common Lisp, the kind to read and learn from. Are there any open-source Scheme projects or libraries that you can ...
1
vote
11answers
5k views

Avoid Postfix Increment Operator

I've read that I should avoid the postfix increment operator because of performance reasons (in certain cases). But doesn't this affect code readability? In my opinion: for(int i = 0; i < 42; ...
18
votes
7answers
6k views

How far should 'var' and null coalescing operator '??' be entertained without hampering readability?

I know the title of the question is very subjective, but I was confronted with usage of ?? operator by my peers, where at the same time I was not very happy/comfortable with applying var in new ...
62
votes
18answers
20k views

Are `break` and `continue` bad programming practices?

My boss keeps mentioning nonchalantly that bad programmers use break and continue in loops. I use them all the time because they make sense; let me show you the inspiration: function verify(object) ...
11
votes
4answers
6k views

How to determine if a programming language is verbose or terse?

Programming languages can often be described as verbose or terse. From my understanding, a verbose language is easy to read and understand, while a terse language is concise and neat, but more ...
29
votes
16answers
3k views

Should you sacrifice code readability with how efficient code is? [closed]

Should you sacrifice code readability with how efficient code is? e.g. 3 lines of code into 1 line. I read in Code Craft by Pete Goodliffe that readability is key. Your thoughts?
5
votes
4answers
2k views

Is nesting types considered bad practice?

As noted by the title, is nesting types (e.g. enumerated types or structures in a class) considered bad practice or not? When you run Code Analysis in Visual Studio it returns the following message ...
9
votes
6answers
1k views

Pythonic Java. Yes, or no? [closed]

Python use of indentation for code scope was initially very polemic and now is considered one of the best language features, because it helps ( almost by forcing us ) to have a consistent style. ...
10
votes
12answers
1k views

Maintainability of Boolean logic - Is nesting if statements needed?

Which of these is better for maintainability? if (byteArrayVariable != null) if (byteArrayVariable .Length != 0) //Do something with byteArrayVariable OR if ((byteArrayVariable != ...
22
votes
12answers
2k views

How do people manage to write and maintain extremely complex and hard to read code? [closed]

Reading SQLite source code is IMO mission impossible. Yet it is a usable piece of quite complex software (it's a full-blown embedded database after all) that can be downloaded, compiled and used from ...