Readability is a subjective parameter used to measure an aspect of code quality. It is based on the assumption that code should be easily comprehensible by humans, both in its form and in its meaning.

learn more… | top users | synonyms

2
votes
1answer
54 views

Bash pass multiple commands to SSH and make readable

I have a script that sends multiple commands after logging in a remote machine via SSH. Problem is, it's barely readable. I've tried quoting everything with "", but it's terrible (everything appears ...
9
votes
3answers
207 views

Proper capitalization for book titles?

I'm working through some exercises to sharpen my Ruby skills. The following code is how I solved this particular question. I'd like to know what other developers think of this solution. I'm self ...
7
votes
1answer
33 views

Importing data from an external EXCEL-Sheet

I was assigned the task of copying some subsums from a given EXCEL-Sheet into the executing EXCEL-Sheet. This had to be done with an EXCEL-Macro, so non-programmers can easily use it. There was the ...
9
votes
1answer
83 views

Project Euler “Even Fibonacci numbers” in Java 8

I'm looking for general advice on my code on the following problem: Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 ...
4
votes
3answers
67 views

What are my options for read-only access with many member variables?

I have a MouseInputHandler class that registers itself to an InputManager. When the InputManager class receives events they are forwarded to MouseInputHandler which changes it's state to reflect the ...
5
votes
0answers
51 views

Finding the next higher digital permutation of a number

This is my solution for CodeEval challenge 44. The function followingInteger takes a number in its decimal representation and returns the next higher permutation of the digits of the number. If there ...
13
votes
2answers
941 views

Java %= and general feedback

I'm doing a program for a course in school (intro software development) and I'm looking for some general feedback as well as any ways this bit of code could be cleaner. I'm also wondering if it is bad ...
2
votes
2answers
149 views

Return value when the requested variable returns null

