Questions tagged [anti-patterns]
An anti-pattern is a behavior or practice that is common despite being ineffective or counterproductive.
240 questions
-3
votes
1
answer
182
views
Is there a name for this anti-pattern? (reference to a class member passed to another class method) [closed]
Is there a name for this anti-pattern?
A reference to a class member is being passed to another class method, rather than having the class method set the class member directly.
public class ...
5
votes
1
answer
336
views
What do you call an enum that translates its own values?
I see this pattern a lot, especially with countries, or more generally regions. An enum is defined with additional fields and with methods that translate to and from these values.
Example:
import ...
2
votes
2
answers
351
views
Can chatty microservices be okay to use if there is a specific use case for them?
Introduction
Hi everyone,
in my company we are using microservice approach and of course are trying to do it as correct as possible. There is a new requirement coming up where I have laid out a ...
0
votes
1
answer
195
views
Is it anti-pattern to obtaining public static data from a function?
In C programming, I have a set of information, and I have to ways of providing it to user:
construct a data structure and provide it as an object.
write a function to read them out and return them.
...
0
votes
0
answers
127
views
Is having many thin factories an antipattern?
I need to perform the following task: for a user [email protected], store a blob of data into their dedicated data store.
DataStoreService is what actually stores the blob of data in the user's store, ...
-1
votes
3
answers
540
views
Are there existing term(s) for a 1-1 child-parent table anti-pattern?
NOTE: Please don't respond by telling me that I probably don't understand what I am looking at. You can't possibly know that and it's wrong. Just don't answer if that's all you have to say.
I'm ...
11
votes
5
answers
4k
views
How do you fix the wrong-case-sensitivity dictionary setting bug-pattern?
There is a coding anti-pattern I've noticed (while using .Net). You declare a data class, which is supposed to have a dictionary field (or get/set Property), and lets call it 'Properties', for the ...
3
votes
2
answers
587
views
Creating an abstraction just for exception handling - a pattern or anti-pattern?
Assume that an external library or framework not under our control exposes a Controller API:
abstract class Controller {
abstract fun call(): Result
}
Assume that we want to handle exceptions ...
0
votes
3
answers
245
views
What pattern is a function that returns a component?
Ok I have a bunch of components that all have the same logic but have different css classes. So I wanted to create a sort of factory function that takes the names of the classes as its argument and ...
0
votes
1
answer
275
views
Is this dependency propogation an anti-pattern, and how do I remove it?
Module A contains a gap buffer for manipulating text and some associated methods. Relevant to this question is the dependency on a Module B, used for syntax highlighting of text.
Module A also ...
1
vote
2
answers
164
views
Are the exceptions used in BeanValidation/JAX-RS's ExceptionMapper an anti pattern?
I am reading a lot about patterns and code structure and something that bothers me is BeanValidation's way to handle errors. I like Java and think that BeanValidation is easy to use, but it seems to ...
1
vote
2
answers
707
views
No trivial god-class refactoring
Consider you have the following code:
class UserContainer
{
List<User> user;
//some methods to get specific users, for example users, which are higher than 1,70meters
}
The User have a ...
106
votes
11
answers
27k
views
Is putting general-use functions in a "helpers" file an anti-pattern or code smell?
Is it an anti-pattern or code smell to put "general use" functions (examples below) into a catch-all file named "helpers" or "utils"?
It's a pattern I've seen quite a lot ...
6
votes
2
answers
164
views
Resource that has different state based on input parameters
Let's say I have a REST api endpoint that is getting a resource called a "purchasable" (an item that a user can purchase). Here is an example of what this might look like.
Endpoint: GET /...
3
votes
3
answers
2k
views
Using python context managers instead of passing arguments: Is it an anti pattern?
We have an input flag in our API which indicates whether we should keep the mid level resources involved in fulfilling current request or not. I've decided to use some context managers at interface ...
4
votes
5
answers
1k
views
How to fix a pair of tightly coupled classes that store references to each other?
I have the following situation:
class User
{
public Thing curThing;
}
//each thing can only belong to one user at a time
//And vice versa
class Thing
{
...
0
votes
1
answer
423
views
Is an antipattern returning differente objects in a single rest method?
I have seen around the Internet several rest web services with the following behaviour. In case there are any errors, they return a Error object, otherwise they return, say, MyClass.
See the ...
-2
votes
1
answer
752
views
.Net Core Dependency Injection is an example of anti-pattern?
I want to use Dependecy injection in my new .net core project, but my manager thinks it is an anti-pattern usage. I already know benefits of dependency injection. But my manager cares architecture ...
116
votes
17
answers
24k
views
Why should 'boneheaded' exceptions not be caught, especially in server code?
I am confused because in quite a few places I've already read that the so-called 'boneheaded' exceptions (ones that result from bugs in code) are not supposed to be caught. Instead, they must be ...
1
vote
1
answer
279
views
Avoiding "instanceof" and explicit casts when selecting applicable handlers for inheriting object
In my current project, I am trying to implement an environment to perform simulations of different workflows in a range of programs, websites, and mobile applications. These simulation subjects can ...
0
votes
2
answers
276
views
Temporal coupling vs. complex constructor
I'm working through a book on writing Single Page Applications in Vanilla Javascript. (I'm working on a project where I'm not allowed to use React or any other frameworks, so I'm trying to get better ...
29
votes
7
answers
10k
views
Is my company merging branches wrong?
I recently came across an MSDN article about branching and merging and SCM: Branching and Merging Primer - Chris Birmele.
In the article they say 'big bang merge' is a merging antipattern:
Big Bang ...
0
votes
1
answer
723
views
Is a Factory calling a Factory an anti-pattern or an extension of the Single Responsibility Principle?
I'm busy playing around with some training material to help teach some of the juniors the factory pattern.
Whilst writing the example, I can't help but think this might be an anti-pattern.
Lets say ...
2
votes
3
answers
499
views
Swappable state object or decoupling data and functions
I come from OOP pradigm and I also know a bit about functional programming and its advantages. Over time I came to like the separation of data and transformations that are applied to it using pure ...
2
votes
2
answers
431
views
What is this anti-pattern's name? (Specialization added directly to a general purpose utility component)
I'll describe the anti-pattern I see occasionally as this.
Rather than using encapsulation or inheritance, a utility library grows with feature specializations directly added to it. Subsequent usage ...