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
1
vote
3answers
262 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 ...
1
vote
1answer
349 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 ...
1
vote
2answers
100 views

Explaining concepts [closed]

How can I explain a concept when I don't know its name or any formal reason for it? The reason I ask is this... A new programmer has entities with a property title in his system. He uses the title to ...
1
vote
1answer
535 views

How to Avoid a Busy Loop Inside a Function That Returns the Object That's Being Waited For

I have a function which has the same interface as Python's input builtin, but it works in a client-server environment. When it's called, the function, which runs in the server, sends a message to the ...
1
vote
1answer
4k views

Code reuse via inheritance [duplicate]

I have a set of classes that are all dealing with some related tasks. These tasks do have different inputs and outputs. This causes it to become impossible to have the tasks done via shared code ...
1
vote
2answers
308 views

What's the name of this pattern involving multiple inputs and what to do based on an input?

If I've got code similar to this (although perhaps not as constrained as warning levels): switch(item.StatusCode) { case StatusCode.SUCCESS: CallSuccess(item); break; case ...
1
vote
1answer
2k views

AMQP routing-keys naming anti-patterns when using topics

I'm working on the specification for building a web services platform and AMQP is the messaging protocol used for the interaction between the components of this platform. I'm using topic exchanges ...
1
vote
1answer
2k views

Is using __import__('module_name') an antipattern in Python?

I'm currently refactoring a Python 2 project which includes the ability to add or remove plugins, which are Python modules implementing a given API. The main app accesses add/remove/update hooks in ...
1
vote
2answers
153 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 ...
1
vote
3answers
248 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 ...
1
vote
1answer
382 views

Refactoring god-class leads to feature envy [closed]

I'm trying to refactor a 2.5KLOC god-class (with about 68 data members and 62 member functions) that performs a wide variety of text formatting and layout operations. After a careful analysis based on:...
1
vote
1answer
261 views

Service/component based application in Java

I have a Java project whose architecture is quite component-oriented, and I am wondering if this is a common way to organize code which rules/patterns are used, if there is a name for this coding ...
1
vote
1answer
108 views

Lookup pattern as a way of passing global references

I am looking at some legacy code in java that uses the Service Locator pattern as a way of passing global references as opposed to passing them over and over again through method arguments and I am ...
1
vote
1answer
678 views

Using inner classes to achieve thread-safe behavior without synchronization

I have some classes that contains both immutable (primitive & references) and mutable data, but mutability come from external writes (another process). To avoid using synchronized on every ...
1
vote
3answers
425 views

Is synchronously inspecting a promise an anti-pattern?

ES6 native promises do not allow you to synchronously check if they're resolved/pending/failed or to extract their value. I sometimes need this functionality and thus I have to code it manually. Is ...
1
vote
1answer
578 views

How to avoid big class complexity while keeping encapsulation?

I'm developing a PHP library to work with big numbers (at this moment only with a "Decimal" class, but I want to add new classes, to handle Integers, Rationals, and Complex numbers). In any case, the ...
1
vote
1answer
83 views

Is having a parent controller to manage a set of tabbed sections an anti-pattern for an angular application?

A lot of times, I have long forms that I divide into multiple tabbed sections. Each section is managed by it's own controller and there is a parent controller that manages the whole view. I use ui-...
1
vote
2answers
552 views

Why do IoC containers provide public Resolve method(s)?

In my opinion it just inverses the inversion and could make new users (including myself) make incorrect assumptions about using IoC containers. It can be used for the Service Locator (anti-)pattern ...
1
vote
1answer
148 views

How do you wrestle the DRY principle with configs?

For instance, lets say we have an nginx config pointing at foo1, foo2, and foo3, as well as a haproxy config pointing at foo1, foo2, and foo3, and finally, a deployment tool pointing at the same ...
1
vote
1answer
2k views

Modular Database Structures

