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

Which is fast : Query Syntax vs. Loops

The following code provides two approaches that generate pairs of integers whose sum is less than 100, and they're arranged in descending order based on their distance from (0,0). //approach 1 private static IEnumerable> …
Nawaz
  • 353,942
  • 115
  • 666
  • 851
4
votes
3 answers

Should I include files included in another header?

Most often when creating multiple classes inside a program that use each other, I like to include only the minimum number of header files I need to reduce clutter. For example, say class C inherits from class B, which contains class A. Now of course…
wrongusername
  • 18,564
  • 40
  • 130
  • 214
4
votes
8 answers

How do I find methods?

Here's a somewhat general computer question. I've always been able to follow the LOGIC of programming, but when I go to code something, I always find that I don't know some method or another to get what I need to get done. When I see it, I always…
joe
  • 77
  • 4
4
votes
1 answer

What's the normal way of organising a header file in Objective-C?

I do start off organising my .h files with the best intentions but somehow they get disgustingly messy. Below is an example (which isn't that bad, but i've seen much worse!). I've tried grouping sections with #pragma mark but it seems to look even…
Jamie Chapman
  • 4,229
  • 5
  • 29
  • 47
4
votes
3 answers

Checking error parameters in node

It is a convention in node to pass an error parameter to asynchronous operations: async.someMagicalDust(function(callback) { // some asynchronous task // […] callback(); }, function(err) { // final callback if(err) throw…
Pierre Arlaud
  • 4,040
  • 3
  • 28
  • 42
4
votes
1 answer

How to structure R code for inherently nested problems to be easily readible?

There are problems that inherently require several layers of nesting to be solved. In a current project, I frequently find myself using three nested applys in order to do something with the elements contained in the deepest layer of a nested list…
Eike P.
  • 3,333
  • 1
  • 27
  • 38
4
votes
2 answers

How to effectively read and write Lisp code?

I'm currently learning Lisp, and I think that I got the basics (I'm using the excellent book Land of Lisp, and so far I've read and worked through about a quarter). I try to create my own Lisp programs, based on what I already learned. Somehow, it…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
4
votes
2 answers

Using Unicode in source files and and lack of unicode symbols

Ever since I learned that clang was able to compile c++ source files written in Unicode, I began to use it heavily when writing math-related code. Compare uₙ₊₁ᵖ = A*uₙ + B*uₙ₋₁; uₙ₊₁ᶜ = π * Aₜₒₜ; uₙ₊₁ = uₙ₊₁ᵖ + uₙ₊₁ᶜ; and u_n1_p = A*u_n +…
Bérenger
  • 2,678
  • 2
  • 21
  • 42
4
votes
4 answers

Overhead of 'this' keyword

This seems like it could be a common question but I searched SO and Google and couldn't find quite what I'm looking for: What is the overhead of calls to the this keyword in Java? I know in C++ there is some minimal overhead due to dereferencing…
Mark Hazlewood
  • 453
  • 1
  • 3
  • 7
4
votes
3 answers

Are there other ways to deconstruct option types in OCaml?

OCaml's option type is really useful in cases where you have functions that might not return anything. But when I use this in many places, I find it cumbersome to handle the Some case and the None case all the time in a match ... with. For…
Jason Yeo
  • 3,602
  • 3
  • 30
  • 38
4
votes
9 answers

General programming - else or else if for clarity

In a situation where a variable could have two different values, and you do something if its one, something differnent if its the other, would you just do: if(myVariable == FIRST_POSSIBLE_VALUE) { ... } else { ... } or would you do: if(myVariable…
mk12
  • 25,873
  • 32
  • 98
  • 137
3
votes
2 answers

Easily generate edge list from specific structure using pandas

This is a question about how to make things properly with pandas (I use version 1.0). Let say I have a DataFrame with missions which contains an origin and one or more destinations: mid from to 0 0 A [C] 1 1 A [B,…
jlandercy
  • 7,183
  • 1
  • 39
  • 57
3
votes
3 answers

Best Way to Format a Simple When Function in JS

I found this code in Ruby (from here): DX = { E => 1, W => -1, N => 0, S => 0 } and I was thinking about how to best format it in JS, given that it's lacking a "when" function. For reference, N, S, E, and W are "directions", and have aliases like…
Justin
  • 945
  • 12
  • 26
3
votes
5 answers

How to simplify a repetitive function

Is there a way anyone can think of to simplify this function? I find much of this quite repetitive but having a hard time thinking of a way to make it more pythonic or cleaner. Relatively new to python, so I'd appreciate any recommendations. def…
chachacha
  • 328
  • 1
  • 2
  • 10
3
votes
0 answers

How to Re-issue let's encrypt when new subdomains/mutiple domains added for Trafik on docker and also config refactoring

My previous effort to add additional domain was just to do docker-compose down remove the acme.json file add another section in traefik.toml for the new domain docker-compose up -d new acme.json was generated Now the problem is I tried the same…