The readability tag has no wiki summary.
3
votes
3answers
74 views
Blackjack card game
It's been a long while since I've done any Python programming so I thought I'd start with a simple blackjack game. Any comments on how I can make this more readable? Use more methods perhaps?
from ...
2
votes
3answers
37 views
Building and getting a form of objects that have multiple properties
I'm building a form dynamically in a web app where I'm using product_id to keep track which product I'm reading and then product_<id>_property to grab the value of it. Then in my view I end up ...
3
votes
2answers
129 views
Refactor to make intention clearer and testable
I'd like to improve the readability of the following code. The aim of this code is to apply formatting to row(s) in a WinForms DataGridView based on the Priority of an item, determined either by its ...
1
vote
2answers
59 views
Get device orientation
Here is my code:
// get orientation of device
getOrientation();
// animate
var num = 400;
if( $('body').hasClass("landscape") ) {
$('.example').animate({'bottom', 0});
} else {
...
5
votes
2answers
109 views
Boolean enums: improved clarity or just overkill?
Suppose we are writing a GUI toolkit in C++ (though this question may also apply to other languages). We have a button class with a member function hide, which hides the button. This member function ...
8
votes
4answers
231 views
Reduce length of condition
Is there a way to reduce this lengthy if condition:
if(
statusCode.equals( NO_ERRORS_NO_WARNINGS ) ||
statusCode.equals( HAS_ERRORS_NO_WARNINGS ) ||
statusCode.equals( ...
2
votes
1answer
82 views
Is this good Ruby?
This is the "codebreaker" game in Ruby, tell me what I can make better!
#!/usr/bin/env ruby
class Sequence
attr_accessor :guess, :code
def initialize
puts "Type the difficulty level you ...
1
vote
1answer
71 views
Review request: snippet of custom array.indexOf that supports nested arrays
I recently wrote a snippet to make a custom array.indexOf but with nested array support in addition to allow using a nested array as needle.
For example, it correctly returns the index 3 in this ...
1
vote
1answer
31 views
Which name should I choose for private abstract functionality with a public proxy?
I have an abstract class implementing some concrete functionality for its child classes:
abstract class Function {
def eval: Double = some_concrete_functionality_which_calls_fEval
def simplify: ...
1
vote
1answer
148 views
Review my prolog code for bibtex reader
I am trying to learn Prolog, and wrote a bibtex reader using gnu prolog.
I would like some feed back on my code in terms of: the way I write Prolog, and how it can be improved.
I am new here, and ...
5
votes
3answers
291 views
Code Readability vs Code Length
library.php
My own HTML tag encoder that will print HTML codes according to the input.
<?php
function tag($tagname, $content = NULL, array $properties = NULL)
{
$html = ...
2
votes
1answer
100 views
Logic/Code duplication, improve readability?
I have a function that takes a point, and given its velocity, and acceleration, calculates the time(s) for the point to collide with the line:
def ParabolaLineCollision(pos, vel, acc, line):
"""A ...
2
votes
1answer
64 views
How can my code for computing a Discrete Cosine Transform matrix be improved?
I'm learning Haskell and decided that my first program should also help me finish my homework (because if I'm going to procrastinate, why not make it worthwhile?). I needed to work with discrete ...
3
votes
1answer
113 views
Longest non-decreasing subsequence, in Haskell
OK, so I recently posted this solution in Python to the longest non-decreasing subsequence problem, and cleaned it up with some expert advice. As a next step, I wanted to translate this solution into ...
4
votes
1answer
343 views
Pie Chart jQuery-UI plugin
I would greatly appreciate the input of any gurus out there. I have recently begun learning JavaScript and then jQuery and jQuery-UI and have thought I would take a stab at writing my own jQuery-UI ...