What is an Anti-Pattern?

In this week blog, I'm going to write about anti-pattern, mainly because I have seen the term a lot and think to myself that I should at least know something about it. This week blog is based on this article.

For a start, we need to understand what algorithm and pattern is. Algorithm has been around for a really long time and considered to be the most fundamental concepts in software engineering. The early concept of algorithm as it is written in "Fundamental Algorithms" by Donald Knuth, which was published in 1968, mainly provides Calculus-based proofs of its solution and code examples in outdated language like Algol or MIX Assembly. However, a lot of the subject was covered is still widely used today, for example like singly / double linked list, garbage collection or trees, etc. and it remains to be valid solutions to common software engineering problems for more than 5 decades and still going strong.

A "pattern" can be seen as a more general form of an algorithm, while algorithm may focusing on a specific programming task, pattern would offer more advantages in areas such as reducing defect rates, allowing an effective teamwork or even increasing the maintainability of the code. Four common patterns that are used in the industry are:

   - Factories: A concept in object-oriented programming that would eliminates the need for the creator of an object to know everything about it ahead of time, in other words, it would generalize the object as a square instead of knowing what details that contains in it. This pattern certainly simplify the program and encourage more efficient teamwork.
 
   - Pub / Sub: It is an async process between sender and receiver. Instead of having the sender to send the messages directly to the receivers, the sender publishes the messages to a queue. This pattern allowed multiple receivers to subscribe and retrieve those messages. The queue also have the ability to handles details such as transmission errors or resending messages. While factories pattern is more code-oriented pattern, pub/sub suggest to be more architectural in nature.

   - Public-key Crytography: A really useful and commonly used for security like in SSH or git server. It is a mechanism that allows two parties to communicate securely without interception without exchanging the secret encryption keys. Usually, each party maintain a pair of keys (public and private), and the public key can be shared anytime as needed.

   - Agile: A philosophy that establishes a set of guiding principle for software development to emphasize the customer satisfaction. It also embrace the need for flexibility and collaboration and promote the simple and sustainable development practices.

If a "pattern" suggest the solution to common software engineering problems, then should "anti-pattern" be the exact opposite? Anti-pattern actually is a term to establishes the concept of failure to do the right thing, maybe some of the choice in the development process seems right, but they would lead to problems in a long term. Wikipedia define anti-pattern as a common response to recurring problem that is usually ineffective and risks being highly counterproductive. As the sentence proposes that this is a common mistakes and they are nearly always followed with good intentions. Just like pattern, anti-pattern can be really broad or specific, depends on what we are considering.

Comments

Popular posts from this blog

Designing the code is more important than you thought

Introduction

Comparing REST and SOAP, which one should you use?