понедельник, 3 августа 2015 г.

Classes, factories and interfaces

Original in Russian: http://programmingmindstream.blogspot.ru/2015/07/blog-post_62.html


Provided basis for Shooting the breeze. AddRef and Release (in Russian).

Let us have classes CA, CB and CC that implement the interface I and have one superclass.

At a certain point we understand that the objects should be cached.

So, we add factories FA, FB and FC that create and cache objects.

It works fine.

But!

What can we see?

We do not need interface I. We derive abstract class CI from it and inherit it from P.

Classes CA, CB and CC are inherited from CI.

Abstract methods are implemented and common functionality is extracted.

As a result, we dispose of AddRef/Release and indirect costs related and does not affect the logic.

Комментариев нет:

Отправить комментарий