CSC/ECE 517 Fall 2010/ch7 7g ms: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
No edit summary
 
 
(40 intermediate revisions by 2 users not shown)
Line 3: Line 3:
=Analysis Paralysis Anti-pattern=
=Analysis Paralysis Anti-pattern=


In software engineering, an anti-pattern (or antipattern) is a pattern that may be commonly used but is ineffective and/or counterproductive in practice.
In software engineering, an anti-pattern is a pattern that may be commonly used but is ineffective and/or counterproductive in practice[[1]].  Specifically, the Analysis Paralysis is an anti-pattern because it is something done, but something that should be avoided.  Typically, users of the Analysis Paralysis pattern do not realize it at first, if ever.  This is because typical problem solving does require some analysis.  However, Analysis Paralysis is the over analyzation of a problem, to the point where no movement is ever made on solving the problem.  Analysis paralysis is one of the classic anti-patterns in object oriented software development. In analysis paralysis, we over analyze (or over think) a situation until no decision is ever made, which effectively paralyzes the current process' outcome. [[#References|[5]]]


In analysis paralysis, we over analyze (or over think) a situation until no decision is ever made, which effectively paralyzes the current process' outcome.


===Class Diagram===
[[Image:AnalParal.gif|frame|right|FSM Showing Analysis Paralysis.  The Healthy Problem Solving FSM assumes you do eventually make progress. ]]
[[Image:IC73826.gif|500px|center]]


This diagram is a Universal Modeling Languages (UML) diagram of how a Singleton class would look if implemented in Java.
=Causes=
===Sequence Diagram===
In software development, analysis paralysis typically manifests itself through exceedingly long phases of project planning, requirements gathering, program design and data modeling, with little or no extra value created by those steps. When extended over too long a timeframe, such processes tend to emphasize the organizational (i.e., bureaucratic) aspect of the software project, while detracting from its functional (value-creating) portion.
[[Image:CR2.gif|500px|center]]
This diagram illustrates how the Singleton class creates an instance of the Singleton object. The client classes then create instances of the Singleton class which handles access to the Singleton object.


