An indicator within a codebase that possibly indicates a deeper problem.

learn more… | top users | synonyms

2
votes
4answers
224 views

Escape a GameLogic god class.

When programming a simple game as an example. I always tend to get left with a large GameLogic class somewhere which is reponsible for gluing together all of the other portions of the software. A ...
2
votes
1answer
290 views

Is using MultiMaps code smell? If so what alternative data structures fit my needs?

I'm trying to model nWoD characters for a roleplaying game in a character builder program. The crux is I want to support saving too and loading from yaml documents. One aspect of the character's is ...
0
votes
2answers
202 views

How to avoid spaghetti code when I have a lot of conditions? [duplicate]

I have the following problem: An user can withdraw money from 2 payment systems (but the number of payment systems can change anytime in the future). If user has a trusted account on either of ...
64
votes
16answers
10k views

Are #regions an antipattern or code smell?

In C# code it allows the #region/#endregion keywords to made areas of code collapsible in the editor. Whenever I am doing this though I find it is to hide large chunks of code that could probably be ...
8
votes
3answers
682 views

Clean Code and Hybrid Objects and Feature Envy

So I recently made some major refactorings to my code. One of the main things I tried to do was split out my classes into data objects and worker objects. This was inspired, among other things, by ...
4
votes
3answers
522 views

How to avoid large function arity / exposure of underlying implementation

Currently reading Clean Code, and the authors seem to imply that any function with an arity greater than 3 should be avoided at all costs. I am unfortunately running into an issue where I am faced ...
0
votes
3answers
594 views

Is $.proxy a code smell?

I've been writing most of my javascript applications in an OO style close to what I would use for most other languages. However, this means that most callbacks need to have a reference to an object, ...
4
votes
3answers
781 views

What's the best way to create a static utility class in python? Is using metaclasses code smell?

Ok so I need to create a bunch of utility classes in python. Normally I would just use a simple module for this but I need to be able to inherit in order to share common code between them. The common ...
13
votes
5answers
4k views

Is it considered Pythonic to have multiple classes defined in the same file?

In working with python for the first time, I've found that I end up writing multiple classes in the same file, which is opposed to other languages like Java, which uses one file per class. Usually, ...
0
votes
2answers
106 views

What should happen when code is reached that shouldn't be, according to business or logic rules? [duplicate]

I am currently writing an application that isn't huge but will be used through-out my company of 200+ people and external customers about projects we are working on (not software projects), but there ...
29
votes
10answers
4k views

Are flag variables an absolute evil?

Are flag variables evil? Are the following kind of variables profoundly immoral and is it wicked to use them? "boolean or integer variables that you assign a value in certain places then down ...
1
vote
6answers
2k views

Static classes and/or singletons — How many does it take to become a code smell? [closed]

In my projects I use quite a lot of static classes. These are usually classes that naturally seem to fit into a single-instance type of thing. Many times I use static classes and recently I've started ...
10
votes
4answers
691 views

Is it a code smell if you are frequently creating an object just to call a method on it

I inherited a code base where there is a lot of code that goes something like this: SomeDataAdapter sda = new SomeDataAdapter(); sda.UpdateData(DataTable updateData); And then sda is never used ...
0
votes
0answers
35 views

Create a subclass of model for class-based viewmodel creation

Is it justified to create a model subclass just for creation of appropriate viewmodel based on this class. Am I missing something? How to pass data about model into viewmodel?
7
votes
5answers
387 views

Is doing an assignment inside a condition considered a code smell?

Many times I have to write a loop that requires initialization of a loop condition, and an update every time the loop executes. Here's one example: List<String> currentStrings = ...
1
vote
5answers
548 views

Lots of classes with only one single static method with same name as class - Code smell? [duplicate]

I'm trying to follow the single responsibility principle (SRP) in my applications. I have lots of CRUD classes I just name xxxxxManager. Following the SRP, I made 4 classes for each one : ...
0
votes
0answers
141 views

DRY on API specifcations?

