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
6
votes
0 answers

C# 7 Nested Local Functions – easy to read?

C# 7 introduced local nested functions. They provide even better structure to the code but do they improve readability? Are there any standards, recommendations and best practices? What is easier to read for your eyes and aesthetic feelings? class…
user2341923
  • 4,537
  • 6
  • 30
  • 44
6
votes
2 answers

How can I hide tracing code in Visual Studio IDE C#?

As I'm starting to put more tracing in my code, i'm realizing it adds a lot of clutter. I know Visual Studio allows you to hide and reveal code, however, i'd like to be able group code into "tracing" code and then hide it and reveal at will as i'm…
Mark
  • 5,223
  • 11
  • 51
  • 81
6
votes
4 answers

Making SQL INSERT statement easier to read

I'm working on a program in Go, that makes heavy usage of MySQL. For sake of readability, is it possible to include the value of a column after each column name in an INSERT statement? Like: INSERT INTO `table` (`column1` = 'value1', `column2` =…
eggbertx
  • 463
  • 4
  • 14
6
votes
2 answers

Optimising treelike control structure

I have to create reports based on the user input. User answer a question, and then depending on the answer I go left or right in a treelike structure, and ask a new question. Some nodes will have the same question, but different children. I am not…
Marko D
  • 7,576
  • 2
  • 26
  • 38
5
votes
2 answers

header full of inline functions, can i move the code outside header file and still inline everything?

i have ended putting many little small inline function in a header file which i include in many compilation units, the code is correctly inlined by the compiler and the program works like a charm. but now the header file is something very unusual…
user975413
  • 51
  • 2
5
votes
2 answers

Does "var" keyword hampers code readability?

I just started using Resharper. One of its features is that it suggests changes to the code based on, i suppose, good coding practices. One of the changes it suggested is to change the variable type to var during assignment. I kept on changing and…
stackoverflowuser
  • 22,212
  • 29
  • 67
  • 92
5
votes
3 answers

Increase readability & maintainability : omit < > for many variable declaration possible?

The question seems very abstract. I will ask by an example instead. Introduction Assume that I have many types of game objects. They are Bullet, Rocket, Enemy, Zone, ... . They are all nicely created & deleted & managed by pools, e.g. Pool
javaLover
  • 6,347
  • 2
  • 22
  • 67
5
votes
7 answers

Java private method signature clarity and better practice

I received the code review comment for below code snippet - public void doWork(String a, Integer b) { .. .. SomeService service = getService(); for (Integer i : numbers) { doMoreWork(a, b, service); } } private void…
Bruso
  • 803
  • 3
  • 12
  • 25
5
votes
7 answers

Return vs. Not Return of functions?

Return or not return, it's a question for functions! Or, does it really matter? Here goes the story: I used to write code like the following: Type3 myFunc(Type1 input1, Type2 input2){} But recently my project colleges told me that I should try,…
herohuyongtao
  • 49,413
  • 29
  • 133
  • 174
5
votes
4 answers

How can this 6 line method be refactored to be more readable?

I'm trying to clean up this ridonkulously ugly method here, that's crying out for refactoring, but I'm not sure what kind of structure would do this best (i.e. a case statement, or simply a carefully formatted if then statements) At first glance, it…
Chris Adams
  • 2,721
  • 5
  • 33
  • 45
5
votes
2 answers

Can I use R attributes to save physical units?

Can I (should I) use R attributes to save physical units and similar information as hint for the user? epsilon0 <- 8.854188e-12 # name <- "electric constant" # source <- "CODATA" # unit <- "F m-1"
Jonas Stein
  • 6,826
  • 7
  • 40
  • 72
4
votes
8 answers

How should I deal with null objects in a using block?

Given a situation like this: using (var foo = CreateFoo()) { if (foo != null) { // do stuff } } I would like to avoid the nested if. Sadly, the obvious solution is not possible because break does not work with using: using (var foo…
mafu
  • 31,798
  • 42
  • 154
  • 247
4
votes
1 answer

Omitting the 'else' in PHP ternary and null coalescing operators

I was reading about and experimenting a bit with ternary and null coalescing operators in PHP. So, instead of writing if (isset($array['array_key'])) { $another_array[0]['another_array_key'] = $array['array_key']; } else { // Do some code…
4
votes
0 answers

Writing R-thonic code in R

What were the design decisions that led to R having often more than one way of doing things, that have subtle difference? See, for a good example, https://www.r-bloggers.com/r-na-vs-null/ More more such issues are here, some which are justified,…
l7ll7
  • 1,309
  • 1
  • 10
  • 20
4
votes
3 answers

Lodash Filter with Multiple Functions

Trying to figure out the cleanest way to do the following: I'm filtering some results twice, and I'm using Lodash filter to do so. Currently, my code looks like: resultsOne = _.filter(results, functionOne); resultsTwo = _.filter(resultsOne,…
user6506263