=Implementation=
Further things to minimize in the workplace in order to defeat analysis paralysis include[[#References|[3]]]:
When this pattern is implemented then it must only have one instantiation of a class and that class must satisfy the global access principles.  The pattern requires a mechanism to access the singleton class without instantiating another class object and a mechanism to persist the value of class members among class objects.  [[#References|[1]]]
*Pride
*Narrow Mindedness
*The lure of infinite composability and decomposability
*Insistence on completing all analysis before beginning design.
*Regular change of leads and their philosophies (each trashing and restarting the work of the previous)
*Too many learning curves at once (underqualified analyst) causing incessant revisiting of prior work
*Lack of goals
*Increasingly conflicting goals (often political)
*Creative speculation, when discovery and definition are required.
*BigProjectSyndrome: this one will do it all, will use the latest tools, will use a new paradigm, will use all new developers, will start with a clean slate, will handle all use cases of two or more existing systems in the first release, etc.
*Risk avoidance, fear of making a mistake.


==Creating the instance==
=Effects=
===Early Instantiation===
One of the most harmful effects of Analysis Paralysis is extended time to marketIn the case of new products, this gives competitors more time to develop products that may be better than yours, and may even be released before yours. In the case of existing products, this can cause customers to become dissatisfied because they are not receiving updates regularly.  By setting deadlines, one can hope to achieve shorter time to market.[[#References|[4]]]
The instance can be created with a static constructor in static languages(See the java example below) This means that the single instance is created on program start up and all new methods are private and never used except by the singleton class itself.


In static languages, this is accomplished by setting the constructors to private and controlling creation of instance of the object from within the object itself.
=Overcoming Analysis Paralysis=
One simple measure to overcome Analysis Paralysis is to create small goals, and then execute them.  Often times people fall into Analysis Paralysis because it seems necessary to have every minute detail planned from the start.  However, this is rarely the case.  Having a general view of long term plans is all that is necessary.  Then, one should take a small piece of that plan and flush it out in full detail, and begin to act on it.  By only taking small pieces to act on at once, one will never run into a case of being overwhelmed and thus avoid Analysis Paralysis.


In dynamic languages, this is done by changing the access level of the constructor to prevent use outside the class just as in the static patterns.
Dr. Edwards Deming popularized a process called the PDCA Model. PDCA stands for: Plan, Do, Check, ActSuch a process emphasizes the necessity to keep producing output, and not just planning to produce output.
===Late Instantiation===
The instance of the class can be created after class loading. (See the C++ example) This can be done by only allocating the instance on the first access of the instance variable.


==Accessing the instance==
=References=
 
[[#References|[1]]] Wikipedia. (2010, November) Wikipedia - Anti-Pattern. [Online]. http://en.wikipedia.org/wiki/Anti-pattern
In static languages, such as Java, the Singleton class will have a method which returns the instance of the Singleton class so that the other classes can use the functionality encapsulated in the Singleton class.
 
In dynamic languages, such as Ruby, if a class needs to access the functionality within the Singleton class then it simply needs to access the instance variable @instance and all the functionality therein.
 
=Examples=
==Java==
 
Java's API includes a Singleton class which implements the static version of the Singleton pattern.  Java's implementation of the Singleton pattern only allows the programmer to create one instance of the Singleton class.  The Singleton class automatically creates INSTANCE when it is initialized.  The getInstance() method returns the single instance of the class that has been initialized.  Java also utilizes a constructor to initialize the Singleton class. 
<pre>
    private static final Singleton INSTANCE = new Singleton();
 
    // Private constructor prevents instantiation from other classes
    private Singleton() {
    }
 
    public static Singleton getInstance() {
        return INSTANCE;
    }
</pre>
[[#References|[1]]]
 
==Ruby==
 
Ruby implements the Singleton pattern by privatizing the "new" method and creates an instance variable called @instance.  This implementation guarantees that the class will not be able create more than one instantiation of itself and that the system will have the global access privileges since the @instance variable has a global scope. [[#References|[6]]]
 
<pre>
class genericFactory
  include Singleton
end
</pre>
[[#References|[1]]]
 
<pre>
class Logger
  def initialize
    @log = File.open("log.txt", "a")
  end
 
  @@instance = Logger.new
 
  def self.instance
    return @@instance
  end
 
  def log(msg)
    @log.puts(msg)
  end
 
  private_class_method :new
end
 
Logger.instance.log('message 1')
 
</pre>
[[#References|[6]]]
 
==C++==
<pre>
// Declaration
class Singleton {
public:
    static Singleton* Instance();
protected:
    Singleton();
private:
    static Singleton* _instance;
}
 
// Implementation
Singleton* Singleton::_instance = 0;
 
Singleton* Singleton::Instance() {
    if (_instance == 0) {
        _instance = new Singleton;
    }
    return _instance;
}
</pre>
[[#References|[3]]]


=Benefits=
[[#References|[2]]] Analysis Paralysis. (2010, November) Analysis Paralysis. [Online]. http://c2.com/cgi/wiki?AnalysisParalysis
 
*This pattern allows the programmer to control the instances of a particular object, it ensures that all objects use the same instance of a class.[[#References|[3]]]
 
*The Singleton class has the ability to control the instantiation process since it implements the instantiation functionality.[[#References|[3]]]
 
=Drawbacks=
 
*Unit tests are much harder to write when using the Singleton pattern.[[#References|[3]]]
 
*This pattern reduces the potential for parallelism within a program since the threads must be serialized.[[#References|[3]]]
 
*The overhead of checking whether there is an instance of a class that already exists every time an objects requests a reference.  Although the overhead is minuscule, this could be a serious problem for systems which don't have the resources to waste.  [[#References|[3]]]
 
*There may be some development confusion with implementing the singleton class (especially one defined in a class library) because developers may forget that they cannot use the "new" keyword to instantiate the object.[[#References|[3]]]
 
*The singleton design pattern doesn't address the issue of deleting the single object.  Some languages implement memory management which means that the Singleton class can only be unallocated by itself since it holds a private reference to the instance of itself. In languages that don't provide memory management, then the single instance can be deleted but it will cause a dangling reference to that object.[[#References|[3]]]
 
=References=


[[#References|[1]]] Wikipedia. (2010, October) Wikipedia - Singleton_Pattern. [Online]. http://en.wikipedia.org/wiki/Singleton_pattern#Traditional_simple_way
[[#References|[3]]] Analysis Paralysis. (2010, November) Programming Management Anti-Patterns. [Online]. http://sourcemaking.com/antipatterns/analysis-paralysis


[[#References|[2]]] Freeman, Eric, Elisabeth Freeman, Kathy Sierra, and Bert Bates. (October 2004) Head First design patterns. [Print.]
[[#References|[4]]] Marelisa. (2010, November) How to Defeat Analysis Paralysis – The PDCA Model. [Online]. http://abundance-blog.marelisa-online.com/2010/06/26/defeat-analysis-paralysis/


[[#References|[3]]] C# Corner (2010, October) Creational Patterns - Singleton. [Online]. http://www.c-sharpcorner.com/UploadFile/susanabraham/CreationalPatterns06042005050058AM/CreationalPatterns.aspx
[[#References|[5]]] Analysis paralysis. (2010, December) http://en.wikipedia.org/wiki/Analysis_paralysis


[[#References|[4]]] Source Making (2010, October) Singleton Design Pattern. [Online]. http://sourcemaking.com/design_patterns/singleton
=See also=
* Anti Pattern http://pg-server.csc.ncsu.edu/mediawiki/index.php/CSC/ECE_517_Fall_2009/wiki3_1_ab


[[#References|[5]]] JavaBeginner.com (2010, October) Java Singleton Design Pattern. [Online]. http://www.javabeginner.com/learn-java/java-singleton-design-pattern
=External Links=


[[#References|[6]]] Dalibor Nasevic (2010, October) Ruby Singleton Pattern Again. [Online]. http://dalibornasevic.com/posts/9-ruby-singleton-pattern-again
* Is Analysis Paralysis Stopping You From Taking Action? http://www.healthmoneysuccess.com/602/analysis-paralysis-stopping-you-from-taking-action/
* How to Deal With Analysis Paralysis http://www.ehow.com/how_2065802_deal-analysis-paralysis.html

Latest revision as of 04:13, 2 December 2010

Analysis Paralysis Anti-Pattern

Analysis Paralysis Anti-pattern

In software engineering, an anti-pattern is a pattern that may be commonly used but is ineffective and/or counterproductive in practice1. Specifically, the Analysis Paralysis is an anti-pattern because it is something done, but something that should be avoided. Typically, users of the Analysis Paralysis pattern do not realize it at first, if ever. This is because typical problem solving does require some analysis. However, Analysis Paralysis is the over analyzation of a problem, to the point where no movement is ever made on solving the problem. Analysis paralysis is one of the classic anti-patterns in object oriented software development. In analysis paralysis, we over analyze (or over think) a situation until no decision is ever made, which effectively paralyzes the current process' outcome. [5]


FSM Showing Analysis Paralysis. The Healthy Problem Solving FSM assumes you do eventually make progress.

Causes

In software development, analysis paralysis typically manifests itself through exceedingly long phases of project planning, requirements gathering, program design and data modeling, with little or no extra value created by those steps. When extended over too long a timeframe, such processes tend to emphasize the organizational (i.e., bureaucratic) aspect of the software project, while detracting from its functional (value-creating) portion.

Further things to minimize in the workplace in order to defeat analysis paralysis include[3]:

  • Pride
  • Narrow Mindedness
  • The lure of infinite composability and decomposability
  • Insistence on completing all analysis before beginning design.
  • Regular change of leads and their philosophies (each trashing and restarting the work of the previous)
  • Too many learning curves at once (underqualified analyst) causing incessant revisiting of prior work
  • Lack of goals
  • Increasingly conflicting goals (often political)
  • Creative speculation, when discovery and definition are required.
  • BigProjectSyndrome: this one will do it all, will use the latest tools, will use a new paradigm, will use all new developers, will start with a clean slate, will handle all use cases of two or more existing systems in the first release, etc.
  • Risk avoidance, fear of making a mistake.

Effects

One of the most harmful effects of Analysis Paralysis is extended time to market. In the case of new products, this gives competitors more time to develop products that may be better than yours, and may even be released before yours. In the case of existing products, this can cause customers to become dissatisfied because they are not receiving updates regularly. By setting deadlines, one can hope to achieve shorter time to market.[4]

Overcoming Analysis Paralysis

One simple measure to overcome Analysis Paralysis is to create small goals, and then execute them. Often times people fall into Analysis Paralysis because it seems necessary to have every minute detail planned from the start. However, this is rarely the case. Having a general view of long term plans is all that is necessary. Then, one should take a small piece of that plan and flush it out in full detail, and begin to act on it. By only taking small pieces to act on at once, one will never run into a case of being overwhelmed and thus avoid Analysis Paralysis.

Dr. Edwards Deming popularized a process called the PDCA Model. PDCA stands for: Plan, Do, Check, Act. Such a process emphasizes the necessity to keep producing output, and not just planning to produce output.

References

[1] Wikipedia. (2010, November) Wikipedia - Anti-Pattern. [Online]. http://en.wikipedia.org/wiki/Anti-pattern

[2] Analysis Paralysis. (2010, November) Analysis Paralysis. [Online]. http://c2.com/cgi/wiki?AnalysisParalysis

[3] Analysis Paralysis. (2010, November) Programming Management Anti-Patterns. [Online]. http://sourcemaking.com/antipatterns/analysis-paralysis

[4] Marelisa. (2010, November) How to Defeat Analysis Paralysis – The PDCA Model. [Online]. http://abundance-blog.marelisa-online.com/2010/06/26/defeat-analysis-paralysis/

[5] Analysis paralysis. (2010, December) http://en.wikipedia.org/wiki/Analysis_paralysis

See also

External Links