Dependency Injection, Services and Containers (DIC) – part 4

 

If you have read my previous posts. Maybe the terms Inversion of Control, Dependency injection, DI Containers and Service Locator means anathema, so this article doesn’t suite you.

If you think the whole DI idea is a hoax, no problem. Enjoy the other millions patterns that the OOP world offers.

For people that understand the matter, I would love to hear everything you need to say about it. As I said in my first post: The PHP community makes that language so fun to deal with. I look forward to increase my knowledge and share my own. The general idea of this blog.

Note to the newbies – I won’t give an exact implementation of a problem you’ve faced – I’m not StackOverflow and I don’t intend to be. Yeah I’ll try to help and explain if you have questions about the subject but again, I am not a guru 😉

Read More »

Dependency Injection, Services and Containers (DIC) – part 3

Aaaand we are on part 3, and you still don’t know what the hell am I talking about. OK. Lets explain a little more, and we’ll continue on the types of injection and Service Locators and DI Containers.

The Dependency Injection is a technique that follows the Inversion of Control. If you wish to follow that click here. So just to make things clearly lets get the Wikipedia definition about IoC:

A design in which custom-written portions of a computer program receive the flow of control from a generic, reusable library.

A software architecture with this design inverts control as compared of traditional procedural programming.

So if it doesn’t sound that clearer, I’ll try to make it crystal:

With inversion of control, the custom code calls a library to perform a task, without caring about the dependencies. And that best practice I was explaining in the previous two parts of this post.

Read More »

Dependency Injection, Services and Containers (DIC) – part 2

 More & more problems

In the previous part we’ve found a solution for one of the problems, and that is the removing of the dependencies and code it with an interface. By itself, this is a good milestone but we’ve never managed the object creation. The complexity of creating the dependencies through the other objects – so in order to instantiate Payment we need to create every class that must be injected and implement the PaymentProcessor, the Invoice and DB.

Read More »

Dependency Injection, Services and Containers (DIC)

So, a little while ago, when I’ve dug in deep into the sea of OOP, a popular new technique surfaced and its called Dependency Injection. Take note here, that I’m not rediscovering the wheel here. Just pointing the obvious and explaining it – My Way!

There are literally thousands of information about that topic, but I’ll try to be brief here, take a little as much I can of your time, and give you all the info, so when you set sail in the vast sea of Information Technologies, you don’t like your support.

Let us begin.

Read More »

PHP Questions about OOP and Software Development principles

In this post, I’ll try to answer questions given by a company for the title “PHP Web Developer”. The questions are all about our field of interest, like SQL and PHP but I’ll try to explain only the PHP with the OOP (Object oriented programming) ones.

Take note here, that these questions has relative brief description, and the idea is to give as much as you can in like 20 or few lines. For everything else, there is Google 😉

Read More »