A sign of a possible problem in a program. Use this tag for code reviews where you can already "smell" something and would like others to confirm your thoughts or dissipate your doubts, and hopefully to propose ideas for making it "smell better".
1
vote
1answer
33 views
How can this jQuery be changed to be more manageable and readable?
I am working on a Python/Django project which has turned into a JavaScript/jQuery project due to the amount of asynchronous functionality that I thought to add.
There is a javascript file which is ...
2
votes
1answer
22 views
6
votes
2answers
71 views
5
votes
3answers
221 views
Shorten code to perform search based on four slash-delimited parameters
How can I make this code more compact?
It is a ASP.net WebForms project
It is a SinglePageApplication for searching in list mode and map mode.
I have many paths for a page.
/Denmark
...
5
votes
3answers
267 views
Regex match for a string in a URL
I feel like there is too much repetitive code going on here. All I am doing is doing a basic regex match for a string in the URL. If a match is found, I find an li with a class (.index, .grid, .type) ...
7
votes
2answers
149 views
Missing level of technical depth (Common Ancestor)
I recently have given a coding test in a reputable IT company. There were three coding questions.
They refused me by saying that
as we felt they didn't demonstrate the level of technical depth ...
5
votes
2answers
103 views
Missing level of technical depth (Flatten Tree)
I recently have given a coding test in a reputable IT company. There were three coding questions.
They refused me by saying that
as we felt they didn't demonstrate the level of technical depth ...
5
votes
1answer
133 views
Missing level of technical depth (Recursive to Iterative)
I recently have given a coding test in a reputable IT company. There were three coding questions.
They refused me by saying that
as we felt they didn't demonstrate the level of technical depth ...
5
votes
2answers
197 views
Thrice nested “OS” in Python
This Python main is what greets the user to a thrice nested super duper barebones OS. The entire rest of my code isn't bug free but this section is, and it feels dirty anyway. I'd like to know how ...
1
vote
0answers
40 views
AngularJS constants depending on other constants - any established patterns?
I'd like to be able to define Angular constants in terms of other constants.
It's not possible to inject dependencies into Angular constant services. When I want ...
4
votes
2answers
61 views
Can this localStorage login script be written more efficiently?
I understand that account details should be stored using a much more secure method, but this is only a demonstration script I've made to store login credentials and remember a user wishes to remain ...
3
votes
1answer
89 views
Format string inline
For this project, I do not have access to Boost or C++11.
Note: I updated the question's description to clarify what I am doing. I have not changed the code though, so no answer has been invalidated.
...
2
votes
2answers
179 views
Avoiding instanceOf when finding index of an interface within a list
I am working on some code and I have come across the following:
...
5
votes
1answer
51 views
Eliminating repetitiveness in code to test hash functions
I usually take my school code as a playground to mess around with things. I was given a bunch of premade hash functions and had to test their output and find when they reach a specific lower range. ...
1
vote
0answers
44 views
5
votes
2answers
67 views
Simple factory of a complex object [closed]
I've got few doubts about factory pattern, so I'm looking forward for your review of the following two factories.
I've heard that factories should have no state. But what about factories inside ...
6
votes
1answer
58 views
Populate errors for objects
I have a map of objects and errors associated with those objects.
I have to do the following:
populate the errors in the object
populate errors for valid objects based on the following:
check the ...
4
votes
2answers
103 views
Better PHP Ajax Request Processing Structure
I have a server side PHP file which processes Ajax requests from the client browser. Some requests are only valid if they originate from an Administrator in the application, others are only valid if ...
9
votes
1answer
70 views
Directory Searcher
This is about my first backbone.js application. It is a small directory that fetches data and presents it in a search-like UI.
Here is a working (minified) example.
Here is the file that handles ...
5
votes
2answers
179 views
Adding two BigInts using linked lists in C
While trying to learn more about linked lists, I thought I should try the exercise of reading two BigInts from an input file and then adding them up. My strategy was to store the two numbers in two ...
5
votes
1answer
89 views
Linked List implementation and manipulations in C
While trying to learn some more C, I decided to implement a linked list and perform a few operations on it.
The first thing I wanted to do was read from a .csv of numbers (ex: 1,2,3,...) and store ...
6
votes
2answers
772 views
Empty Interface usage - is this a code smell?
I've recently made a set of interfaces/classes to work with converting a spreadsheet into an object but I utilise an empty interface in my design:
So first off I have my interface which defines what ...
4
votes
1answer
83 views
How to make business logic code maintainable when working with multiple states?
I am developing a UI Application for a very simple phone app, the UI is based entirely on the state of Call in a container provided to me by a third party library.
Below is a sample Call object that ...
3
votes
2answers
75 views
Dependency on overridden method
In my code I have a base type which is OnlinePaymentTransaction:
...
17
votes
6answers
5k views
Why is my C# program slower than my Python program?
I made a program in Python and wanted it to be faster, so I wrote it on C# because it's compiled. To my surprise, the Python program is much faster. I guess there is something wrong with my C# code, ...
5
votes
2answers
118 views
Am I using Lazy initialization properly?
The following code is intended to implement a LinFu DynamicProxy interceptor to lazy load given virtual properties from an Umbraco datastore.
My concerns:
Thread safety, Have I covered all the ...
4
votes
1answer
153 views
How can I reduce the number of nested if statements in this code?
The application I'm building can accept two types of updates: Application Update and Parameter Updates. If there is an application update, then parameter updates can be ignored. This is the code that ...
11
votes
3answers
2k views
4×4 Tic-Tac-Toe in C
While trying to teach myself C, I decided to take a stab at writing this Tic-Tac-Toe program on a 4x4 board. It will be great if somebody could review it and let me know of some ways of refining this.
...
9
votes
2answers
149 views
Handling null arguments in a factory class
I have a Factory class that gives out instances of ResponseImpl class. It accepts one ...
3
votes
2answers
116 views
Array manipulation exercise
While trying to learn more about arrays in C, I tried to write some code that did the following:
Read a stream of numbers from the stdin and store them in an ...
6
votes
1answer
67 views
Rich Text on multiple iFrames
Having so many loops running concurrently obviously can't be good, and the code seems overly complicated. There has to be a simpler, more efficient way to
Turn the designMode of all iFrames on
Find ...
7
votes
4answers
395 views
4
votes
2answers
82 views
Processing student scores from the stdin
As part of learning more C, I wrote this extremely trivial C program that takes Student scores from stdin and, upon termination, prints out the minimum ...
7
votes
2answers
151 views
Inputting and displaying strings
I have written some code for one of my assignments. However, I feel that I am repeating myself slightly in a few places. I have that niggling feeling that there is a better way to do things.
Here ...
4
votes
1answer
121 views
Mapping from multiple sources to destination using JMapper
I am using JMapper to map from multiple sources to a destination class. Could you review it and let me know if the code looks OK to you? Please suggest any changes that I can make to improve it.
...
13
votes
5answers
2k views
Temperature conversion in C
I have started to learn C and I have tried my hand at temperature conversion. The idea is to convert a temperature from Fahrenheit to Celsius and vice/versa. Can somebody review my code and let me ...
10
votes
2answers
1k views
Word count program in Java
I am trying to write clean code in Java for reading text of any size and printing the word count in ascending order without using Java collection framework.
For example, given the following input ...
4
votes
1answer
86 views
Reducing repetitive Android code
How can I reduce the amount of repetitive code in my Android app? A lot of the code seems to be doing the same thing twice. I think that there is a more compact way to do this.
What are some ways ...
5
votes
4answers
397 views
Battle game simulation seems to have too much code
Can someone tell me if my code is too long for what it does? Please be nice — I just started trying to learn a couple days ago.
...
3
votes
1answer
282 views
Clockwise and counterclockwise spiral matrix traversal
An interviewer asked me to write clean Java code for clockwise and counterclockwise spiral matrix traversal.
e.g. {{1,2,3}, {7,8,9}} becomes ...
4
votes
2answers
82 views
Ruby Dynamic Struct - Pattern or AntiPattern?
There is a pattern that keeps coming up in my ruby code and I'm somewhat ambivalent about it. It's somewhere between a Hash and a Struct. Basically
I used method_missing to return/set values in the ...
5
votes
1answer
103 views
5
votes
1answer
91 views
Is this a good way to cascade a property?
I'm trying to write a simple game. I have an Entity object, that has a list of Sprite objects. Each Sprite has a position property where it is drawn on the screen. Sometimes, an entity can contain a ...
4
votes
4answers
200 views
Improving readability of enabling method
There doesn't seem to be anything really wrong with this method. But it has a little smell to me. Does the name make sense (do what you think it would do). Is there some logic I could use to make the ...
10
votes
3answers
661 views
Multiple return statements smells like what?
Here's some code of mine that I don't like (this was my very first attempt at DI/IoC!). It's a small C# application that runs scheduled on one of our servers and is responsible for fetching the latest ...
6
votes
4answers
310 views
Organizing semaphores into a pyramid
My homework was to organize semaphores into a pyramid. The task was accomplished, but I ended up with this long ugly conditional and was wondering if anyone can see a better way/algorithm to ...
1
vote
1answer
68 views
Optimizing jQuery functions for mobile menu
Consider this code (link to JSFiffle) (you need to resize your browser to see the effect)
...
0
votes
1answer
31 views
How to organize these several lists of booleans to avoid code duplication?
My class Person has a number of boolean values: isMoving, hasEyesOpen, ...
2
votes
1answer
142 views
Singleton has logic and state, and logic has state
------edit---------
note: this is for a MUD client, so the commands are issued to the MUD game server
-----end edit--------
For an overview, here's the structure of the project:
...
6
votes
1answer
136 views
10x10 bitmapped square with bits
This program prints out a 10x10 square and uses only bit operations. It works well, but I don't like that global array.
Can you tell me if the code is proper or not?
...