Tagged Questions
7
votes
3answers
395 views
Is this correct factory method pattern?
I know that there are many similar questions, but I don't understand most of those questions because I'm not sure if I know what a factory method pattern is.
So, after reading many examples over the ...
5
votes
2answers
120 views
When an object has different representations… what's the OO pattern?
I've an AbstractMessage object (a hierarchy, actually). It represents a small text message and can be sent using different transport methods: HTTP, REST and a "mailer" transport. Each transport relies ...
5
votes
3answers
1k views
Review on design pattern
I wrote a framework and I want to hear the thoughts of other on the design patterns it uses. Every method contains three design patterns - adapters(strategy), intercepting filters, and observers.
A ...
5
votes
2answers
438 views
DI Container: You're doing it wrong?
I'm working on a framework (partly out of frustration with Zend, and partially as a learning exercise to improve my coding). I've constructed a fairly solid library of classes for data validation, ...
4
votes
2answers
263 views
Validation Class - Feedback Welcome!
I have written a Validation and Form class in PHP.
Validation class allow you to define the rules of each field and a error message.
Form class allow you to get a error message and also allow you ...
4
votes
3answers
568 views
Simple PHP Auth Class feedback
this is a basic PHP auth class I've put together for use with simple sites I do from time to time which don't warrant using a framework. I'm wondering if i'm separating out responsibilities all that ...
4
votes
1answer
260 views
Entity collection best practice (separation of concerns, dependency injection, …)
I build a collection to ensure only valid entities in an array so I don't have to validate after every function / method call as I could rely on the collection to have only valid entities stored.
...
3
votes
3answers
797 views
Simple DI container
I'm building a web application and is trying to make my code reusable. I've decided to create components that can be used outside this project.
Now I'm trying to create a simple DI container, one ...
3
votes
4answers
137 views
Refactoring a class hierarchy to remove subclasses
I have the following class inheritances hierarchy:
First the abstract parent class:
<?php
abstract class SegmentParserAbstract{
/** @var ParserResult */
protected $_result;
protected ...
3
votes
1answer
276 views
How to convert my classes to Dependency injection?
I am still learning to develop my skills in OOP.
It uses a combination of the factory and its real singletons?
As I did more research, I have realized this design pattern is bad because of global ...
3
votes
1answer
176 views
Optimize PHP Class
I'm looking for a better way to provide configuration options and improvements in general. I'm using the constructor injection pattern to get access to the Cache and Twitter class. $callback and ...
3
votes
1answer
160 views
Tips for Making this Code Testable
So I'm writing an abstraction layer that wraps a telephony RESTful service for sending text messages and making phone calls. I should build this in such a way that the low-level provider, in this case ...
3
votes
1answer
73 views
Is the way I use my pattern good enough?
For quite a long, I have been using a pattern to make my life a bit easier. please help me evaluate how good or bad my approach is and how can I improve it.
I have a static class for just returning ...
2
votes
3answers
352 views
Is This Is Strategy Pattern
I'm using this pattern for the first time, and using php
I just wanted to check if this is the correct implementation.
class.validator.strategy.php
abstract class ValidatorStrategy
{
abstract ...
2
votes
3answers
609 views
A simple php Session class, is the layout/design correct?
Basically I'm writing a simple framework in php in order to learn more. This session class is extremely rudimentary. At this point I'm not even checking ip/user_agent to prevent session hijacking, ...