Questions tagged [anti-patterns]

A programming anti-pattern is a commonly used solution to a specific programming problem, often claiming being an actual design pattern. But such a solution usually leads to adverse effects on an application scalability, testability and maintenance.

Filter by
Sorted by
Tagged with
1 vote
0 answers
9 views

How do I name this anti-pattern

I'm new at this company and looking at the code I see a lot of examples of this pattern Class A { object data; getData() { data = ... } processData() { //Process items ...
Samy Boulos's user avatar
0 votes
0 answers
33 views

AWS Glue Crawler exclude option not working

I have s3 bucket as bucket/folder1/folder2/folder3. Inside folder3 I have two csv files such as report.csv and report.csv_abcd.csv. I have tried multiple regex to exclude the report.csv_abcd.csv which ...
Babu's user avatar
  • 111
0 votes
2 answers
62 views

How can i reduce an Arrow head type if statement with 3 different else`s?

im going to try to explain myself in the best way possible, i have a method that looks like this: if(condition1) if(condition2) { if(condition3) { //do something if ...
Sergio López López's user avatar
0 votes
1 answer
66 views

What is the jargon or area of study for this type of code (non-compliant, non-conforming)? [closed]

What is the technical jargon for a module/library that's considered bad because it strays from or changes standard behavior (especially implicitly)? For example, if I have module.js with the following ...
Joe Boris's user avatar
  • 487
0 votes
1 answer
41 views

Reducing Java code-duplication when iteratively applying an operation on a list until stable

I am attempting to reduce code duplication in my java code. I am not a java expert, so I might be missing something basic. The goal is to operate on a list via several operators, foo1, foo2, ..., fooN....
Caleb's user avatar
  • 148
1 vote
0 answers
14 views

Definig page component only by HOC in NextJS

I have nextjs (react) website I use (on every "page") same template - there is Detail and List component. I have definition of every page as XML (not nextjs thing but my implementation). ...
Petr Marek's user avatar
0 votes
1 answer
263 views

Injecting service in the class / pure functions

I am working on Angular project (Angular 14+) and following atomic design principles (creating minute level components like button, input, toggle etc.). Most of the views (list, forms, headers) are ...
Monis's user avatar
  • 165
0 votes
1 answer
43 views

How to make a sample that shows the 'Props are overwritten when re-rendering' anti pattern

I would like to be convinced that 'Props are overwritten when re-rendering' is an anti pattern. const MyButton = Vue.extend({ props: { obj: {} }, template: "<button @click=\"...
Mikael's user avatar
  • 69
0 votes
0 answers
40 views

How to update a child component that extends a parent class when the parent class updates?

I have a page that has a number of forms on it. In an effort to try and keep the forms consistent, I have a main Form class component that is extended by all the other forms. This parent Form ...
Barry Chapman's user avatar
0 votes
0 answers
79 views

How to filter items by multiple attribures using eav model?

I am building online catalog using eav antipatern. I know this is bad pattern, but i need to be able to add properties at runtime, so i choosed this.Also i cant use solr, because i use hotsted ...
alex sasai's user avatar
0 votes
0 answers
178 views

Does using the combination of useReducer with too many useEffects an anti-pattern?

I have created a Select Dropdown component with its state abstracted in the reducer. I am just updating this collective state using reducer actions and handling the side effects via useEffect but ...
Abhinay's user avatar
  • 11
0 votes
1 answer
245 views

Building app and Anti pattern (distributed monolith...)

We are currently working on an app that will store IoT data in a database ( process it like average etc...) and make it available through Rest API. Our first though is of course to build one app (good ...
SebUndefined's user avatar
0 votes
0 answers
113 views

Anti-pattern name for the raw usage of `List<List<Object>>` instead of some data transfer objects `List<DTO>`

Is there any known anti-pattern name for the raw usage of List<Object> that is actually List<List<Object>> instead of some data transfer objects List<DTO>? class Main { ...
rostIvan's user avatar
  • 264
0 votes
0 answers
245 views

Is putting a global state in useEffect deps considered bad practice?

I recently stumbled upon an issue where a value that is stored in global state(redux) is watched in React component, especially in useEffect hook dependancy. To be specified, it was an authenticated(...
JunKim's user avatar
  • 667
0 votes
1 answer
203 views

Is a forEach in redux reducer an anti-pattern?

I have a forEach loop which checks if a certain attribute of data coming in includes '/' if it does im replace the '/' with '-', i was wondering if that is valid redux code or im creating some sort of ...
karterkortland's user avatar
11 votes
1 answer
36k views

How to fix React Warning : Can't perform a React state update on an unmounted component

Whenever if there is any asynchronous task performing related to component and that component unmounts then React generally gives this warning - Can't perform a React state update on an unmounted ...
user15650989's user avatar
1 vote
1 answer
768 views

Is there an alternative to Template Method pattern when using common logic?

I have a problem. Most of the solutions in the project follow the Template Method design pattern. At the same time, along with the complexity of business logic, solutions are becoming more and more ...
Learner's user avatar
  • 13
1 vote
1 answer
364 views

Is folder name shadowing 3rd-party package name or Python module name is an anti-pattern?

Consider the following (very simplified) project structure: project/ src/ collections/ validators/ foo/ bar/ The "collections" sub-directory name shadows ...
Nairum's user avatar
  • 1,257
1 vote
2 answers
2k views

C# - How to inject new instance of dependency to a class which get instantiated once in the app lifetime?

Here is a class which will be instantiated only once through out the lifetime of the application public class SampleClass //instantiated only once { public void DoOpertation()//will be called by ...
ecma-402's user avatar
1 vote
1 answer
62 views

Does Information Expert pattern contradict Service Layer Pattern?

While reading about GRASP patterns I stopped at Information Expert, which states that behavior on classes state should be within that same class. But that is a complete opposite with Service Layer ...
Bohdan Onufriychuk's user avatar
0 votes
1 answer
2k views

Best practice for an optional return value

Suppose a function cannot compute a valid return value. For example, a dictionary lookup may fail to find a key. What are the best practices for such a situation when a function returns one or no ...
Ryota Tomioka's user avatar
0 votes
0 answers
87 views

Does this component fit into the Anti-Patterns of React?

How can I rewrite this component so it doesn't go against the rules of React? I'm calling the function renderButtonType() inside of the render(). Is that the correct way to conditionally render the ...
jefelewis's user avatar
  • 1,850
1 vote
2 answers
451 views

Why inject the entire DbContext instead of just the necessary DbSets?

I've seen a lot of projects whether the entire DbContext is injected in a class: public class MyClass { public MyClass(MyDbContext context) { ... } public void DoStuff() ...
stacksucks's user avatar
1 vote
3 answers
3k views

Is it an anti-pattern to use variables the outside of React function component?

Is below case an anti-pattern in React? Variables and functions might be declared outside a React function component for some reasons. For example, an timer ID and others could be used as below: ...
Dongwook Kim's user avatar
12 votes
1 answer
3k views

What is the "Smart UI Anti-Pattern"?

In his book, Implementing Domain-Driven Design, Vaughn Vernon states, When there are User Interface views that render the model and drive execution of its behavior, these are also inside the Bounded ...
Julien Gavard's user avatar
0 votes
2 answers
188 views

Best way design and generate unique strings from an array of objects for mapping

The problem I am trying to solve is how best to generate a unique string from a set of question/answer strings. So say an end user fills out a questionnaire and answers the following: [ { ...
motime545's user avatar
2 votes
1 answer
175 views

React Context: Nested re-use/enhancement (anti-pattern?)

I would like to know if it is an anti-pattern to create nested context providers (the same context) and progressively extend the data. So, using the current context and enriching/overriding it from ...
Gabriele Petrioli's user avatar
0 votes
1 answer
173 views

Is this an anti-pattern/code smell? - Using enum/class of consts to access class properties with [] instead of using dot property

class FruitFields { static const NAME = "name"; static const DESCRIPTION = "descriptionText"; } class Fruit { final string name; final string descriptionText; Fruit(required ...
user2561417's user avatar
0 votes
1 answer
132 views

Is self injection a good practice? Same class injection programming pattern in PHP

Is injection of the same class a good practice? I am using self-injection for years to isolate methods during PHPunit testing: class Meter extends Model { use SomeTrait; protected self $self; ...
Eugene Kaurov's user avatar
-3 votes
1 answer
1k views

Singleton is design-pattern or anti-pattern? [closed]

Singleton is design-pattern or anti-pattern??
Mohammad reza Golshahi's user avatar
0 votes
0 answers
194 views

Is two way classes association bad?

I was developing one tool, and noticed what my classes use "two way association". Objects of class A have a pointer to B, and B have pointer to A. I tried to find out, is that a bad design ...
MadL1me's user avatar
  • 31
3 votes
1 answer
258 views

Is "static Domain helper class" Ambient Context Anti-Pattern?

As defined in the Manning book by Steven van Deursen and Mark Seemann, "Dependency Injection Principles, Practices, and Patterns" (which I recommend as must-read), there is one specific anti-...
Marko Krstic's user avatar
4 votes
1 answer
559 views

Is inheriting from the EventEmitter an antipattern?

It appears to be common practice to inherit from the EventEmitter if you want your class to support events. For example Google does it for Puppeteer, the WebSocket module does it, mongoose does it, ......
Forivin's user avatar
  • 14.8k
3 votes
0 answers
3k views

Get value of field with lombok builder

Is it possible to retrieve the value of a field on a builder which was generated by lombok? final var builder = Something.builder(); try { // ... something that might break } catch (Throwable t) {...
Josh M.'s user avatar
  • 26.5k
0 votes
0 answers
89 views

How can I eliminate a "rank() over (...order by timestamp)" pattern in Hive?

This pattern seems very inefficient: SELECT * FROM table1 a inner join ( SELECT * ,rank() over (partition by orderNum order by orderUpdateTime) rnk ) b ... WHERE b.rnk = ...
Drew R's user avatar
  • 133
0 votes
2 answers
1k views

Dao in Usecase. MVVM or Clean Architecture anti-pattern?

In our "SearchUsecase" we have access to "ShowFtsDao" directly. Does it violate the Clean Architecture principles? Does it violate the MVVM architecture? Assuming our intention is ...
Hossein Mirzazadeh's user avatar
0 votes
2 answers
314 views

Refactoring Promise code to remove async/await in new promise constructor

I had been reading and saw that it is an anti pattern to use async/await in the promise constructor. I had the following code in my current project and I wish to refactoring it but not very sure how I ...
Joox's user avatar
  • 1
0 votes
1 answer
391 views

Python decorator taking additional argument anti-pattern

Is adding an argument to a function through a wrapper a python anti-pattern? I want to add a wrapper that saves the output of many functions to a location, so a wrapper seems to make sense. However, ...
Mason Caiby's user avatar
  • 1,846
0 votes
1 answer
750 views

Counting lines or enumerating line numbers so I can loop over them - why is this an anti-pattern?

I posted the following code and got scolded. Why is this not acceptable? numberOfLines=$(wc -l <"$1") for ((i=1; $i<=$numberOfLines; ++$i)); do lineN=$(sed -n "$i!d;p;q" &...
tripleee's user avatar
  • 176k
0 votes
1 answer
146 views

Is async code in a Promise always an antipattern?

I see from this question that it can be an antipattern to mix Promises with async code. Does this, however, apply in all cases? I can't see an easy way to avoid combining them in the following code: ...
JamesTheAwesomeDude's user avatar
1 vote
1 answer
28 views

What is this anti-pattern? Invoking a function for a latent effect

Is there a name for this anti-pattern? The best way I can describe it is "invoking a function for a latent effect, not for its primary purpose". Function A does X and Z Function B does Y ...
cambunctious's user avatar
  • 8,471
0 votes
1 answer
138 views

Is it an anti-pattern to use the suffix "Template" for the class name of the template method pattern?

I am using the template method pattern. My abstract class has a skeleton method processing iteration and logging. like this: abstract public class ImportingTemplate implements Importing{ ...
chytonpide's user avatar
2 votes
0 answers
68 views

data.table anti-pattern when adding/modifying a new column [closed]

I am rather new to R and working on an existing code base heavily using data.table. I understand one of the correct way to add a column or modify an existing one is: my.table[ , new_column := "...
Arnold Dumas's user avatar
1 vote
0 answers
59 views

Is using const == thread safe a bad practice [duplicate]

I just listened to this talk about how const actually means bitwise immutable OR thread safe in and after c++11. Furthermore we should guarantee const functions to be thread safe. This is all well and ...
A.Hristov's user avatar
  • 481
1 vote
2 answers
971 views

Is synchronous communication between services anti-pattern in microservices?

I am somewhat new to microservices. I am currently developing an application using microservices and I am using both synchronous and asynchronous communication methods. Recently I saw few article ...
Supun Praneeth's user avatar
1 vote
1 answer
228 views

Is this an anti pattern?

Currently I am confronted often with code that follows the pattern demonstrated by the code bellow. It is kind of a strategy pattern. I am not fine with this, it feels somehow smelly. It breaks the ...
aiquita's user avatar
  • 19
5 votes
2 answers
1k views

Is extending a widget really an antipattern?

I've read in couple places that extending a Flutter widget is an anti-pattern. Is that true? I've used widget subclassing to cut down on nesting by subclassing the widget I'm removing and put its ...
buttonsrtoys's user avatar
  • 2,399
4 votes
3 answers
333 views

Bad idea to put a dom operation inside a redux reducer?

I have several actions which use the same reducer, and instead of having a dom operation in each of those actions, I want to just add it once inside my shared reducer. I know reducers are to be pure (...
ram's user avatar
  • 680
1 vote
1 answer
927 views

Is returning a void response for Service APIs a good practice?

I am planning to build APIs to perform CRUD operations. I have the following APIs: CreateEntry UpdateEntry For CreateEntry API, I am accepting CreateEntryRequest and CreateEntryResponse as request ...
Anirudh Mergu's user avatar
0 votes
0 answers
135 views

What is this data referencing anti-pattern called?

I have a question related to a kind of duplication I see in databases from time to time. To ask this question, I need to set the stage a bit: Let's say I have a database of TV shows. Its primary ...
rotarydial's user avatar
  • 2,211

1
2 3 4 5
9