Click here to Skip to main content
15,612,563 members
Articles / Programming Languages / C# 3.5
Posted 16 Jul 2013


22 bookmarked

Some of the Anti Patterns

Rate me:
Please Sign up or sign in to vote.
4.37/5 (22 votes)
16 Jul 2013CPOL4 min read
Anti Patterns are wrong practice followed by Developers. They are opposite to Design Patterns.

Anti Patterns

It is exactly opposite of software design Patterns. Some the well known anti patterns are the problems which software industry faces. Anti patterns are out comes of following bad practices, over engineering, implementation of design patters without having enough knowledge of patterns or not understanding the context of problem.

Anti patterns are real world experience of understand recurring problems of software industry. It helps to recognize problems and understand the cause of it. They are also a bridge between understanding architectural concepts and its real world implementations.

There are three categories of software anti patterns like:

  1. Software development anti patterns
  2. Software architectural anti patterns
  3. Software Project Management anti patterns

Some of the Development Anti Patterns

1. God Object (Monster Object)

If some object knows too much or does too much, it is called a God object which is opposite to Single responsibility Principle one of the SOLID principal.

If the problem is big, it is very hard or tough to resolve it. So if we divide it into smaller parts of problem, it is easy to solve them. So in software engineering, if we create an object with single responsibility, we should divide one big task into smaller separate responsibility (class) so when any change or problem occurs, we have to change a smaller class and also we have to test only one smaller class after change. 

In case of God object, it is very tough to maintain it. It is also very tough to test it. If we change something small of a God object, we have to test the whole object functionality. 

  • Single class with many attributes & operation
  • Controller class with simple data object class
  • Lack of Object oriented design
  • A migrated legacy design
  • Tough to maintain
  • Tough to test
  • Lost all object oriented advantage
  • Too complex to reuse
  • Expensive to load

2. Copy and Paste Programming

This is a favorite of any developer including myself. Ctrl + C, Ctrl + V is part of any developer's life. It is good if you are doing it from external sources to boost your development with good understanding of it, but it becomes Anti pattern when you do it with your own code. If you are doing copy and paste of your own code, then it is an Anti pattern.

  • Similar code found in an application
  • When client changes the requirement, you have to change code at more than 1 place
  • Bug found by tester and developer has fixed it, but it reoccurs (because it was not fixed in all the places)
  • No code review done by experienced programmer or lead
  • It has huge maintenance efforts, If some requirement changed, developer has to change code to many places.
  • Developer's lack of knowledge of software development principals like OOPs, SOLID, DRY (Do not Repeat Yourself).
  • Lack of forward thinking among developers.
  • A "Not Invented Here" syndrome applied to development environment. Meaning development environment does not adopt external tools and employ reinvent the wheel.
  • Developers lack of knowledge of new easy technology available.
Whenever you as an developer come across the situation to copy and paste your own code, stop that and find the opportunity to write it with common class or component and make it reusable with loose coupling.

3. Functional Decomposition

In Object oriented environment, If someone writes code in procedural programming way, just decompose main methods into several private methods, only then it becomes Anti Patterns. So instead of writing different classes or design class architecture according to different tasks, if code is just decomposed into private methods only then it is an anti pattern. This is mostly done by an experienced programmer in procedural languages like C and shifted to Object oriented programming language.
  • All Class attributes are private and used in one class
  • Degenerated architecture and missed most object oriented architecture
  • No use of reusability
  • Very tough to do documentation or design class diagram
  • Lack of object oriented design understanding
  • Lack of architecture enforcement

4. Spaghetti Code

Spaghetti code is a code meaning unstructured code, written by a developer who is less experienced or lacks knowledge of Object oriented programming. Code written like a procedural programming. In this kind of code, the developer himself can't understand his own code after a few days. The code looks like spaghetti.

  • Code is not much reusable
  • Flow of execution dictated by objects and not the client of the objects
  • Minimum relationship exits between objects
  • Code is not unit testable. or ends up writing too many integration tests
  • No advantage of Object oriented programming
  • Very difficult to maintain. so maintenance cost is higher than rewriting new from scratch
  • Code written by inexperienced object oriented programming developer
  • No design prior to development
  • No effective code review
Whenever an experienced developer sees this kind of code, he smells it and finds an opportunity to refactor it.

There are some other anti patterns as well. I will understand them thoroughly and edit this blog.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Technical Lead torchmark
United States United States
I believe that Writing a good code is an investment. So always try to find better way to write code and also share it with others.

Comments and Discussions

GeneralMy vote of 5 Pin
S. M. Ahasan Habib5-Nov-13 18:22
professionalS. M. Ahasan Habib5-Nov-13 18:22 
GeneralMy vote of 5 Pin
David H. Wright15-Aug-13 10:36
professionalDavid H. Wright15-Aug-13 10:36 
QuestionSuggestions Pin
Shameel23-Jul-13 1:50
professionalShameel23-Jul-13 1:50 
AnswerRe: Suggestions Pin
Atulkumar P Patel23-Jul-13 3:37
professionalAtulkumar P Patel23-Jul-13 3:37 
QuestionHuman component Pin
Alexandro Ramos Rodríguez22-Jul-13 12:20
Alexandro Ramos Rodríguez22-Jul-13 12:20 
AnswerRe: Human component Pin
Atulkumar P Patel23-Jul-13 3:41
professionalAtulkumar P Patel23-Jul-13 3:41 
GeneralRe: Human component Pin
Alexandro Ramos Rodríguez23-Jul-13 7:46
Alexandro Ramos Rodríguez23-Jul-13 7:46 
SuggestionMissing option Pin
Davide Zaccanti17-Jul-13 21:41
Davide Zaccanti17-Jul-13 21:41 
Use algorithm / schema based on first sample (maybe second for experts) that can be find / googled on internet.
QuestionNice article.. Pin
Pradeep Shukla17-Jul-13 17:23
professionalPradeep Shukla17-Jul-13 17:23 
GeneralMy vote of 1 Pin
Claudrian17-Jul-13 16:17
Claudrian17-Jul-13 16:17 
GeneralRe: My vote of 1 Pin
Atulkumar P Patel17-Jul-13 16:31
professionalAtulkumar P Patel17-Jul-13 16:31 
Questionnot bad Pin
BillW3317-Jul-13 3:58
professionalBillW3317-Jul-13 3:58 
GeneralMy vote of 5 Pin
Vasily Tserekh17-Jul-13 3:36
Vasily Tserekh17-Jul-13 3:36 
GeneralRe: My vote of 5 Pin
Atulkumar P Patel17-Jul-13 3:38
professionalAtulkumar P Patel17-Jul-13 3:38 
GeneralFunctional Decomposition Pin
RuchiH17-Jul-13 1:32
RuchiH17-Jul-13 1:32 
GeneralRe: Functional Decomposition Pin
Atulkumar P Patel17-Jul-13 3:37
professionalAtulkumar P Patel17-Jul-13 3:37 
GeneralRe: Functional Decomposition Pin
Alexandro Ramos Rodríguez22-Jul-13 11:35
Alexandro Ramos Rodríguez22-Jul-13 11:35 
GeneralMy vote of 3 Pin
abdurahman ibn hattab16-Jul-13 21:11
abdurahman ibn hattab16-Jul-13 21:11 
GeneralRe: My vote of 3 Pin
nobodyxxxxx16-Jul-13 22:09
nobodyxxxxx16-Jul-13 22:09 
GeneralRe: My vote of 3 Pin
Atulkumar P Patel17-Jul-13 3:49
professionalAtulkumar P Patel17-Jul-13 3:49 
GeneralMy vote of 5 Pin
nobodyxxxxx16-Jul-13 20:55
nobodyxxxxx16-Jul-13 20:55 
GeneralRe: My vote of 5 Pin
abdurahman ibn hattab16-Jul-13 21:15
abdurahman ibn hattab16-Jul-13 21:15 
GeneralRe: My vote of 5 Pin
Atulkumar P Patel17-Jul-13 3:51
professionalAtulkumar P Patel17-Jul-13 3:51 
GeneralRe: My vote of 5 Pin
Seishin#17-Jul-13 1:09
Seishin#17-Jul-13 1:09 
GeneralRe: My vote of 5 Pin
Atulkumar P Patel17-Jul-13 3:52
professionalAtulkumar P Patel17-Jul-13 3:52 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.