Skip to main content

Questions tagged [anti-patterns]

An anti-pattern is a behavior or practice that is common despite being ineffective or counterproductive.

Filter by
Sorted by
Tagged with
5 votes
1 answer
287 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 ...
user2740's user avatar
  • 159
2 votes
1 answer
294 views

In poltergeist, whats wrong with "solely to trigger or initialize several other objects"? Isn't it is a good use of encapsulation and reuse?

After reading What differentiates function objects from poltergeists?, according to the definition of poltergeist, I still don't understand why would "poltergeist" be a bad pattern: A ...
wcminipgasker2023's user avatar
2 votes
2 answers
280 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 ...
Musterknabe's user avatar
1 vote
1 answer
74 views

Is using an UId to hash Mutable Entities an anti-pattern?

In the context of an object-oriented language, such as Dart, I have an abstract entity which has a single property called id (which is incrementally uniquely generated to make sure there are no-...
Fabrizio's user avatar
  • 115
0 votes
1 answer
172 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. ...
DannyNiu's user avatar
  • 285
1 vote
1 answer
206 views

Is module scoped initialisation considered a bad practice?

A module app.js includes another module service.js. The service.js module/file contains some functions but also does some module scoped initialisations(registry variable). // service.js const ...
Cap Barracudas's user avatar
0 votes
0 answers
115 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, ...
async's user avatar
  • 854
-1 votes
7 answers
655 views

If you use Inversion of Control, what alternatives to obfuscated function calls exist?

Consider a class that follows the obfuscated function call anti-pattern. I've also seen these called "stupid classes". The definition of such a class is that it only has one public method ...
J. Mini's user avatar
  • 1,037
-1 votes
3 answers
426 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 ...
JimmyJames's user avatar
  • 28.9k
1 vote
3 answers
2k views

Are "Distributed Enums" an Anti-pattern in non-OOP like they seem to be considered in OOP?

I have recently read about the so-called "distributed enum anti-pattern." In particular, as it relates to using enums in conditional statements. (The idea is apparently that if you were to ...
user1713450's user avatar
10 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 ...
Tim Lovell-Smith's user avatar
4 votes
1 answer
259 views

What is the anti-pattern for modules that group objects of the same type? [closed]

In MVC, I often seen all models in a models.py module, all views in a views.py module, and the controller - you guessed it - in a controller.py module. In other projects, I sometimes see all exception ...
Chewers Jingoist's user avatar
3 votes
2 answers
422 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 ...
Matthew Layton's user avatar
4 votes
6 answers
609 views

Waiting until end of project to remove commented out code, remove unused code, and resolve compiler warnings

A co-worker of mine is working on project solo but would still like to have other team members review their code upon reaching certain milestones. Unfortunately, they also want to wait until the end ...
user8297969's user avatar
0 votes
3 answers
211 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 ...
kaan_atakan's user avatar
1 vote
0 answers
93 views

How to improve the coding quality in a problematic company [duplicate]

Due to circumstances I'm now working in a small software company. We make e-mail marketing management software and serve some big customers as our national railways and a big bank. The software has ...
JHBonarius's user avatar
0 votes
1 answer
263 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 ...
user avatar
44 votes
13 answers
9k views

Is it an (anti-)pattern for a function to have an argument to decide which other function to call?

Consider your have an enumeration that looks like this: enum ProcessingType { CONFABULATION, RETICULATION, SPLICING; } And you have a web-service that looks like this: class WebService { ...
Mathieu's user avatar
  • 1,039
1 vote
2 answers
138 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 ...
Apollo's user avatar
  • 121
2 votes
3 answers
432 views

Are user-callable recursive functions an anti-pattern?

I have a function in python that calls itself recursively, and has some internal variables passed down the recursion using keyword arguments (that are not listed in the docstring) Is it a problem to ...
holox's user avatar
  • 31
1 vote
2 answers
632 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 ...
Robin Kreuzer's user avatar
-3 votes
1 answer
161 views

General term to describe the anti-pattern where the same concept is described in different ways?

Our codebase is old and very large. Over the years, many developers have worked on the code and frequently refered to the same concept inconsistently. For example, we have a "number that uniquely ...
AlainD's user avatar
  • 150
105 votes
11 answers
25k 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 ...
old greg's user avatar
  • 949
0 votes
0 answers
75 views

Can someone suggest what pattern I used mistakenly and is it correct in this situation. Any alternative?

Client_1 uses --> IService_1 and thus Service1_impl public interface IService_1 { void DoTask_1(); } public class Service1_impl : IService_1 { private readonly IDepService_1_v1 ...
PKV's user avatar
  • 181
6 votes
2 answers
153 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 /...
katmfoo's user avatar
  • 71
-3 votes
2 answers
190 views

Name for unnecessary transcoding antipattern?

Say I have a library function that expects a JSON-encoded object and does some things with it: function foo(bar) { const baz = JSON.parse(bar); doTheThing(baz); doTheOtherThing(baz.qux); } ...
Bart Robinson's user avatar
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 ...
Mehraban's user avatar
  • 269
0 votes
2 answers
261 views

Anti-pattern in which code blocks are indirectly used as parameters

I was recently trying to explain a particular anti-pattern to some novice programmers and found that it was hard to express without an overly-detailed example. I'm sure it has a name and that someone ...
nben's user avatar
  • 345
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 { ...
Arturo's user avatar
  • 149
1 vote
3 answers
2k views

Anti-pattern? Storing JSON table in SQL table

For an application that I currently plan to scale up, there's a bunch of JSON dicts and directories making up the "database". The reason I didn't use SQL initially, is simply because I've ...
DannyNiu's user avatar
  • 285
0 votes
1 answer
387 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 ...
joninx's user avatar
  • 211
2 votes
4 answers
10k views

How is a nested Try/Catch (inside the try) not an anti-pattern

I've seen a debate on this. Nested trys in the catch, I can see that being okay. The outer try has already triggered a catch by that time, hence no scope issues. The other way....hides errors (it is a ...
user3768121's user avatar
-2 votes
1 answer
705 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 ...
cansu's user avatar
  • 169
0 votes
2 answers
909 views

Are there cases when using polling is preferable to Webhooks

When evaluating whether to use webhooks or polling for an architectural decision I've been reading some articles. Most highlight the obvious drawbacks with using polling such as: wasted resources (...
Sergey Evstifeev's user avatar
115 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 ...
gaazkam's user avatar
  • 4,509
3 votes
1 answer
908 views

Avoiding Arrow Anti-Pattern in MISRA-C

For a safety-critical domain, with a code standard including the MISRA C 2004 guidelines, a "simple" piece of code becomes obtuse, chiefly because of the requirements both that all if() statements ...
JWCS's user avatar
  • 179
1 vote
1 answer
252 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 ...
chb's user avatar
  • 119
35 votes
9 answers
47k views

Is there a better way to use C# dictionaries than TryGetValue?

I find myself often looking up questions online, and many solutions include dictionaries. However, whenever I try to implement them, I get this horrible reek in my code. For example every time I want ...
Adam B's user avatar
  • 1,660
0 votes
2 answers
253 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 ...
samfrances's user avatar
  • 1,085
1 vote
1 answer
495 views

Design question on synchronization of two asynchronous data streams

I have two async streams suppose- Trip : {tripId, date, city} Bill : {billId, tripId, date, amount}. I need to design a system to get real time aggregated view of following nature: City, TripCount, ...
Himanshu Verma's user avatar
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 ...
user6567423's user avatar
2 votes
2 answers
221 views

What is wrong with writing web applications in a way that merges repository layer with view and with controller in the same file?

is there anything wrong with writing code in a way that merges view, repository, controller in the same file? i.e. global $db; // or $db = DBSingleton::get_db_instance(); // or global $container; $...
Dennis's user avatar
  • 8,257
0 votes
1 answer
686 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 ...
Darkestlyrics's user avatar
4 votes
4 answers
977 views

Is a constant name related to its current value an anti-pattern? [closed]

For example, suppose I have a string constant like this: const TITLEBAR_MESSAGE="Welcome back, %USERNAME%!"; I think it is more readable when it is named as const WELCOME_BACK_USERNAME="Welcome ...
ocomfd's user avatar
  • 5,722
2 votes
3 answers
464 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 ...
konrad's user avatar
  • 551
0 votes
1 answer
175 views

How to bring a code to conformance with tell, don't ask without creating tons of methods on other classes?

It used to be fairly common for people to call a getter, do some calculation on it, then call a setter with the result. This is a clear sign your calculation actually belongs to the class you called ...
gaazkam's user avatar
  • 4,509
2 votes
2 answers
396 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 ...
selbie's user avatar
  • 643
1 vote
1 answer
484 views

How can I get rid of this antipattern

I have a main window and I amgetting data from http client service while form load. public class MainWindow: Window { private IClientService service; public MainWindow(IClientService ...
barteloma's user avatar
  • 329
4 votes
3 answers
1k views

How can I resolve this **kwargs antipattern?

I am a hobbyist programmer, working on a much more complex Python project than I've attempted before, which is in the form of a Python library. I find that I'm often passing **kwargs around (as ...
N. Virgo's user avatar
  • 894
4 votes
2 answers
638 views

Injecting a dependency that is a tree of dependencies

Is it a pattern or antipattern to inject a dependency that is a tree of dependencies? For example: public class ClassExample { private IContainer _container; public ClassExample(IContainer ...
Răzvan Flavius Panda's user avatar

1
2 3 4 5