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

learn more… | top users | synonyms

0
votes
2answers
195 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 ...
-2
votes
1answer
147 views

Tools for identifying code smells [closed]

I heard people tell me before that my code smells. At first I did not understand their point but after researching and working through thousands of lines of code (since they weren't specific on where ...
8
votes
3answers
669 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
517 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 ...
2
votes
1answer
281 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
103 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 ...
0
votes
0answers
31 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
379 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 = ...
10
votes
4answers
687 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 ...
1
vote
5answers
533 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
140 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 ...
1
vote
2answers
147 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
90 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(){ ...
2
votes
1answer
230 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
373 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 ...
0
votes
0answers
41 views

Duplicate code in DCI model and use case

I'm just coming in to an application that's already built with a DCI architecture. I've discovered in trying to implement a feature that there is duplicate code in a use case and a model. This is not ...
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. ...
12
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, ...
1
vote
1answer
255 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
933 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
213 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
641 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 ...
4
votes
3answers
761 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 ...
2
votes
1answer
210 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 ...
0
votes
3answers
592 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, ...
2
votes
1answer
394 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
614 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 ...
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) ...
7
votes
3answers
445 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 ...
5
votes
3answers
528 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 ...
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
4answers
413 views

Is extensive documentation a code smell? [closed]

Every library, open-source project, and SDK/API I've ever come across has come packaged with a (usually large) documentation file, and this seems contradictory to the wide-spread belief that good code ...
3
votes
3answers
468 views

Is there a limit on how many global consts are used before an application is considered bad programming?

Basically, I develop websites, some large with many crud operations, etc... However I've gotten into the habit of storing re-usable data as a constant in my PHP applications I currently have 44 ...
9
votes
2answers
696 views

Unit Testing: “It's a code smell if you're refactoring and there are no collaborators”?

I'm reading The Art of Unit Testing by Roy Osherove. I'm at section 7.2 Writing maintainable tests where the author has this note about code smell: NOTE: When you refactor internal state to be ...
17
votes
5answers
1k views

Is it OK for a function to modify a parameter

We have a data layer that wraps Linq To SQL. In this datalayer we have this method (simplified) int InsertReport(Report report) { db.Reports.InsertOnSubmit(report); db.SubmitChanges(); ...
1
vote
2answers
447 views

Unit Tests code duplication?

How can I avoid code duplication in unit tests? Using Java and JUnit suppose I have something like this: public interface Arithmetic<T> { public T add(T a, T b); public T sub(T a, T ...
16
votes
9answers
1k views

Are too many assertions code smell?

I've really fallen in love with unit testing and TDD - I am test infected. However, unit testing is normally used for public methods. Sometimes though I do have to test some assumptions-assertions ...
1
vote
2answers
72 views

Should Multiple Data Items be in Multi Unit Test Methods?

I often want to have the same unit test applied to data multiple items that are roughly equivalent (two non-empty strings). Currently I implement these in multiple unit test methods, with names like ...
2
votes
4answers
651 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() { ...
0
votes
2answers
492 views

Is this bad design for a Shape interface?

I'm creating a vector editing program in C++, and I need a Shape interface which other concrete classes will implement. There is a requirement that no implementation inheritance is allowed. The design ...
7
votes
4answers
729 views

Is “Code Smell” still a useful metaphor, or has misuse of the term subverted its meaning? [closed]

I've come across some comments and answers on Programmers.SE that decry the use of the phrase "Code Smell" and I've been wondering what the reasoning is for those who dislike it. I first encountered ...
9
votes
5answers
635 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 ...
2
votes
1answer
223 views

How should I design a correct OO design in case of a Business-logic wide operation

EDIT: Maybe I should ask the question in a different way. in light of ammoQ's comment, I realize that I've done something like suggested which is kind of a fix and it is fine by me. But I still want ...