This week, I am writing about the first Antipattern that I’ve learned about, which is called “The Blob.” I learned about this Antipattern from the website “Source Making.” And I like this blog’s explanation of The Blob because it breaks everything about it down into different sections, making it easy to understand.
https://sourcemaking.com/antipatterns/the-blob
The blog begins with some background to make the idea of The Blob Antipattern easier to understand by first describing the movie of the same name, where an alien would grow as it consumed things, which is a good analogy for the Blob AntiPattern because it has been known to consume entire object-oriented architectures.
The blog then goes on to explain that The Blob is found in designs where one class monopolizes the processing, which means that the majority of the responsibilities are allocated to a single class. Because of this, the code is procedural-style rather than object-oriented architectures.
The next section of the blog describes symptoms and consequences of the Blob. Which include: a single class with a large number of attributes, operations, or both. The blog explains that a class with 60 or more attributes and operations usually indicates the presence of the Blob. A disparate collection of unrelated attributes and operations encapsulated in a single class. A single controller class with associated simple, data-object classes. And an absence of object-oriented design. A program main loop inside the Blob class associated with relatively passive data objects, the single controller class nearly encapsulates the application’s entire functionality.
The blog then goes on to explain typical causes of The Blob AntiPattern which include: lack of an object-oriented architecture, lack of architecture enforcement, too limited intervention, and a specified disaster.
A solution for the Blob AntiPattern offered by the blog is a form of refactoring. The key is to move behavior away from the blog and to reallocate behaviors to some of the encapsulated data objects in a way that makes those objects more capable and the Blob less complex.
So from this blog, I learned about my first AntiPattern, The Blob. Like the movie of the same name, a Blob AntiPattern is where one class monopolizes the processing of the other classes in a program. It gives too much responsibility to the single class and leaves not much else for the rest of the classes to do. This is bad practice, and to fix this AntiPattern you should refactor your code by taking away some of the responsibilities from the Blob and delegate it evenly to the other classes to make the program more equal in processing.
From the blog CS@Worcester – Decode My Life by decodemylifeblog and used with permission of the author. All other rights reserved by the author.