When developing a new RESTful application, I generally: Define tests Define routes [ e.g.: RESTful CRUD; namespaced on /api/users ] Define models [ e.g.: "Users" ] Define forms [ e.g.: in ...
21
votes
5answers
2k views

Is code ownership a code smell?

This is something I've been thinking about ever since I read this answer in the controversial programming opinions thread: Your job is to put yourself out of work. When you're writing ...
1
vote
2answers
149 views

Code Duplication in Multi-Module Project

I've about seven modules arranged like so: Service Processing Common Account Email Scheduling I try to make it my policy to restrict code to the module that actually uses it. Code that is shared ...
0
votes
1answer
91 views

should this code be structured into an event capture and a method or put the functionality in the event capturing

I have adopted some jQuery code that has like 20 event-captures that look like this // used on menu#edit $('.show-headers-only-toggle').on('click',function(){ ...
5
votes
5answers
737 views

Nested languages code smell

Many projects combine languages, for example on the web with the ubiquitous SQL + server-side language + markup du jour + JavaScript + CSS mix (often in a single function). Bash and other shell code ...
2
votes
1answer
235 views

Is depending on lazy loading a code smell?

During my short experience with DDD I often find myself in the situation where I wished for some type of lazy loading mechanism to solve some dangerous cases where large nested data sets might be ...
-1
votes
1answer
392 views

Are verb-like classes a code smell? [closed]

I do a lot of flat-file processing to extract data. The file "formats" are very unique and each file format requires a lot of format-specific code. Sometimes, the parsing code needs to maintain a lot ...
2
votes
4answers
654 views

What code smell best describes this code?

Suppose you have this code in a class: private DataContext _context; public Customer[] GetCustomers() { GetContext(); return _context.Customers.ToArray(); } public Order[] GetOrders() { ...
5
votes
1answer
3k views

If you have a piece of logic that needs to be shared between two controllers where do you keep it?

I have a set of single purpose functions that I need in two separate controllers. Right now I just have duplicate code and I want to get rid of it. This code is part of the controller and doesn't ...
18
votes
2answers
3k views

What is a“ feature envy” code and why is it considered a code smell?

This question on SO talks about correcting what the OP thought is feature envy code. Another example where I saw this nifty phrase being quoted is in a recently given answer here in programmers.SE. ...
17
votes
11answers
1k views

Why are we supposed to use short functions to sectionalize our code? [duplicate]

I've seen an increasing trend in the programming world saying that it is good practice to separate code blocks into their own functions. Obviously, if that code block is reusable, you should do that. ...
1
vote
1answer
257 views

catch(Exception ex) would this example be a code smell? [duplicate]

We have production code that is not easily deployed in a test area. We also have a new library of code that we would like to "plug in" to the production code. The production code would be making a ...
5
votes
8answers
994 views

Passing an object into a method which changes the object, is it a common (anti-) pattern?

I am reading about common code smells in Martin Fowler's Refactoring book. In that context, I was wondering about a pattern I am seeing in a code base, and wether one could objectively consider it an ...
4
votes
1answer
217 views

Reference Passing Style Anti Pattern

I'm working on a legacy VB.Net code base. There are very few functions that return values, most of the code is in subs/void methods. The general strategy seems to be to pass everything in by ...
10
votes
3answers
1k views

How to tackle a 'branched' arrow head anti-pattern? [duplicate]

I recently read this question that features, the arrow anti-pattern. I have something similar in code I'm trying to refactor except that it branches. It looks a little something like this: ...
7
votes
3answers
653 views

TDD Mock call verification - is it an anti-pattern?

I've been doing TDD for year now, I feel pretty good about it, I love my test suites and all. However I've noticed that lately I've been doing a lot of mock call verification. For example I'd have a ...
9
votes
5answers
644 views

Writing Testable Code vs Avoiding Speculative Generality

I was reading some blog posts this morning, and stumbled across this one: If the only class that ever implements the Customer interface is CustomerImpl, you don't really have polymorphism and ...
7
votes
3answers
447 views

is this javascript property defaulting pattern a code smell?

In some javascript code I'm working on refactoring I've handled cases where I wanted to default an object property to true without having to go through the code-base and add the property to every ...
55
votes
17answers
4k views

How to train yourself to avoid writing “clever” code?

Do you know that feeling when you just need to show off that new trick with Expressions or generalize three different procedures? This does not have to be on Architecture Astronaut scale and in fact ...
2
votes
5answers
883 views

Is wrapping third-party API calls a design smell?

Five methods within my API call the same third-party method. In trying to abide by DRY, does it make sense to wrap this call in a private method?
2
votes
1answer
211 views

Is there a name for CSS code smell that can be seen in class names like “float” or “white”?

I noticed some code in our projects using CSS class names such as red, black or float. I want to provide some information for people so they know to avoid it. Is there a common name for that code ...
1
vote
1answer
132 views

Less code or less operation

Sometimes I hesitate between "More code to avoid unnecessary operations" and "less code but with redundant operations". Let me just take an example (Win32 API): I try to paint some controls manually ...
2
votes
1answer
396 views

How can I deal with a team member who duplicates code? [duplicate]

One of our team member duplicates code. Code duplication causes confusion among my team members reading his code, it causes bugs down the line when the duplicated segment is fixed in one location and ...
6
votes
4answers
621 views

Hating your own code - for good or bad, how do you deal with it? [closed]

Have you ever had this feeling that your code is bad, the whole project is a mess, and you just want to step off? On your daily job you can explain this feeling away with your coworkers, asshole boss, ...
3
votes
1answer
2k views

What does the “4” in LCOM4 mean?

I know that methods in a class should have high cohesion which roughly translates to having all the methods use all the instance variables directly or indirectly. I know that LCOM4 (Lack of ...
2
votes
2answers
130 views

Should I check integrity in my application code or defer to the database? [duplicate]

At work we have a lot of code like this (pseudocode): response form_submit(string username, string password) { if ( username == "" || username.contains(invalid_chars) || password.length ...
4
votes
2answers
561 views

How do I handle having so many SQL queries?

I have an MVC3 project that uses SQL Server. I use data from the SQL database all the time and I often find that I'm reusing/duplicating some SQL queries. I thought I'd solve this problem by creating ...
18
votes
9answers
5k views

Is there any reason to use “plain old data” classes?

In legacy code I occasionally see classes that are nothing but wrappers for data. something like: class Bottle { int height; int diameter; Cap capType; getters/setters, maybe a ...
46
votes
12answers
3k views

If your unit test code “smells” does it really matter?

Usually I just throw my unit tests together using copy and paste and all kind of other bad practices. The unit tests usually end up looking quite ugly, they're full of "code smell," but does this ...
7
votes
4answers
812 views

Is this a test smell or is it even worse?

I have recently been looking at some testscripts which looks a bit like ... try { receiveSomething(); // something was received even though it shouldn't failTest(); } catch (TimeoutException e) ...
6
votes
3answers
419 views

Is having a switch to turn mocking on or off a code smell?

I have a method that looks like this: def foobar(mock=False, **kwargs): # ... snipped foobar actually makes several calls to Amazon S3 and returns a composed result. In order to make this ...
28
votes
7answers
1k views

Are there architecture smells?

There are tons of resources on the web referring to and listing code smells. However, I've never seen information on architectural smells. Is this defined somewhere, and is there a list available? ...
5
votes
3answers
533 views

At what point/range is a code file too big?

I'm finding lots of 2-3k line files, and it doesn't really feel like they should be that big. What is a good criteria to objectively call a source code file "too big"?, is there such thing as a ...
7
votes
5answers
1k views

Is having 'Util' classes a cause for concern? [closed]

I sometimes create 'Util' classes which primarily serve to hold methods and values that don't really seem to belong elsewhere. But every time I create one of these classes, I think "uh-oh, I'm gonna ...