Tagged Questions
0
votes
0answers
16 views
Re-factoring restrictions validation functions for proper OOP design in MVC framework
I am aware that code review is for refactoring code from an existing code. Let me first to say that the following code works but inefficiently and its very convoluted, so I would like to apologize if ...
4
votes
2answers
76 views
Would this be considered MVC?
For many days, I've been re-designing my application, applying some custom pattern and making our code looks like a framework. I have something like this for separate the business logic, from views:
...
3
votes
0answers
70 views
Laravel - Repository and Entity patterns
I've spent quite a bit of time studying the repository and entity patterns and this is what I came up with. I would appreciate it if you could post suggestions and critique.
...
5
votes
1answer
39 views
Secure Functions in a Database Class
I am trying to solve as many issues as possible with my Database Class and bind statements as far as possible without actually doing it in the front-end. The goal is to do all of the heaving lifting ...
3
votes
1answer
91 views
MVC architecture in PHP
I have developed a few web applications according to my own coding style similar to MVC architecture. I'm a self learner. But there is no controller class or model class. In my way, I don't split the ...
7
votes
1answer
67 views
Making a FileHandler more OOP friendly using SOLID
I have a class created for the sole purpose is to help handle files.
The class holds a path(folder) that contains a single file at a time. Some extra properties to this class are: age of a file and ...
7
votes
1answer
110 views
Is this a sensible way of using an IoC container?
I have a Factory class for a queuing system I'm playing around with.
Consuming classes only care that they get a particular interface (Job) as a result of calling the factory's load method.
Some ...
1
vote
0answers
64 views
Data lookup table with Redis and API call
This class' function is to change a given array's data into an ID.
The list is set by a configuration file. I have DI the outer array and objects into the class so that if there are any dependencies - ...
5
votes
3answers
1k views
Design pattern for adapter
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 ...
0
votes
2answers
346 views
Simple sign up form
I have tried to build my first MVC sign up form.
Here is the user controller method register:
...
0
votes
1answer
104 views
Is my first MVC architecture set up to standards?
I just started learning about the MVC architecture. And I started to create my own MVC framework to how I like it the most.
Here I've got the index.php, indexcontroller.php and view.php. I'm not too ...
6
votes
2answers
178 views
Pattern to avoid Variable Functions?
I have some PHP code where I use Variable functions to call the right function. I need to build a chart array (for example), and the chart array that comes out has a fixed format. But the data that ...
3
votes
1answer
73 views
Redunancy Issues in PHP Class
I've been studying PHP for a while now and decided to dive into OOP. Most of my code was a mess and I've begun to refactor much of the website to OOP; however, I'm having an issue with redundancy in ...
5
votes
2answers
128 views
PHP framework building: Sessions Managment Class
I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
8
votes
3answers
518 views
Are these endless if statements a bad pattern?
I'm only asking because almost the entire code base I've inherited here, in C# and PHP, looks like this:
...
3
votes
2answers
130 views
Simple design pattern for authorization in PHP [closed]
What do you think about the following class? Do you think it is a good approach to solve the authorization problem? I'm looking for a very simple design pattern.
...
10
votes
3answers
257 views
Listener/Observer Model in PHP
I've taken a look at the SPL Listener/Observer model but found that it doesn't work when using static methods. So I wrote my own but it's very simply. Can anyone suggest ways to make it more like the ...
2
votes
1answer
89 views
“Property Container” design-pattern
I've tried to write my Property Container design-pattern implementation.
Could anybody, please, tell me, if this code is really what I intended to write (follows ...
3
votes
3answers
468 views
Email text validator
I'm using this pattern for the first time and wanted to check if this is the correct implementation.
class.validator.strategy.php
...
0
votes
0answers
33 views
Classes to iterate over millions of records, performing calculations and comparisons on each
I'm converting a PHP written with a lot of procedural loops to classes. There is a hierarchy of nested information represented in nested associative arrays. The actual records are from currency ...
2
votes
1answer
58 views
How to deal with some of the dependencies?
I am very beginning in PHP and Design Patterns. I have been studying the beautiful book "Head first: Design pattern" and I have been working in some of the codes originally presented in Java in order ...
1
vote
1answer
51 views
Is this a model? What is controlling it (controller?) and how does the data get to the view?
My goal is to instantiate a class based on the request and call a method on it based on the request verb. The classes I'm referring to will have methods such as ...
2
votes
1answer
663 views
Repository pattern with plain old PHP object
I've been reading a lot about repository patterns these days. At first, the pattern seemed easy.
Most of the examples I read over the web use an ORM like below.
...
3
votes
0answers
92 views
Is this a good PHP strategy pattern?
I am a very beginning in PHP and Design Patterns. I have been studying the amazing Head First Design patterns. So, I have been trying to translate the original to PHP. The class is working well. ...
4
votes
1answer
126 views
PHP magic function for accessors and mutators
I have implemented the following PHP magic method behavior to save my time of creating accessor and mutators for properties of any class that extends this base class.
I am looking for suggesiongs on ...
0
votes
1answer
364 views
Understanding Dependency Injection and Inversion of Control
I have recently been looking into the concepts/patterns behind dependency injection, inversion of control, and registries/service locators. I have searched about the internet on the subjects and have ...
3
votes
1answer
232 views
framework design review (SOLID)
I'm developing a php framework for educational purposes, I have learned a big deal about design patterns and MVC.
I've been thinking a lot on how to have a nice design and so far I've come up with ...
1
vote
1answer
146 views
PHP design pattern factory input for products and quotes
I'm working on figuring out the best way to design this so that it's well organized and it seems like the factory design pattern makes sense.
Updated:
What I'm building:
- Pricing calculator
- ...
2
votes
1answer
614 views
Builder pattern for Codeigniter ActiveRecord queries
I am using Codeigniter and it's ActiveRecord.
I had this idea for a base class that provided a generic getter/setter for doing simple queries on a database. I have a lot of database objects that ...
4
votes
4answers
318 views
Creating an array that loops out on the frontend - Don't Repeat Yourself?
Entire Code Here
Don't repeat yourself
I know of the "Don't repeat yourself". Still it's getting messy in some places. The code below contains three blocks of code.
They are similar in some ways ...
1
vote
0answers
182 views
Basic structure of a simple php REST api
I've read plenty about php OOP design principles and patterns. I can work with classes and inheritance. My issue is with actually using classes for some purpose. In this case, I want to create a ...
2
votes
1answer
1k views
PHP framework building: Database Control Classes
I am building a PHP framework and would like to get some feedback on a few different sections of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
1
vote
1answer
373 views
PHP framework building: Template parsing
I am building a PHP framework and would like to get some feedback on a few different section of the project so far. I consider myself still a neophyte in PHP so I would like to ask if I'm going about ...
2
votes
1answer
381 views
How to create a simple stateless cache class in PHP
i need to create a cache class to avoid making the same calculations more than needed. My idea was something really basic like
...
7
votes
3answers
487 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 ...
1
vote
2answers
611 views
How to implement Publish-subscribe pattern in PHP?
I have two classes, Database and Logger. Database is responsible for handling SQL queries, and Logger logs messages to an external file. Whenever the database executes an SQL query, I want Logger to ...
3
votes
1answer
224 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. ...
1
vote
1answer
265 views
Builder & decorator patterns together, am I doing this right? [closed]
Little background: payload is the representation of a message being send, using a specific transport. The builder pattern is used to build different representation (as ...
1
vote
1answer
73 views
Thoughts on the testability of my use case interactor?
So here is a class that executes the CreateAPerson use case. It takes a request object (which is a simple data structure), validates the request, creates a new ...
2
votes
1answer
164 views
Set of classes for generating social plugins, is my design correct?
I've created a set of classes thatwork together to create the html needed to display social plugins like Facebook like, google plus and twitter.
At firsti defined an abstract class ...
3
votes
3answers
212 views
Refactoring a class hierarchy to remove subclasses
I have the following class inheritances hierarchy:
First the abstract parent class:
...
5
votes
2answers
155 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 ...
4
votes
2answers
749 views
Validation Class - Feedback Welcome!
I have written a Validation and Form class in PHP.
Validation class allow you to define the ...
4
votes
1answer
188 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 ...
2
votes
2answers
488 views
Correct GenericDAO implementation?
I implemented a MVC Framework with Generic DAO and I would like know if is correct. I did not have developed yet the MySQLDAO.
My controller class
...
1
vote
1answer
808 views
What is the correct way to set up my classes in OOP programming in PHP?
Let me start with a little introduction. I am in the process of learning OOP in PHP. I have also researched Design Patterns but have not yet fully grasped the different types of concepts. I am at the ...
1
vote
1answer
79 views
contract validation and responsibility without exceptions in the constructor
my question is based on this "principles"
do not throw exceptions in a constructor
single responsibility / seperation of conerns
use logic exceptions for broken contracts and runtime exceptions for ...
1
vote
1answer
234 views
Does this code follow loose coupling pattern or should be refactored/re-designed?
I've to adming i don't like this design.
The main class (SMSHelper) is responsible of query a REST web service which in turn returns an XML string. This helper is ...
1
vote
3answers
188 views
Fail-safe remote API operations - best practices
I'm working with two remote APIs, one which manages customers, the other (a Paypal API interface) which manages billing. To delete an account, I must delete the records from both.
...
5
votes
2answers
538 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, ...