I have been examining the code base we use in work and I am worried about the size the packages have grown to. The actual code is modular, procedures have been broken down into small functional (and ...
1
vote
1answer
36 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, ...
1
vote
0answers
39 views

Where to override the design of jQuery UI elements?

We are using a few jQuery UI elements in our web application, and I need to change their design. For example, the ui-progressbar is way too high and its rounded corners don't fit well with our design. ...
1
vote
1answer
2k views

Why singleton is an anti-pattern? [duplicate]

Many articles in Internet say that singleton is an anti-pattern, because it makes debugging more difficult. However I don't understand why debugging a program with a singleton object is difficult. ...
0
votes
3answers
2k views

How can I explain this is an anti-pattern? [closed]

I recently started at a new job. The existing system works OK but is poorly designed and hard to maintain, and they are planning to rebuild it in MVC and I fear it will be much worse. (Not because ...
0
votes
4answers
370 views

How to deal with low or medium dev team level?

In our team we have some low / medium level developers: they know how to write C#/JavaScript code, but most of it is an anemic domain model in a purely functionnal way of coding, but there are no unit ...
0
votes
2answers
67 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 ...
0
votes
2answers
476 views

Is it acceptable to escalate a software error to HTTP 500?

Should an error 500 only be thrown by the web server, or is it acceptable for your program to throw one itself? try { some bad code; } catch (Exception) { set_header_code(500); set_content_type(...
0
votes
1answer
284 views

How could I avoid singletons in this case? [duplicate]

Using Dart in the client part of a web app where I have an application manager that contains a List of application instances and references to services that are used by each application as in the ...
0
votes
2answers
242 views

Is there a name for this data structure pattern consisting of a list of dictionaries each with one entry, consisting of an object? [closed]

There is a data structure idiom that looks something like this: [ { obj_1_id: { key1: value1_1, key2: value2_1 } }, { obj_2_id: { key1: ...
0
votes
1answer
685 views

Finding a definition for this anti-pattern

Working on a large and multi-tiered software project, I just found a recurring anti-pattern to be occurring in the code. I coulnd't find its definition in Wikipedia or other sources after a quick ...
0
votes
1answer
359 views

Is there an official name for the “one object disease” anti-pattern (iterative single object operations on databases, services etc.)?

It is caused by the naive programming paradigm: focus on just a single object, do something with it, and if you have to work with many objects, you loop, iterate and traverse, repeating the operation ...
0
votes
2answers
1k views

How to avoid using service location when using dependency injection? [closed]

I am trying to use dependency injection in a WPF application, and I really can't figure how to avoid using service location, which is considered to be an anti-pattern in many articles. I am using the ...
0
votes
1answer
928 views

Is this a good service locator, and is this service locator pattern(?) OK?

I'm working in Zend framework 1 and was using Zend_Registry to store objects so that I could replace them in my controllers while unit testing: $auth = Zend_Registry::get('Auth'); // set in Bootstrap....
0
votes
1answer
126 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 ...
0
votes
1answer
112 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 ...
0
votes
1answer
73 views

Is creating near duplicate partial views solely for populating html elements with Ajax returns violating DRY?

Maybe anti-pattern is a better word for this question. I do not know, but I mean a violation of DRY. Id like to reuse a partial view, and I can, but that partial view has other things in it I don't ...
0
votes
1answer
239 views

Inverse of Extract Interface refactoring

I'm working with a Java project that has several interfaces, many of which have only one implementation. (See related question) For a given revision of the software, one could think this acceptable ...
0
votes
1answer
2k 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
1answer
87 views

terminology for upward devolution from modules to framework

Is there a word for the problem of a framework becoming married to the software modules it supports, for example adding methods to a base class that may apply only to certain subclasses or use cases? ...
0
votes
0answers
65 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 ...
0
votes
0answers
199 views

A modification of singleton pattern

"Singleton" is widely considered anti-pattern ("bad" in everyday language). What about this alternative modified singleton pattern? An object constructor for our class ensures that at any given ...
0
votes
0answers
115 views

Excessive LINQ chaining - Is it considered a code smell, and why? [duplicate]

I am in a current iteration between design and implementation, and ended up with the following "one-liner": IEnumerable<Channel> ActiveChannels = Receiver.AcquisitionInfo ...
-1
votes
1answer
270 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($...
-1
votes
1answer
76 views

Experimentally determined timing of function/method calls vs locks, signals. Anti-pattern name?

Here is some pseudocode and paraphrased comments: // Allow time for screen to start before content reset. // Delay time determined by testing with platform version 5. delayCall(0.01, contentReset()) ...
-2
votes
2answers
1k views

What is the difference between Code Smells and Anti Patterns?

I am trying to understand the difference between these two terms. In some contexts that these two terms have been used interchangeably. What is the exact difference between these two terms ?
-2
votes
1answer
147 views

Is there a named antipattern for unclear API not exposing the requirements? [closed]

In the source code I'm evaluating (jarjar), there exists java code that can be used like this: JarJarTask fixture = new JarJarTask(); fixture.addConfiguredRule(new Rule()); fixture.execute(); Which ...
-3
votes
5answers
200 views

How to convince others to effect change? [closed]

I'm low man on the totem pole (consultant) who was pulled into a project for a large organization. How do you explain that this large organization practices zero industry standards and follows no ...
-3
votes
3answers
332 views

how to protect against theft of a class. (neural network class) [duplicate]

I am writing software that makes use of a neural net. What makes my network special as compared to others, is the way I train them. Its non standard, its something that I don't want to give away to ...
-4
votes
5answers
599 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, ...
-6
votes
3answers
915 views

How can hard-coding be considered a code smell in the age of micro-services?

As an intermediate stage hard-coding is accepted by Google in their Tour of Heroes Angular tutorial but the benefit cannot surely only be for novices. Do people not understand that hard-coding as an ...