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
0 votes
3 answers
117 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 ...
user avatar
  • 155
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 ...
user avatar
0 votes
1 answer
244 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
  • 281
43 votes
13 answers
7k 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 { ...
user avatar
  • 960
1 vote
2 answers
86 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 ...
user avatar
  • 121
2 votes
3 answers
236 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 ...
user avatar
  • 31
1 vote
2 answers
405 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 ...
user avatar
-4 votes
1 answer
117 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 ...
user avatar
  • 140
94 votes
9 answers
14k 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 ...
user avatar
  • 839
0 votes
0 answers
69 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 ...
user avatar
  • 181
6 votes
2 answers
143 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 /...
user avatar
-3 votes
2 answers
160 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); } ...
user avatar
1 vote
3 answers
599 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 ...
user avatar
  • 249
0 votes
2 answers
224 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 ...
user avatar
  • 316
4 votes
5 answers
279 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 { ...
user avatar
  • 49
1 vote
3 answers
606 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 ...
user avatar
  • 121
0 votes
1 answer
108 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 ...
user avatar
1 vote
4 answers
4k 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 ...
user avatar
-2 votes
1 answer
434 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 ...
user avatar
  • 159
0 votes
2 answers
167 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 (...
user avatar
115 votes
17 answers
23k 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 ...
user avatar
  • 3,307
3 votes
1 answer
603 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 ...
user avatar
  • 179
1 vote
1 answer
98 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 ...
user avatar
  • 119
31 votes
9 answers
28k 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 ...
user avatar
  • 1,477
0 votes
2 answers
195 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 ...
user avatar
  • 1,045
2 votes
1 answer
331 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, ...
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 ...
user avatar
2 votes
2 answers
217 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; $...
user avatar
  • 8,021
0 votes
1 answer
351 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 ...
user avatar
4 votes
4 answers
495 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 ...
user avatar
  • 5,572
2 votes
3 answers
309 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 ...
user avatar
  • 551
0 votes
1 answer
145 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 ...
user avatar
  • 3,307
2 votes
2 answers
338 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 ...
user avatar
  • 613
1 vote
1 answer
450 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 ...
user avatar
  • 328
2 votes
3 answers
817 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 ...
user avatar
  • 677
4 votes
2 answers
476 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 ...
user avatar
2 votes
1 answer
293 views

Is it efficient and a normal practice to have one class with thousands of lines of code? [duplicate]

I am currently in a continuous software product development project on base of legacy Java code. The source code is very complicated, which is good and bad. But I am surprised to see that in the core ...
user avatar
  • 1,467
4 votes
2 answers
254 views

Using injection for services that contain only pure functions

Imagine we have a service like the this: class SomeService { // A random pure function that transforms the input // without doing any remote calls or any side effects function ...
user avatar
  • 189
6 votes
6 answers
650 views

Is duplicating files to avoid programming branching a good or anti pattern?

for example, suppose I need to play different sounds according to "grade": file list: fairSound.mp3 goodSound.mp3 excellentSound.mp3 code: showResult(grade){ if(grade==0 || grade==1){ ...
user avatar
  • 5,572
0 votes
0 answers
68 views

For a responsive app, do frequent conditionals checking device size indicate a code smell or antipattern?

I have joined a team working on a large and mature responsive website (using a javascript MVC framework), and one thing I frequently see in the codebase is branching code in controllers or components ...
user avatar
  • 591
1 vote
2 answers
157 views

Is passing an ErrorMessage to be populated inside the receiving method an anti-pattern?

I come from a Java background, and my colleague is from .NET. We are working on a Java project and I saw him create a method like this: public Object myMethod(Object[] param1, ErrorMessage ...
user avatar
  • 131
2 votes
3 answers
713 views

Perplexed by dependency injection principle - what if it is runtime dependant which objects are created?

The antipattern-plagued game I'm creating is using ASP.NET Core, which, in many cases, requires the use of dependency injection. This is new and counter-intuitive to me. Up to now, I managed to limit ...
user avatar
  • 3,307
31 votes
6 answers
14k views

Why is it wrong to comment out code and then gradually remove it to keep track of what I've already done and what remains to be done?

Whenever I find out that a large portion of my code needs to be changed, either because it is incorrect or because it needs to be adapted to major architectural changes necessited by other reasons, ...
user avatar
  • 3,307
3 votes
1 answer
109 views

Auto-Initializable Objects Pattern

I'm working on a system where we consistently apply "patterns" or approaches such as Dependency Injection. I'd rather not expose the current underlying technology as not to get biased solutions, ...
user avatar
3 votes
3 answers
2k views

Passing a context object to the constructor or to the method

I am writing a recursive descent parser. Let ParseContext specifies the context for parsing. Pseudocode: class ParseContext { Logger logger; // logger for error/warning messages Locale ...
user avatar
  • 722
22 votes
5 answers
12k views

Is the use of ***Helper or *** Util classes containing just static methods an AntiPattern

I am often confrontated with helper or util classes in Java or whatever kind of language. So I was asking myself if this is some kind of Anti Pattern and the existence of these kind of classes is ...
user avatar
  • 329
4 votes
3 answers
2k views

CQRS+Event Sourcing as Top Level Architecture: Anti-Pattern

I have been study DDD along with CQRS and Event Sourcing. I recently listened to a talk Greg Young gave a couple years ago where he said that CQRS and Event Sourcing are not a top level architecture ...
user avatar
  • 318
34 votes
13 answers
5k views

If nulls are evil, what should be used when a value can be meaningfully absent?

This is one of the rules that are beaing repeated over and over and that perplex me. Nulls are evil and should be avoided whenever possible. But, but - from my naivety, let me scream - sometimes a ...
user avatar
  • 3,307
-4 votes
5 answers
813 views

Why do programmers like to stick to "Thou shalt" / "Thou shalt not" rules that define whether a code is of good or bad quality? [closed]

I'm not sure how to correctly describe my problem... Ever since I started learning how to program, I recognized that many more experienced programmers have very strict (and, in the POV of a beginner, ...
user avatar
  • 3,307
-1 votes
1 answer
696 views

Refactoring bad code switch statment without distort everything

Once in a while I’m stumbling on switch statements during a Code Review session. I would like to find a more elegant way of this code .... $istannceOfClass = $repository->loadFoo(); switch($...
user avatar

1
2 3 4 5