A coding style is a set of conventions and practices used in software, such as naming classes, variables, and files.
2
votes
1answer
21 views
Scheme/Racket: idiomatic infix math evaluator
Inspired by xkcd and a couple of praising blog posts, I decided to try out Lisp. It seemed that the best-supported dialect was Racket, itself a variant of Scheme, so I went with that and wrote an ...
1
vote
1answer
37 views
Recursive Determinant
The following code I devised to compute a determinant:
module MatrixOps where
determinant :: (Num a, Fractional a) => [[a]] -> a
determinant [[x]] = x
determinant mat =
sum [s*x*(determinant ...
2
votes
3answers
114 views
Cleaner and/or more practical code for decimal/binary/hex converter
I've finally finished my converter and have determined that it works, but I'm trying to make it cleaner and/or more practical (primarily with the switch statements). I could probably put more things ...
0
votes
1answer
63 views
I've finally found a satisfactory way to create classes on JavaScript. Are there any cons to it?
Depending on external OO libraries is really bad, using prototypes/new has some limitations, using only hashes has others. Dealing with classes was always a pain in JavaScript and it didn't help that ...
1
vote
0answers
29 views
Vaadin web application
I am creating a web application for an enterprise and I would like to improve my way of coding, know what I do wrong and what I do well. I'll leave the main class' code here:
package com.puntobile;
...
3
votes
1answer
223 views
Which is better: the short, clever way, or the long, ctrl+c way?
The code below is equivalent. I can see pros and cons for both versions. Which one is better?
Short version:
character.on("key",function(key){
var action = ({
...
1
vote
1answer
79 views
Playing Card Class - is this right?
The Art and Science of Java, a course book that uses the ACM library has an exercise that reads like this.
Implement a new class called Card that includes the following entries:
• Named ...
1
vote
1answer
98 views
Code review for an abstract repository implementation
I have a repository abstract class that encapsulates pretty much all of the CRUD functionality:
public abstract class DataRepository<T> : IRepository<T>
where T : class
{
public ...
1
vote
1answer
123 views
Which code is better? And why?
I found two ways of writing the same program (one that only uses local variables, but no methods other than the main one) and other that uses one instance variable that is used in two methods.
This ...
2
votes
2answers
101 views
How can I improve this coin flipping code?
I am doing exercises for the Art and Science of Java textbook. I had an exercise that required me to program the simulation of flipping a coin until 3 consecutive "Heads" result appeared.
I did it, ...
2
votes
1answer
94 views
What steps to turn python code into python zen code
My python code is ugly and I'm having difficulty improving it. What kind of steps could be done here to make it. This is an example function that comes from time to time and I can't seem to have a ...
0
votes
1answer
53 views
How to make proper code out of this function
public function getStuff($brand)
{
$web=FALSE;
if($this->getWebcorners()):
foreach ($this->getWebcorners() as $webcorner):
...
4
votes
1answer
139 views
How do I make this code unit-testable?
I have a functionality that imports data into a database, based on an Excel workbook and some meta data (both user-supplied). The functionality implements interface IFunctionality which essentially ...
0
votes
0answers
63 views
Hanoi Towers - need help with the code
I made an algorithm solving Hanoi Tower puzzles, for n disks and m pegs.
It uses lists as pegs, each list's element contains disks array - {0, 0, 0} means the peg is empty, {1, 2, 0} means the peg ...
1
vote
2answers
63 views
Looking for Python code review of database abstraction class
I'd be very thankful if some Python masters would take a look over the following class and review the code. There is no bug(not as far as I know anyway), the code is working as intended. But, since ...