Click here to Skip to main content
Click here to Skip to main content

Some of the Anti Patterns

, 16 Jul 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
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. 

Symptoms
  • Single class with many attributes & operation
  • Controller class with simple data object class
  • Lack of Object oriented design
  • A migrated legacy design
Consequences
  • 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.

Symptoms
  • 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
Causes
  • 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.
Symptoms
  • 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
Causes
  • 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.

Symptoms
  • 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
Causes
  • 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.

License

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

Share

About the Author

Atulkumar P Patel
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.
~Atul
Follow on   Twitter

Comments and Discussions

 
GeneralMy vote of 5 PinprofessionalS. M. Ahasan Habib5-Nov-13 19:22 
GeneralMy vote of 5 PinprofessionalDavid H. Wright15-Aug-13 11:36 
GeneralMy vote of 5 PinmemberArash M. Dehghani25-Jul-13 22:02 
QuestionSuggestions PinmemberShameel23-Jul-13 2:50 
AnswerRe: Suggestions PinmemberAtulkumar P Patel23-Jul-13 4:37 
QuestionHuman component PinmemberAlexandro Ramos Rodríguez22-Jul-13 13:20 
AnswerRe: Human component PinmemberAtulkumar P Patel23-Jul-13 4:41 
GeneralRe: Human component PinmemberAlexandro Ramos Rodríguez23-Jul-13 8:46 
SuggestionMissing option PinmemberDavide Zaccanti17-Jul-13 22:41 
QuestionNice article.. Pinmemberprdshukla17-Jul-13 18:23 
GeneralMy vote of 1 PinmemberClaudrian17-Jul-13 17:17 
GeneralRe: My vote of 1 PinmemberAtulkumar P Patel17-Jul-13 17:31 
Questionnot bad PinmemberCIDev17-Jul-13 4:58 
GeneralMy vote of 5 PinmemberVasily Tserekh17-Jul-13 4:36 
GeneralRe: My vote of 5 PinmemberAtulkumar P Patel17-Jul-13 4:38 
GeneralFunctional Decomposition PinmemberRuchiH17-Jul-13 2:32 
GeneralRe: Functional Decomposition PinmemberAtulkumar P Patel17-Jul-13 4:37 
GeneralRe: Functional Decomposition PinmemberAlexandro Ramos Rodríguez22-Jul-13 12:35 
GeneralMy vote of 3 Pinmemberabdurahman ibn hattab16-Jul-13 22:11 
GeneralRe: My vote of 3 PinprofessionalH. Mueller16-Jul-13 23:09 
GeneralRe: My vote of 3 PinmemberAtulkumar P Patel17-Jul-13 4:49 
GeneralMy vote of 5 PinprofessionalH. Mueller16-Jul-13 21:55 
GeneralRe: My vote of 5 Pinmemberabdurahman ibn hattab16-Jul-13 22:15 
GeneralRe: My vote of 5 PinmemberAtulkumar P Patel17-Jul-13 4:51 
GeneralRe: My vote of 5 PinmemberSeishin#17-Jul-13 2:09 

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

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

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.141220.1 | Last Updated 16 Jul 2013
Article Copyright 2013 by Atulkumar P Patel
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid