Why do we need encapsulation?

If you have been dealing with OOP lately, you may have heard about encapsulation. Its the one of the principle mechanisms of object-oriented design, which restricts access to a class’s properties and allows you to manage a data flow. These are done with the use of access specifies: private, protected and public, which are supported in most programming languages.
Continue reading “Why do we need encapsulation?”

Factory Design Pattern

When we code using OOP paradigm, we might have to deal with creating objects of classes, which implement a common interface or extend the same class. In this situation, it is recommended to use a Factory pattern. What it basically does is, that it takes on the responsibility of creating objects, making this process more generic and consequently, more clear and readable.

Continue reading “Factory Design Pattern”

Customizing routes with urlManager rules in Yii2

By default, a URL in Yii Framework is of the form example.com/index.php?r=controller/action, where ‘r’ represents a route. When the application receives the route, it first analyses it and then creates an instance of a controller action according to the route’s name. If a controller or an action is not found, the application will throw NotFoundException.
Continue reading “Customizing routes with urlManager rules in Yii2”

Why use strict typing mode of PHP7?

All modern programming languages can be divided into two groups according to their data type declaration: dynamic and static. The difference between them is, that the type of data in statically typed languages like Java or C++ can be distinguished at compile time, while the type of variables assigned dynamically may not always be correctly specified.

Continue reading “Why use strict typing mode of PHP7?”