In this post we will discuss Open Closed Principle of Object Oriented Design in details, and review a real production code from Android Open Source Project in order to understand its importance.
This post is part of a series that describe SOLID principles of Object Oriented Design. If you have difficulties understanding the examples, please read the introduction article.
As formulated by Uncle Bob, Open Closed Principle states:
You should be able to extend a classes behavior, without modifying it.
Let’s try to understand what does this mean.
The first part of this definition talks about the behavior of a class. This behavior is defined by the source code of that class. Extending behavior probably means some kind of a change. Since the behavior is defined by the source code, then change of behavior requires change of code. …
Single Responsibility Principle is the most important and fundamental of all SOLID principles, and, probably, the most important principle of Object Oriented Design in general.
In this article we will discuss Single Responsibility Principle in details, and review a real production code from Android Open Source Project in order to understand its importance.
This post is part of a series that describe SOLID principles of Object Oriented Design. If you have difficulties understanding the examples, please read introduction article.
As formulated by Uncle Bob, Single Responsibility Principle states:
A class should have one, and only one, reason to change.
Note that this short quote not only defines what SRP is, but also what “responsibility” is — according to Uncle Bob, responsibility is “reason to change”. In the rest of this post we will use these synonyms interchangeably. …
SOLID is one of the most important acronyms in the world of Object Oriented Programming.
The importance of SOLID comes from the fact that it is practically impossible to write a “clean” code if you don’t know what distinguishes a “clean” code from a “dirty” one.
Understanding of these five principles allows developers to analyze the code using standard models and terminology, and qualitatively assess code’s “cleanness”.
This post opens a series of posts about SOLID principles of Object Oriented Design.
One of the main goals of this series of posts is to show a real-life examples that demonstrate the importance of SOLID principles. In order to achieve this goal, we will be reviewing a real design found in Android Open Source Project (AOSP). …
In this post we will observe Activity through a prism of Single Responsibility Principle of Object Oriented design, and attempt to understand what is the one single responsibility that is best associated with Activity in Android.
The following statement opens the official “Activities” page by Google:
An Activity is an application component that provides a screen with which users can interact in order to do something, such as dial the phone, take a photo, send an email, or view a map.
After such an introduction, it is only natural that we will be thinking about
Activities in terms of application’s UI. Today, when the topic of modular design became especially popular and many abbreviations (e.g. MVP) were promoted to a rank of “buzz-word”, perception of
Activity as UI element is especially notable. …