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

Using RegEx for simple operations

I was wondering if there might be some reason someone would want to use a regular expression for a problem that could also be written easily without using regular expressions. I came to this thought because of this question. The question is…
Subler
  • 657
  • 6
  • 11
2
votes
1 answer

Should you use named functions when developing a JavaScript library?

For example: module.exports = { myLibraryFunction: function myLibraryFunction() { ... } } The disadvantage is obvious. It's not very DRY, which means it can easily become out-of-sync if you're not careful. It also makes your code a little…
Joe
  • 16,328
  • 12
  • 61
  • 75
2
votes
3 answers

inline methods and code readability in modern C++

Alright, so sometimes my "coding brain" skips a gear; once in a while you can hear the gears grind. (For instance, every once in a while I write class Foo : Bar {} before reminding myself that's not proper anymore -- and hasn't been in a long…
John Price
  • 556
  • 1
  • 6
  • 18
2
votes
1 answer

How to Initialize the Task Object?

This question is trivial and it is for readability. I would just like to know weather the following line of code has any alternative ? Is that code is correct in the means of Readability and style? Task newTask = new Task(() => { }); EDIT: This…
Rajesh Subramanian
  • 6,400
  • 5
  • 29
  • 42
2
votes
2 answers

How to wrap selection in curly brackets in sublime text 2 with correct indentation?

Is there a way to improve Sublime text 2's curly bracket wrapping? For example, I have the following PHP code: $isThisPointless = true; $uselessString = 'Meh.'; $uselessInt = 83; Let's say I want to wrap it inside an if statement. So I go ahead,…
2
votes
4 answers

When can I get away with using short variable names?

I often find that people stress using variable names that appropriately and accurately describe what the variable is trying to convey. This is also often very hard to do in a word or two. I find it true that though longer names are typically more…
jwalk
  • 1,120
  • 11
  • 27
2
votes
9 answers

How can a total, complete beginner read source code?

I am a complete, total beginner in programming, although I do have knowledge of CSS and HTML. I would like to learn Python. I downloaded lots of source code but the amount of files and the complexity really confuses me. I don't know where to begin.…
Frank
  • 39
  • 4
2
votes
0 answers

When to use internal function and when not to?

I am using more and more javascript in my work and wonders what is good practice when it comes to the examples below. function foo(){ //do stuf var bar = foo2(); //do stuf function foo2(){ //do stuf return aValue; …
Mikael Holmgren
  • 2,466
  • 1
  • 18
  • 27
2
votes
5 answers

Good Coding Practices: When to Create New Functions

I have a certain function that uses the same (few, 2-5 depending on how I may change it to accommodate possible future uses) lines of code 4 times. I looked at this question, but it's not specific enough for me, and doesn't match the direction I'm…
Chris Cirefice
  • 5,475
  • 7
  • 45
  • 75
2
votes
3 answers

Patterns for declaring functions for greater readability

In C++ functions needed to be declared before they were called. This could be worked around with function signatures but for the most part this is no longer required in newer programming languages, C#, Python, ETC. However, while reading other…
QueueHammer
  • 10,515
  • 12
  • 67
  • 91
2
votes
2 answers

Scipy Sparse Row/Column Dot Products

What is the readable and efficient way to compute the dot product between two columns or rows of a sparse matrix using scipy? Let's say that we want to take the dot product of two vectors x and y, two columns of sparse matrix A, then I'm currently…
Jon
  • 255
  • 2
  • 8
2
votes
3 answers

how to decide on a bool operators usage, performance issues vs readability

Having even more than two options to choose from, leads me to question, which one to choose, if the result / outcome is same. in .NET C# the following conditions are asking same question using different operators, so the question is , what…
LoneXcoder
  • 2,121
  • 6
  • 38
  • 76
2
votes
2 answers

Static and public positionning

I am working with Apache log4j (http://logging.apache.org/log4j/2.x/) and I realized that in their implementation they always declared their function like this: static public Logger getLogger(Class clazz) { return…
JohnJohnGa
  • 15,446
  • 19
  • 62
  • 87
2
votes
0 answers

Way to refactor javascript code

I am developing a sencha application from past 3 months. Application sources contain several JS files say 20 approx with each file containing 800 - 1000 lines of code on an average. The code is completely messy. It contains atleast 20% of dead,…
Vinay thallam
  • 391
  • 1
  • 7
  • 17
2
votes
1 answer

Return lines in input code causing gaps/whitespace between elements in output?

Possible Duplicate: Ignore whitespace in HTML I am trying to put images next to each other on a webpage. Here is my HTML: Yellow Tulip