A `code smell` is something which is a sign of a possible problem in a program.
3
votes
1answer
36 views
framework design review (SOLID)
I'm developing a php framework for educational purposes, I have learned a big deal about design patterns and MVC.
I've been thinking a lot on how to have a nice design and so far I've come up with ...
6
votes
2answers
129 views
Left hand search in string
the requirement for our search query is to look for all search words in the beginning of vehicle manufacturer, model and variant name. Case insensitive. The word being a string of characters separated ...
1
vote
1answer
63 views
How to improve readability of a big lisp function
My main method (remove-random-edge) looks quite difficult to read. I'm new to list, so would appreciate any advice on how to improve the code.
(defun find-node (node graph)
(find-if #'(lambda (i) ...
3
votes
1answer
75 views
Better Javascript to find unique values in an array
My objective is to make an array of unique keys from a list of objects. Example:
Input:
var input = [{"a":1, "b":2}, {"a":3, "c":4}, {"a":5}]
Output:
[ "a", "b", "c" ]
Current approach:
var ...
3
votes
0answers
76 views
Scala Play Controller - Refactoring out Duplication for Restful Web Services
I'm new to scala and I'm noticing I have some repeating code in my controllers.
I'm wondering if anyone can give some hints for traits and parameterization for eliminating duplicate code for basic ...
4
votes
3answers
284 views
Is this interface too “god-like?”
I have an MVC framework I've written. I'm trying to abstract out ASP.Net specific bits as well as make it more testable. Previously, I relied on HttpContext.Current in many places, which proves to be ...
3
votes
4answers
159 views
Is static method calls to a server a Java bad code smell?
I'm developing an Android app that performs several requests to a server using the AndroidAsynchronousHttpClient. One of these requests (as an example) is responsible to send the username and ...
1
vote
1answer
102 views
Help me simplify this gigantic class
I'm trying to think of ways to separate things out. I'm open to ideas, or if you see anything blatantly wrong, I'd like to know that too.
Generally, I'm happy with this, but the sheer size of the ...
1
vote
0answers
24 views
DOMDocument field class Python
What do you think of this class?
Is this simple to understand how it works and what it does?
Do you think it is good piece of code?
class Field(object):
"""Class which contains logic of ...
0
votes
1answer
115 views
Illustrating DI and IoC concepts
This question is a follow-up to the questions here: Illustrating DI and IoC concepts : Simple code requesting review
I have taken the very good review comments got and tweaked the code. These are the ...
3
votes
5answers
306 views
How to avoid passing variable to a method again and again
Following is a chunk of code from my class which generate PDF document. I am refactoring my code and in the process I have created short methods. But I have to pass 'table i.e PdfPTable' to my methods ...
3
votes
3answers
226 views
Write it better/neat/fast (if condition)
How to write following if condition clean/fast/readable.
Any one of the fields 'address', 'city', 'district', 'province' can be null. I want to make full address by concat all these fields. Like
...
3
votes
1answer
302 views
Using switch to avoid duplicate code. Is there a better way?
I recently changed one of my methods and used this pattern (names are changed, a dose of humor applied for the exception):
switch (myEnum) {
case e1:
// do stuff
if (!alsoApplyCodeForE2) {
...
2
votes
3answers
124 views
How to re-factor a common String comparison
Code below is scattered all over the code base :
if (StringUtils.contains(manager.getName, "custom")){
}
It just checks if an object attribute contains a predefined String and if it does, enter ...
3
votes
2answers
121 views
Improving Python script to drop HTML part of multipart/mixed e-mails
I have a working script that I wrote in Python which for e-mail messages that consist only of a plain text part + an HTML part, discards the HTML and keeps only the plain text part.
The script is not ...
6
votes
2answers
928 views
Bad practice to have try / catch in constructor?
I have a constructor which sets a member variable. The setting of this variable throws an exception. Should I be throwing the exception in the contructor or enclosing the try/catch like below. Is ...
2
votes
1answer
194 views
my constructor is doing work. Is this a code smell in this example?
I have created a queue in javascript. This queue also has blocking take(). As you all probably know this is not really true, because javascript does not have threads. It just wait until element has ...
5
votes
1answer
2k views
Polling loop - Always a bad decision?
I had a need to isolate some long-running blocking calls in a background thread of my app. I also needed to keep this thread running indefinitely, because COM would complain if some object I created ...