I have a method that returns a list from a html page: private List<HtmlNodes> GetRelevantNodes(HtmlDocument aHtmlDoc, string aID) { List<HtmlNode> nodes = new List<HtmlNode>(); ...
12
votes
4answers
818 views

Better way to manipulate this string in sequence?

I am working on a small custom Markup script in Java that converts a Markdown/Wiki style markup into HTML. The below works, but as I add more Markup I can see it becoming unwieldy and hard to ...
4
votes
3answers
60 views

Mutual conversion operators

What is more readable? value / 60 / 60, value / 3600, or Hours{static_cast<Minutes>(*this).value / 60}? Should I use constants, i.e. SECONDS_IN_HOURS. Should I use the explicit keyword? Would ...
2
votes
1answer
112 views

How to make string.Format template more readable?

Have a look to the following example. Clearly it's very hard to understand the meaning of each parameter passed to the string.Format to be replaced to the numeric sequence of {0}, {1}, ... I want to ...
10
votes
5answers
664 views

Minimal Game of Life in C#

I want to learn how to write clean code from the start. This is my first project, a 'Minimum Viable Product' implementation of Conway's Game of Life in C#. Mostly I want to know if my code is ...
1
vote
1answer
66 views

Commenting in simple programs [duplicate]

I am struggling with commenting and variable-naming. My teacher said I need to add comments to my below code. I am not sure where I could add comments (I feel it is self explanatory) or what I ...
6
votes
1answer
138 views

Home-grown web service

I needed to build a one-way web service for a mobile app I developed. Its only goal is to receive incoming JSON data and insert it into the correct tables. It works, but it looks very "kludgy" and ...
5
votes
1answer
157 views

Newton's method to solve cubic equations

I have deleted the previous question I had posted, and am reposting the program with the new version of the code without the error present in the previous one. I have used the Newton-Raphson method ...
0
votes
2answers
57 views

Screenshot-scaling code

Please review for readability. /* Takes a screenshot of the current tab, then scales it to width and height. Returns null if the tab is smaller than width and height. Crops the screenshot to maintain ...
8
votes
3answers
116 views

How clear is this ruby code?

Elsewhere, there was a question about an elegant solution to a problem. I'm curious whether this solution is elegant from the perspective of easy to understand for a ruby programmer (which I am no ...
2
votes
2answers
127 views

Game launcher for The Sims 3

Is there a way I could improve my code's readability, or have I finally won the war against sloppy coding? Here's a game launcher I made for The Sims 3 to fix the awful performance caused by big ...
3
votes
1answer
165 views

Simplifying HTML parsing

I'm working on an app for my school (not homework, an app that's going to be used by students), that's supposed to display our week schedules. I get the data from a webapp, but it has no API that I ...
3
votes
1answer
106 views

Complete Hangman game

I would like to improve code readability and reduce the complexity of my code to improve the maintainability of the source code. If you have any tips, please say so. I was also wondering if it would ...
6
votes
2answers
106 views

python neural network: arbitrary number of hidden nodes

I'm trying to write a neural network that only requires the user to specify the dimensionality of the network. Concretely, the user might define a network like this: nn = NN([2, 10, 20, 15, 2]) # 2 ...
2
votes
3answers
177 views

Is this a good parser?

Is this a good C program for splitting a command line without doing any expansion on it? Don't worry too much about main() and the output -- those are for testing. #include <stdio.h> #include ...
3
votes
1answer
72 views

SASS Code Structure / Readability

I'm trying out a new approach to SASS stylesheets, which I'm hoping will make them more organizined, maintainable, and readable. I often feel like there is a thin line between code that is well ...
4
votes
1answer
60 views

Using Guava to reduce code complexity (and possibiliy to improve readability) of null check and assign default value

Below is my java code with some complexity, String input; double a; if (null != input && !input.isEmpty()) { a = Double.parseDouble(input); } else { a = defaultValue; } With Guava, ...
2
votes
4answers
162 views

How can I make this code more readable and efficient?

How can I rewrite this code to make it more readable and, if possible, more efficient? The conditions are entirely necessary in this problem, but how could I rewrite those if(a != 1) and such? celula ...
5
votes
1answer
114 views

GUI design in Java Swing

I am developing a GUI using Swing, but before my project gets too complex. I would like to have a good design structure. I have a few ideas and will use a simple example to illustrate. Some feedback ...
6
votes
3answers
84 views

Code Readability and Maintenance

I'm debating which version would be more suitable in parameters of code length, readability and maintenance. This is a portion of a set of functions which together parse a Gif file. Version 1: if ...
0
votes
0answers
30 views

Could this ROM reader be faster and/or smaller?

I've been practicing arduino programming for a few weeks now having become confident in reading and writing to pins so I decided to take it a step further and do a serious project that does both, so ...
3
votes
2answers
35 views

How to make the end of loop more readable in Ruby

There are some blocks in my code. To make it easier to read, I often append comment after the end such as end # end upto end # fileopen Because sometimes the indentation still not easy for ...
1
vote
1answer
62 views

Tic-Tac-Toe JavaScript readability and additional suggestions

Requires Underscore and jQuery I'm looking for suggestions on how to make this a little more readable and additional suggestions on flow, logic, etc. The game can be run in a browser by just ...
2
votes
1answer
206 views

Is this an elegant/accurate simulation of the Monty Hall problem?

I'm trying to simulate the Monty Hall problem, to statistically determine if there is any benefit to changing my choice after a door containing a goat is open (testing this guy's Monty Hall theory on ...
1
vote
0answers
109 views

Template parameter pack of parameter packs [closed]

Two things about C++11 variadic template syntax bother me because they make basic concepts hard to code and read. The choice of list operations allowed on parameter packs is arbitrary. The ellipsis ...
4
votes
0answers
98 views

Improving readability of Boolean adder generator?

Today I've noticed that the source code for a Boolean adder is very repetitive, so I wrote a Python script to generate the C source code. The script generates an adder of varying size depending on ...
2
votes
3answers
81 views

Function for encoding strings in-place

I recently wrote a function that replaces every white space with '%20', just for fun (and sharping my coding skills). The input string is terminated with extra white spaces, with the length that the ...
1
vote
2answers
108 views

Readable Ruby Gem

So the main purpose of Ruby is to be readable. I hope I did a good job with this gem I made. If there's any kind of suggestion of how to make this better, then please tell me. class Trigger # event ...
2
votes
1answer
141 views

Method names for encapsulated unit testing logic. Which convention is better?

I have some C# unit tests which each basically perform the same steps but supply different arguments to the unit under test. I wanted to encapsulate the logic inside some "helper methods" but found ...
2
votes
1answer
114 views

Review of String to Long bijection class - focus on readability/maintainabiliy

I wrote the following interface and class to bijectively map a string to a long. I would like feedback on how to make the code more readable and maintainable. Interface: /** * Bijectively maps a ...
3
votes
2answers
73 views

Can someone review my Rational implementation?

The header file can be viewed here. #include <stdio.h> #include <stdbool.h> #include <math.h> // searches default library classpaths #include "Rational.h" // searchs my directory // ...
1
vote
1answer
33 views

Can someone review my Polynomial data structure?

The following is working but I just want to know if I can make it better in any way. The header file can be viewed here. #include <stdbool.h> #include <stdlib.h> #include "Polynomial.h" ...
4
votes
4answers
271 views

More Pythonic way to write this is_palindrome function?

from string import punctuation, ascii_lowercase def is_palindrome(string): """Return True if string is a palindrome, ignoring whitespaces and punctuation. """ new = "" for char in ...
3
votes
2answers
188 views

get rectangle count from given co-ordinates code review

Problem Description Write a program to find the maximum number of rectangles that can be formed both horizontal and vertical with the help of a given n number of coordinate(x,y) points. [x,y points ...
2
votes
1answer
55 views

Which of these two is better in terms of readability and function?

I have two different ways of populating a List with querying another List. They are: var list = _surveyList.Where(x => x.Date == selectedDate).Select(s => s.Joint).ToList(); And: var list = ...
3
votes
2answers
142 views

Is the use of Struct or Class personal preference?

I have a solution in which I instantiate a class with various types inside of it. I feel it is becoming to cumbersome to instantiate and then create variables for each of the types I want to access ...
1
vote
1answer
91 views

Is there a more readable version of this code? [closed]

Coworker put this in a pull request. I don't understand what exactly it's doing, I think it's the single-letter variable names, but is there something else that causes it to be slightly unreadable, or ...
2
votes
0answers
123 views

How can I improve my A* Pathfinding code? (again!)

Done this already, but looking to improve it even more. Nearly time to hand this project in, and I want it to be as close to perfect as possible. So, any issue (No matter how small) - Let me know. If ...
2
votes
2answers
1k views

Maximum Subarray Problem - Iterative O(n) algorithm

I implemented an iterative O(n) algorithm for solving the maximum sub-array problem. I would like a general review for it. Here the max_subarray is the main function and the ones which are static are ...
5
votes
1answer
423 views

Maximum Subarray Problem - Recursive O(n log n) algorithm

I have implemented a recursive O(n log n) algorithm for solving the maximum sub-array problem. I would like a general review for it. Here the max_subarray is the main function, and the static one is ...
1
vote
3answers
103 views

Making my code better. I'm new(ish) to PHP

<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Add New Games</title> <meta name="viewport" ...
3
votes
1answer
92 views

URL percent encoding function

I wrote a custom URL encoding function and I'd like to run it past a few other experienced C developers. I have tested it on a few strings, and it has worked on all of them. This is to be run on ...
3
votes
1answer
256 views

How to separate code into smaller classes using SOLID principles

I have a console application that basically retrieves xml content, writes to the xml file and sends the file to sftp site. This may seem long post but I believe it is simple stuff that need advise on ...