Two components offering the same functionality, required by different dependencies

I’m building an application in PHP, using Zend Framework 1 and Doctrine2 as the ORM layer. All is going well. Now, I happened to notice that both ZF1 and Doctrine2 come with, and rely on, their own caching implementation. I’ve evaluated both, and while each has its own pro’s and cons, neither of them stand out as superior to the other for my simple needs. Both libraries also seem to be written against their respective interfaces, not their implementations.

Reasons why I feel this is an issue is that during the bootstrapping of my application, I have to configure two caching drivers – each with its own syntax. A mismatch is easily created this way, and it feels inefficient to set up two connections to the caching backend because of this.

I’m trying to determine what the best way forward is, and would welcome any insights you may be able to offer.

What I’ve thought up so far are four options:

  1. Do nothing, accept that two classes offering caching functionality are present.
  2. Create a Facade class to stick Zend’s interface onto Doctrine’s caching implementation.
  3. Option 2, the other way around – create a Facade to map Doctrine’s interface on a Zend Framework backend.
  4. Use multiple-interface-inheritance to create one interface to rule them all, and pray that there aren’t any overlaps (ie: if both have a “save” method, they’ll need to accept params in the same order due to PHP’s lack of proper polymorphism).

What option is best, or is there a “None of the above” variant that I’m not aware of?

3

Do nothing Accept that separate projects can have redundancy as long as they work in their own spaces (not polluting each other caches). Doctrine knows Zend has caching but they don’t want to be dependent on Zend and vice versa. Not all people want to use Zend and Doctrine.

I’d let Doctrine code use its own stuff and use ZF for everything else. This way I only need to know ZF classes. Doctrine cache should only be used internally by doctrine for database object. ZF has more front end that’s useful outside an ORM, like html page caching front end.

Creating another layer would be ideal but it’ll add another dependency to the project, so not very good for maintenance.

I know that in bootstrap it can look redundant to setup multiple caches. It can get worse if you try to use ZF1, Doctrine and ZF2 simultaneously. But it’s a very small constant time as they only setup variables, not connecting to the back ends yet.

So, from programming, maintenance and operation perspective, I’d just leave them alone.

Reasons why I feel this is an issue is that during the bootstrapping of my application, I have to configure two caching drivers – each with its own syntax. A mismatch is easily created this way, and it feels inefficient to set up two connections to the caching backend because of this.

Why not just tackle the issue from a “make configuration more convenient” standpoint?

In other words, write some new class that accepts your configuration data, and then applies it to both caching drivers. Sure, it isn’t as flexible, but that also means less can go wrong.

Why not creating an abstraction of your interface that can be specialised to each of the frameworks? I would write my own cacheing Controller with methods I need, that would encapsulate both caches. Then I can forget about them and only talk to my Controller. Any problems with that solution?

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật