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".

learn more… | top users | synonyms

3
votes
1answer
73 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
169 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
42 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. ...
5
votes
2answers
63 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
53 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
84 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
68 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
133 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
75 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
656 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
74 views

Dependency on overridden method

In my code I have a base type which is OnlinePaymentTransaction: ...
17
votes
5answers
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
86 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
125 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
1k 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
141 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
111 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
56 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
257 views
4
votes
2answers
76 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
150 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
98 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
75 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
307 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
147 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
72 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
93 views
5
votes
1answer
90 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
198 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
633 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
309 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
62 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
28 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
131 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: ...
5
votes
1answer
119 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? ...
3
votes
2answers
174 views

Initializing complex constant in Constants interface

I'm being forced to use the common anti-pattern of a public interface Constants which many classes in this project implement. Long story short, I need to have a ...
4
votes
2answers
268 views

Maxmin algorithm implementation review

I'm currently taking an algorithm course in college. To find the maximum and minimum elements in an array, I'm using a divide and conquer algorithm. Please offer suggestions for this code snippet. I ...
1
vote
1answer
68 views

Removing redundancy from an immutable “rules class”

I am writing a board game program in Java. Slightly similar to chess or civilization in that each player has a set of units, and each unit has certain actions that it can take. The base ...
4
votes
2answers
174 views

Initializing a variable with a function reference (PHP)

I'm working on an old PHP website, and NetBeans is complaining about an uninitialized variable. I'm seeing some code like this: ...
4
votes
2answers
881 views

Is this an effective way of populating a datagrid of comboboxes

The goal is to have a DataGrid of comboboxes, 10 rows, 3 columns. Here's the XAML to create said grid: ...
7
votes
4answers
969 views

Is this code with global variables good practice?

I am currently writing a game in C++ and have some variables that I want to be accessible from everywhere. For the examples, I will have the shared variable as an object of the class ...
2
votes
2answers
92 views

More Ruby Idiomatic for creating consecutive words from string

This is method which creates an array of all possible consecutive substrings from from a string ...
0
votes
2answers
79 views

Is this a good way of handling item reservations?

I have a site were we sell unique items. When a user clicks to buy an item we have to reserve it. This prevents other buyers from purchasing the item while the first buyer is checking out. When a ...
0
votes
2answers
66 views

Refactor selective item by highest create date or update date

I have to check for the Highest Date from CostRepository whether it is create date or edit date then i have to get value in that field. edit date can be null. i don't know how to fix the codesmell. ...
1
vote
1answer
52 views

Registering or logging in when creating a new comment object

This service object allows users without a session to create a comment, and register OR login at the same time. If a user is signed out he must enter an email and a password along with the comment. ...
0
votes
3answers
78 views

Image uploader and manager

I have recently started using Ruby and would like to hear your take on the following piece of code. ...