<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wikimaster</id>
	<title>Expertiza_Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.expertiza.ncsu.edu/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Wikimaster"/>
	<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=Special:Contributions/Wikimaster"/>
	<updated>2026-07-15T22:20:20Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27650</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27650"/>
		<updated>2009-11-17T21:35:01Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Anemic Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti-patterns were used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system.&lt;br /&gt;
*Inexperience on the part of the programmer.&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
Some of the important software design anti-patterns are,&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstraction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the index to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**[http://en.wikipedia.org/wiki/Mutex Mutexes] can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Pushbutton===&lt;br /&gt;
This is a very common anti-pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
* The code for in those defined functions grow large.&lt;br /&gt;
* Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
* Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by re-factoring the business logic. In the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
Some of the important Object-oriented design anti-patterns are,&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOPs principle of data and behavior [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are multiple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practice of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a anti-pattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practice because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsibility on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the code base doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27648</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27648"/>
		<updated>2009-11-17T21:34:25Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Software design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti-patterns were used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system.&lt;br /&gt;
*Inexperience on the part of the programmer.&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
Some of the important software design anti-patterns are,&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstraction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the index to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**[http://en.wikipedia.org/wiki/Mutex Mutexes] can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Pushbutton===&lt;br /&gt;
This is a very common anti-pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
* The code for in those defined functions grow large.&lt;br /&gt;
* Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
* Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by re-factoring the business logic. In the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
* Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
Some of the important Object-oriented design anti-patterns are,&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOPs principle of data and behavior [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are multiple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practice of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a anti-pattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practice because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsibility on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the code base doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27643</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27643"/>
		<updated>2009-11-17T21:31:45Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti-patterns were used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system.&lt;br /&gt;
*Inexperience on the part of the programmer.&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstraction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the index to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Pushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by re-factoring the business logic. In the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
Some of the important Object-oriented design anti-patterns are,&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOPs principle of data and behavior [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are multiple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practice of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a anti-pattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practice because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsibility on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the code base doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27641</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27641"/>
		<updated>2009-11-17T21:30:00Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti-patterns were used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system.&lt;br /&gt;
*Inexperience on the part of the programmer.&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstraction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Pushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by re-factoring the business logic. In the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
Some of the important Object-oriented design anti-patterns are,&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOPs principle of data and behavior [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are multiple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practice of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a anti-pattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practice because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsibility on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the code base doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27639</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27639"/>
		<updated>2009-11-17T21:29:17Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti-patterns were used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system.&lt;br /&gt;
*Inexperience on the part of the programmer.&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstraction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Pushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by re-factoring the business logic. In the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
Some of the important Object-oriented design patterns are,&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOPs principle of data and behavior [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are multiple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behavior (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practice of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a anti-pattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practice because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsibility on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the code base doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27630</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27630"/>
		<updated>2009-11-17T21:26:26Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* BaseBean */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the codebase doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27628</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27628"/>
		<updated>2009-11-17T21:25:43Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* BaseBean */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the codebase doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27624</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27624"/>
		<updated>2009-11-17T21:21:37Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the codebase doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as you go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27622</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27622"/>
		<updated>2009-11-17T21:21:08Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the codebase doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27621</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27621"/>
		<updated>2009-11-17T21:20:48Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Conclusion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
The Significance of anti-patterns is the same as design patterns, anti-patterns are real helpful in identifying bad design.Thus the beforehand knowledge of anti-patterns comes in handy in making sure that the codebase doesn't make use any of it. They should be identified at early stage of [http://en.wikipedia.org/wiki/Systems_Development_Life_Cycle SDLC life cycle], because it might require significant effort to remove anti-patterns as go down the SDLC life cycle.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27612</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27612"/>
		<updated>2009-11-17T21:03:23Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Anemic Domain Model */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27611</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27611"/>
		<updated>2009-11-17T21:02:46Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* BaseBean */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27609</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27609"/>
		<updated>2009-11-17T21:01:39Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Known classifications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
Some of the widely used anti-patterns are classified into the following categories,&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Organizational_anti-patterns Organizational anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Project_management_anti-patterns Project management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Analysis_anti-patterns Analysis anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Software_design_anti-patterns Software design anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Configuration_management_anti-patterns Configuration management anti-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Programming_anti-patterns Programming anit-patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern#Methodological_anti-patterns Methodological anti-patterns]&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27605</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27605"/>
		<updated>2009-11-17T20:52:00Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
===Anemic Domain Model===&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===BaseBean===&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. &lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
===CallSuper===&lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
*'''Example'''&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27603</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27603"/>
		<updated>2009-11-17T20:49:34Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Magic Bushbutton */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this are,&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27602</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27602"/>
		<updated>2009-11-17T20:48:27Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27601</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27601"/>
		<updated>2009-11-17T20:47:39Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27600</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27600"/>
		<updated>2009-11-17T20:47:10Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Race Hazard */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27599</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27599"/>
		<updated>2009-11-17T20:46:44Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27598</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27598"/>
		<updated>2009-11-17T20:46:21Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27597</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27597"/>
		<updated>2009-11-17T20:45:47Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27595</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27595"/>
		<updated>2009-11-17T20:45:11Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27593</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27593"/>
		<updated>2009-11-17T20:44:50Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Big ball of mud */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
**Good understanding of the system prior to any major code changes.&lt;br /&gt;
**Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
**Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27592</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27592"/>
		<updated>2009-11-17T20:44:17Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
*'''Solution'''&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.&lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27591</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27591"/>
		<updated>2009-11-17T20:43:40Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
*'''Example'''&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27590</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27590"/>
		<updated>2009-11-17T20:43:04Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27589</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27589"/>
		<updated>2009-11-17T20:42:19Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Abstraction Inversion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* '''Example'''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* '''Solution'''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27588</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27588"/>
		<updated>2009-11-17T20:41:08Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Abstraction Inversion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* ''Example''&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* ''Solution''&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27587</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27587"/>
		<updated>2009-11-17T20:39:34Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Abstraction Inversion */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* Example&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
* Solution&lt;br /&gt;
**Choose the infrastructure carefully.&lt;br /&gt;
**If the system offers w=equivalent functions, use them.&lt;br /&gt;
**Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27585</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27585"/>
		<updated>2009-11-17T20:38:46Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* Example&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
** Solution&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27584</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27584"/>
		<updated>2009-11-17T20:38:11Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Example */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
* Example&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27581</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27581"/>
		<updated>2009-11-17T20:37:12Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Definition */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
    float CalculateTotal(int quantity, float price){&lt;br /&gt;
       return quantity*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    float CalculateAmount(int amt, float price){&lt;br /&gt;
       return amt*price;&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
    global integer A = 0;&lt;br /&gt;
    //increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
    // activated whenever an interrupt is received from the controller&lt;br /&gt;
    task Received()&lt;br /&gt;
    {&lt;br /&gt;
        A = A + 1&lt;br /&gt;
        print RX&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    //prints out only even numbers&lt;br /&gt;
    //is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
    task timeout()&lt;br /&gt;
    {&lt;br /&gt;
       if(A is divisible by 2)&lt;br /&gt;
       {&lt;br /&gt;
           print A&lt;br /&gt;
       }&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
    Output would look like &lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    0&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    2&lt;br /&gt;
    RX&lt;br /&gt;
    RX&lt;br /&gt;
    4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
===Magic Bushbutton===&lt;br /&gt;
====Definition====&lt;br /&gt;
This is a very common anti pattern that shows up on graphical user interfaces programming environments. The user first draws the user interface and then builds up the business logic in the automatically created methods.&lt;br /&gt;
Some of the issues faced in this&lt;br /&gt;
*The code for in those defined functions grow large.&lt;br /&gt;
*Change in the user interface leads to a lot of changes in the functions and becomes difficult to manage.&lt;br /&gt;
*Testing becomes an issue.&lt;br /&gt;
====Example====&lt;br /&gt;
Below is a Bad example of Magic PushButton Anti Pattern.    &lt;br /&gt;
    procedure TForm1.ButtonClick(Sender: TObject);&lt;br /&gt;
    var &lt;br /&gt;
       reg:TRegistry;&lt;br /&gt;
    begin&lt;br /&gt;
       reg:TRegistry.Create;&lt;br /&gt;
    try&lt;br /&gt;
       reg.RootKey:= HKey_Current_User;&lt;br /&gt;
       if reg.OpenKey('\Software\mycompany',true) then&lt;br /&gt;
       begin&lt;br /&gt;
         reg.WriteString('Filename',edit1.text);&lt;br /&gt;
       end;&lt;br /&gt;
      finally&lt;br /&gt;
       reg.Free;&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
&lt;br /&gt;
A good example of the same is given below. This is done by refactoring the business logic. IN the below example this is done by storing the file in an registry in a separate class. &lt;br /&gt;
&lt;br /&gt;
    type&lt;br /&gt;
     TReference = class&lt;br /&gt;
     private  &lt;br /&gt;
       FFilename: string&lt;br /&gt;
       procedure SetFilename(const Value: string)&lt;br /&gt;
     public&lt;br /&gt;
       property Filename:string read FFilename write SetFilename;&lt;br /&gt;
       procedure Load;&lt;br /&gt;
       procedure Save;&lt;br /&gt;
     end&lt;br /&gt;
&lt;br /&gt;
The above code will call Save method from the click handler.&lt;br /&gt;
    procedure TForm1.ButtonClick  (Sender: Object);&lt;br /&gt;
    begin&lt;br /&gt;
       Preference.Save;&lt;br /&gt;
    end;&lt;br /&gt;
    procedure TForm1.EditChange (Sender: TObject);&lt;br /&gt;
    begin&lt;br /&gt;
      Preferences.Filename:= edit1.text;&lt;br /&gt;
    end;&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Create functions and modularize the code as much as possible so that the code could be well maintained and flexible.&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Abstraction_inversion Abstraction Inversion]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Big_ball_of_mud Big Ball Of Mud]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Race_hazard Race Hazard]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Magic_pushbutton Magic Pushbutton]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27025</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27025"/>
		<updated>2009-11-16T04:16:14Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==Conclusion==&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27022</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27022"/>
		<updated>2009-11-16T02:07:37Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                         // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27021</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27021"/>
		<updated>2009-11-16T02:07:09Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                       // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27020</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27020"/>
		<updated>2009-11-16T02:06:38Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of class Person in class Student.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
  // '''Wrong Way'''                                                    // '''Correct Way'''&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27019</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27019"/>
		<updated>2009-11-16T02:03:28Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27018</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27018"/>
		<updated>2009-11-16T02:01:09Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* References */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anti-pattern Anti-pattern]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Anemic_Domain_Model Anemic Domain Model]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/BaseBean BaseBean]&lt;br /&gt;
&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27017</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27017"/>
		<updated>2009-11-16T01:58:46Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* See also */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Design_pattern_(computer_science) Design Patterns]&lt;br /&gt;
* [http://en.wikipedia.org/wiki/Code_smell Code Smell]&lt;br /&gt;
&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27016</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27016"/>
		<updated>2009-11-16T01:56:53Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] AntiPatterns: Refactoring Software, Architectures, and Projects in Crisis by William J.Brown and Raphael C.Malveau&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27015</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27015"/>
		<updated>2009-11-16T01:52:38Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/ &amp;lt;br&amp;gt;&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern &amp;lt;br&amp;gt;&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html &amp;lt;br&amp;gt;&lt;br /&gt;
[4] http://beust.com/weblog/archives/000252.html&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27014</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27014"/>
		<updated>2009-11-16T01:52:09Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] http://www.antipatterns.com/&lt;br /&gt;
[2] http://c2.com/cgi/wiki?AntiPattern&lt;br /&gt;
[3] http://www.martinfowler.com/bliki/CallSuper.html&lt;br /&gt;
[4] http://beust.com/weblog/archives/000252.html&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27013</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27013"/>
		<updated>2009-11-16T01:51:11Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* External Links */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;br /&gt;
&lt;br /&gt;
[1] [http://www.antipatterns.com/]&lt;br /&gt;
[2] [http://c2.com/cgi/wiki?AntiPattern]&lt;br /&gt;
[3] [http://www.martinfowler.com/bliki/CallSuper.html]&lt;br /&gt;
[4] [http://beust.com/weblog/archives/000252.html]&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27012</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27012"/>
		<updated>2009-11-16T01:45:52Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the [http://en.wikipedia.org/wiki/Business_logic business logic] from the [http://en.wikipedia.org/wiki/Domain_model Domain Model] is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's [http://en.wikipedia.org/wiki/Entity_Bean Entity beans] and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour [http://en.wikipedia.org/wiki/Encapsulation encapsulation].It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. [http://en.wikipedia.org/wiki/Inheritance Inheritance] can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no reuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass [http://en.wikipedia.org/wiki/Method_overriding overrides] a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27011</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27011"/>
		<updated>2009-11-16T01:38:31Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the business logic from the Domain Model is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's Entity beans and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour encapsulation.It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. Inheritance can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no resuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass overrides a parent's method and calls the parent's overridden method from the same method. This is considered as a bad practise because, in the future if the parent class's implementation changes it breaks the subclass too. And also it puts an additional responsiblity on the subclass's developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandle{                                             public class EventHandle{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      cleanUp(e);                                                            cleanUp(e);&lt;br /&gt;
    }                                                                        doHandle(e);  //hook method&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandle{                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandle{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27010</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=27010"/>
		<updated>2009-11-16T01:34:30Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Abstraction Inversion===&lt;br /&gt;
====Definition====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
====Example====&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
====Solution====&lt;br /&gt;
*Choose the infrastructure carefully.&lt;br /&gt;
*If the system offers w=equivalent functions, use them.&lt;br /&gt;
*Do not inject any weak constructs into the system.&lt;br /&gt;
&lt;br /&gt;
===Big ball of mud===&lt;br /&gt;
====Definition====&lt;br /&gt;
This term was coined by Brain Foote and Joseph Yoder's paper in 1999. This kind of anti pattern arises over a period of time where a number of programmers have worked on a system on various pieces of code. Dur to the lack of knowledge of the current systems the programmers write code which may have already been present and results in a lot of redundant code. Information being shared across the system which may result in it being globally declared and eventually making the code unreadable and unmanageable.&lt;br /&gt;
====Example====&lt;br /&gt;
float CalculateTotal(int quantity, float price){&lt;br /&gt;
   return quantity*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
float CalculateAmount(int amt, float price){&lt;br /&gt;
   return amt*price;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
The above code shows two functions that perform the same function but was created which results in code redundancy and unreadable.&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
*Good understanding of the system prior to any major code changes.&lt;br /&gt;
*Modularizing the code and defining the functionality at the proper location can help reduce the code redundancy.&lt;br /&gt;
*Technical shifts(client-server to web based, file based to database based etc) can provide good reasons to create the system from scratch.  &lt;br /&gt;
&lt;br /&gt;
===Race Hazard===&lt;br /&gt;
====Definition====&lt;br /&gt;
A race hazard or a race condition is a flaw in the system where the output of the system depends on the order in which the system executes. This leads to inconsistency in the output. This term was coined with the idea of two signals racing each other to influence each other.&lt;br /&gt;
&lt;br /&gt;
====Example====&lt;br /&gt;
global integer A = 0;&lt;br /&gt;
//increments the value of A and prints &amp;quot;RX&amp;quot;&lt;br /&gt;
// activated whenever an interrupt is received from the controller&lt;br /&gt;
task Received()&lt;br /&gt;
{&lt;br /&gt;
    A = A + 1&lt;br /&gt;
    print RX&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
//prints out only even numbers&lt;br /&gt;
//is activated whenever an  interrupt is received from the serial controller&lt;br /&gt;
task timeout()&lt;br /&gt;
{&lt;br /&gt;
   if(A is divisible by 2)&lt;br /&gt;
   {&lt;br /&gt;
       print A&lt;br /&gt;
   }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
Output would look like &lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
0&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
2&lt;br /&gt;
RX&lt;br /&gt;
RX&lt;br /&gt;
4&lt;br /&gt;
&lt;br /&gt;
====Solution====&lt;br /&gt;
Mutexes can be used to address this problem in concurrent programming.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Object-oriented design anti-patterns==&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the business logic from the Domain Model is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's Entity beans and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour encapsulation.It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. Inheritance can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no resuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
* CallSuper &lt;br /&gt;
CallSuper is a antipattern in which subclass overrides a parent's method and call's the parents overridden method from the same method. This is considered as a bad practise because in the future if the parent class's implementation changes it breaks the subclass too. And also it puts the additional responsiblity on the subclass developer to call Super.The correct way to go about this is the parent class declaring a separate hook method for subclass to override.&lt;br /&gt;
&lt;br /&gt;
  public class EventHandler{                                             public class EventHandler{&lt;br /&gt;
    public void handle (BankingEvent e) {                                  public void handle (BankingEvent e) {&lt;br /&gt;
      housekeeping(e);                                                       housekeeping(e);&lt;br /&gt;
    }                                                                        doHandle(e);&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
  public class TransferEventHandler extends EventHandler{                  protected void doHandle(BankingEvent e) {&lt;br /&gt;
    public void handle(BankingEvent e) {                                   }&lt;br /&gt;
      super.handle(e);                                                     public class TransferEventHandler extends EventHandler{&lt;br /&gt;
      initiateTransfer(e);                                                   protected void doHandle(BankingEvent e) {&lt;br /&gt;
    }                                                                           initiateTransfer(e);&lt;br /&gt;
                                                                             }&lt;br /&gt;
  }                                                                        }&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26743</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26743"/>
		<updated>2009-11-13T03:14:09Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Software design Anti- Pattern===&lt;br /&gt;
====Abstraction Inversion====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
===Object-oriented design anti-patterns===&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the business logic from the Domain Model is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's Entity beans and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour encapsulation.It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible. Inheritance can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no resuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26742</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26742"/>
		<updated>2009-11-13T03:12:55Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
Anti-patterns is a type of design which when used may result in the code being unproductive and ineffective. It commonly describes a commonly occurring solution to a problem that may have negative consequences. There are many reasons as to why the anti pattern was used, &lt;br /&gt;
*Lack of knowledge by the programmer who coded the system&lt;br /&gt;
*Inexperience on the part of the programmer&lt;br /&gt;
*Lack of proper understanding of the functionality the system needed to provide.&lt;br /&gt;
Anti-Patterns highlight the most common problems that face the software industry and provide the tools to enable you to recognize these problems and to determine their underlying causes.[http://en.wikipedia.org/wiki/Anti-pattern]&lt;br /&gt;
&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Software design Anti- Pattern===&lt;br /&gt;
====Abstraction Inversion====&lt;br /&gt;
Abstarction Inversion means implementing a lower level construct on top of high level constructs. A simple example would be suppose we have 2 constructs A and B. Let B be implemented on top of A but A is not exposed anywhere in the system and if we really require A then we end up building A on top of B and B was already implemented in terms of A.&lt;br /&gt;
A short Example of Abstraction Inversion is given below&lt;br /&gt;
&lt;br /&gt;
The below code implements a set of binary values in a String which decide if it is true or false. (e.g. 'T' or 'F'). They then use the indexer to find the bit.&lt;br /&gt;
    char[] bitString ...;&lt;br /&gt;
    if (bitString[i] == 'T') { // do stuff&lt;br /&gt;
&lt;br /&gt;
So in this case we have a character representing a bit value, but a character is nothing but a sequence of bits. Therefore we have a sequence made up of characters containing bits which are made up of a bit sequence.&lt;br /&gt;
&lt;br /&gt;
===Object-oriented design anti-patterns===&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the business logic from the Domain Model is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's Entity beans and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour encapsulation.It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
* BaseBean&lt;br /&gt;
In the practise of BaseBean, subclasses are derived from an utility class, even though delegation is possible.Inheritance can be evil sometimes, either breaking some subclass due to change in parent class or very deep hierarchy of classes leading to confusion and no resuse of code. For example, if we want to create a student class and we already have person class, inheritance is not the right way to go. We can use delegation and create instance of Person class in Student class and utilize all the features of person class in Student class.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26735</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26735"/>
		<updated>2009-11-13T00:43:42Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Object-oriented design anti-patterns===&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the business logic from the Domain Model is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's Entity beans and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segregation of data and service, its in violation of OOP principle of data and behaviour encapsulation.It could run into problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to manually check for account type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
	<entry>
		<id>https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26734</id>
		<title>CSC/ECE 517 Fall 2009/wiki3 1 kp</title>
		<link rel="alternate" type="text/html" href="https://wiki.expertiza.ncsu.edu/index.php?title=CSC/ECE_517_Fall_2009/wiki3_1_kp&amp;diff=26734"/>
		<updated>2009-11-13T00:42:20Z</updated>

		<summary type="html">&lt;p&gt;Wikimaster: /* Object-oriented design anti-patterns */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Anti-patterns= &lt;br /&gt;
&lt;br /&gt;
==Overview==&lt;br /&gt;
==Known classifications==&lt;br /&gt;
&lt;br /&gt;
==Software design anti-patterns==&lt;br /&gt;
===Object-oriented design anti-patterns===&lt;br /&gt;
&lt;br /&gt;
* Anaemic Domain Model&lt;br /&gt;
Separating the business logic from the Domain Model is termed as Anaemic Domain Model.One of the prime reason for it being  popular is, it provides separation of logic and data. To site few places this is used are Java's Entity beans and .Net's three layered service application. A short example for Anaemic Model is given below,&lt;br /&gt;
  class BankAccnt {&lt;br /&gt;
    private double balance;&lt;br /&gt;
    public void setBalance(double balance) {&lt;br /&gt;
    this.balance = balance;&lt;br /&gt;
  }  &lt;br /&gt;
  class AccntService {&lt;br /&gt;
    public void debit(Account account, double amount) {&lt;br /&gt;
    account.setBalance(account.getBalance() - amount);&lt;br /&gt;
   }&lt;br /&gt;
  } &lt;br /&gt;
&lt;br /&gt;
Although, the above code looks right by providing segration of data and service, its in violation of OOP principle of data and behaviour encapsulation.It could lead to problems when there are muliple type of accounts and some of them have overdraft protection, then debit method has to check for accoount type.This can be corrected by moving the behaviour (debit method) into BankAccnt Class.&lt;br /&gt;
&lt;br /&gt;
==See also==&lt;br /&gt;
==References==&lt;br /&gt;
==External Links==&lt;/div&gt;</summary>
		<author><name>Wikimaster</name></author>
	</entry>
</feed>