Tagged Questions
0
votes
2answers
116 views
Is there a better way to load objects?
I have always kept the code to load an object within the object itself. That way no matter what method is creating the object, it always has access to the method to load the object. However this does ...
-1
votes
0answers
45 views
Basic PHP Factory Pattern code review [closed]
I have an object, KbArticle, that originally in it's constructor, would try to return null if the SQL query that retrieves the data for its required properties came up with 0 rows. A friend told me ...
2
votes
2answers
243 views
Repository pattern implementation that knows nothing about the database table and column names
I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a ...
1
vote
0answers
122 views
MVC content management framework with an admin panel
I've lately been developing my own MVC content management system using PHP and, at least in my mind, am a little stuck with the system design. I believe this would apply to building a content ...
-2
votes
4answers
227 views
What is the name of this design pattern? [closed]
I have been using this "design pattern" (may or may not be an "official" design pattern) for a while and I wanted to know if it had a name (so that I could name my classes after it).
Example in PHP ...
0
votes
1answer
47 views
Restricting object types that can be added to each other using the Composite Pattern
The Situation: I am building a custom PHP application framework. I have implemented a composite pattern so I can build a object tree representing the page to be rendered. Example:
abstract class ...
1
vote
2answers
101 views
Visitor only applicable when using the Composite pattern?
For a long time I've tried to get my head wrapped around the visitor pattern, and somehow this thing keeps being rather fuzzy to me.
I'm currently under the impression it is only useful to apply ...
0
votes
1answer
177 views
Implementing a strategy pattern with dependency injection
Okay, so the goal here is to implement a strategy pattern that can be tested using any sort of automated testing tool.
I've been struggling with this problem conceptually for a few weeks now and I ...
0
votes
1answer
152 views
Is there a Pattern or a Refactoring Method to pull data-loading out of existing Class
I am refactoring legacy codebase. Part of it is a loadProduct() function inside a larger "everything" class. loadProduct() loads data from a database. I want to move this loading-data part out of ...
3
votes
3answers
226 views
OOP what is meant by object-to-object communication
I've been reading in basic concepts of OOP,as i'm trying to make this shift from transactional scripts to more oop manner in php, and i often come across this definition :
An object stores its ...
0
votes
2answers
127 views
Best design pattern for library with data model
I am refactoring an old Codeigniter library to be php framework agnostic. There are these core parts:
the connection object - this will come from the "user"; ie, the framework's connection, or their ...
2
votes
3answers
303 views
Design for creating a menu based on user type
Problem
I am building a PHP application which has a main menu, which in turn contains various "sections" or "subheadings" with various links. There are several user types such as SuperAdmin, Admin, ...
1
vote
1answer
146 views
Web design pattern
I am building a small website, in PHP and I am using MVC design pattern for the UI.
In the future I will need to add mobile support for my website. It will be in the sub domain "m" like everyone.
All ...
5
votes
2answers
197 views
Branch twice for unique condition
Consider an application that displays only Foobars belonging to themselves to normal users, and all Foobars to admins:
-- Normal users:
SELECT * FROM Foobar WHERE user_id=:user_id;
-- Admins:
SELECT ...
0
votes
3answers
167 views
Doesn’t active record violate SRP and OCP?
I have watched the active record classes in our project grow into large, do-it-all classes. When you need anything about a user, for example, you should go to the Person class. While this makes ...
0
votes
1answer
178 views
Practical Use of Depency Injection (IoC) Container
I am creating a MVC-ish framework in PHP. I am trying to implement a DI Container to allow the creation of controller objects (among others).
My MVC framework is pretty typical. Each module (or ...
1
vote
0answers
258 views
Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?
I am doing a research on this and can't find my answer to this question:
Which interface allows you to use a design pattern that is characteristically changed with the instantiation of objects?
...
1
vote
2answers
262 views
What design pattern matches this problem the closest?
I have two objects, one is a User object and the other is a Content object. The User object has properties like 'reads_articles' or 'reads_books'. The Content object has properties like 'is_article' ...
1
vote
2answers
410 views
Design pattern to handle queries using multiple models
I am presented with a dilemma while trying to re-designing the class structure for my PHP/MySQL application to make it more elegant and conform it to the SOLID principle.
The problem goes like this:
...
0
votes
0answers
126 views
Algorithms or patterns for a linked question and answer cost calculator
I've been asked to build an online calculator in PHP (and the Laravel framework). It will take the answers to a series of questions to estimate the cost of a home extension.
For example, a couple of ...
0
votes
0answers
447 views
Syncing client and server CRUD operations using json and php
I'm working on some code to sync the state of models between client (being a javascript application) and server. Often I end up writing redundant code to track the client and server objects so I can ...
0
votes
0answers
152 views
Pattern or solution for using classes with different interface the same way
What I would like to achieve is to use classes (now two, later more) with different interface the same way, so I would like avoid using decisions based on the interface on upper levels for instance, I ...
0
votes
1answer
91 views
Using a Proxy as an ACL
I am building an MVC application in PHP, using Zend Framework.
My model includes Domain Model and Mapper layers. I am trying to keep the domain model in pristine condition and have managed to keep ...
1
vote
3answers
287 views
Better solution then simple factory method when concrete implementations have different attributes
abstract class Animal {
function eat() {..}
function sleep() {..}
function isSmart()
}
class Dog extends Animal {
public $blnCanBark;
function isSmart() {
return $this->blnCanBark;
...
-4
votes
1answer
212 views
What must one know when approaching web development? [duplicate]
I just started working as a novice Web Developer.
I know PHP pretty well, as well as some basic jQuery.
Anyway, my boss told me I should explore and learn about MVC, Memcache, Design Patterns, how ...
0
votes
2answers
306 views
How to implement multi-theme PHP application
I am developing an application which will handle many virtual stores and I would like to have many themes that the user could choose anytime. I would to know what's the main ideia to implement it. I ...
4
votes
3answers
392 views
Is it acceptable for child classes to “break” parent class functionality?
One of the devs that works with me is following the Open/Closed Principle to add functionality to a Model by extending from our framework ORM.
class BaseModel extends ORM {
...
}
All our models ...
5
votes
2answers
1k views
Can REST API be used as business layer?
I am using PHP Codeigniter MVC design pattern
and I had this project with some sort of specific business processes
In my application I will be dealing with 2 existing REST APIs:
Google
Trello
...
0
votes
3answers
468 views
Changing behaviour of abstract class without modifying subclasses
I am facing a problem with changing behaviour of a library (thus cannot or don't want to change its internals because of future updates, etc.).
In this library there is an abstract class which shares ...
1
vote
1answer
326 views
What is a practical level of abstraction in a web application? [closed]
(Originally asked on StackOverflow - http://stackoverflow.com/questions/14896121/what-is-a-practical-level-of-abstraction-in-a-web-application)
I still consider myself a newcomer to OO programming, ...
6
votes
4answers
371 views
Applying DRY to an inheritance hierarchy
I'm working on refactoring a legacy application where I implemented the State pattern successfully as shown in the following diagram:
As you see there is a common behavior between the 3 states, so ...
9
votes
4answers
1k views
In MVC, can/should basic data retrieval from the Model be done in the View?
Given the concept of 'skinny controllers, fat models' and the general acceptance that Views can directly call on Models when requiring data for output, should one consider handling the 'get and ...
3
votes
2answers
849 views
Service layer design
I am developing an MVC website in PHP, and for the first time, I would like to implement a service layer. I have some design considerations I would like to get some advice on. The backend will by no ...
16
votes
3answers
1k views
How to design website workflow?
I have been thinking about this for really long time without reaching an optimum answer.
First of all, I'm a medical doctor who loves programming but never really studied it, except for home learning ...
1
vote
1answer
199 views
Is there a good design pattern for this messaging class?
Is there a good design pattern for this?
I want to create a messaging class.
The class will be passed:
the type of message (eg. signup, signup confirmation, password reminder etc)
the client's id
...
3
votes
2answers
2k views
Using PDO with MVC
I asked this question at stackoverflow and received no response (closed as duplicate with no answer). I'm experimenting with OOP and I have the following basic MVC layout:
class Model {
// do ...
2
votes
4answers
2k views
Should I use the factory design pattern for every class?
I've been writing a website in PHP. As the code becomes more complex, I keep finding problems that can be solved using the factory design pattern. For example: I've a got a class Page which has ...
2
votes
4answers
395 views
Would Using a PHP Framework Be Beneficial in My Context?
I've just started work at a small start-up company who mainly uses PHP to develop their front-end apps. I had no prior PHP experience before joining, and this has led to my apps becoming large pieces ...
2
votes
1answer
252 views
How can I design my classes to include calendar events stored in a database?
I'm developing a web calendar in php (using Symfony2) inspired by iCal for a project of mine.
At this moment, I have two classes: a class "Calendar" and a class "CalendarCell".
Here you are the two ...
4
votes
4answers
1k views
Best Method of function parameter validation
I've been dabbling with the idea of creating my own CMS for the experience and because it would be fun to run my website off my own code base.
One of the decisions I keep coming back to is how best ...
6
votes
2answers
385 views
How to use DI and DI containers
I am building a small PHP mvc framework (yes, yet another one), mostly for learning purposes, and I am trying to do it the right way, so I'd like to use a DI container, but I am not asking which one ...
7
votes
7answers
8k views
Is there any design pattern except MVC for web?
I want to know are there any design patterns for web besides MVC?
I know there are design patterns as: Registry, Observer, Factory, ActiveRecord ,... and MVC a set of other design patterns and folder ...
0
votes
4answers
292 views
Is it better to find issues myself or let the computer figure it out?
I'm about to start the process of migrating a program from one component to another. Most of the core functionality will be the same but I'll need to change database calls, etc. I'm sure there will ...
2
votes
1answer
494 views
A solution for a PHP website without a framework
One of our customers asked us to add some dynamic functionality to an existent website, made of several static HTML pages.
We normally work with an MVC framework (mostly CodeIgniter), but in this ...
0
votes
1answer
170 views
The design of a generic data synchronizer, or, an [object] that does [actions] with the aid of [helpers]
I'd like to create a generic data-source "synchronizer," where data-source "types" may include MySQL databases, Google Spreadsheets documents, CSV files, among others. I've been trying to figure out ...
2
votes
2answers
2k views
Booking system (Handle working hours, Get available time slots) [closed]
I'm currently working on a time booking system for a friends hair salon. The plan is to try to keep it as simple as possible.
The user view (where the owner see the booked appointments) is more or ...
7
votes
4answers
799 views
Design pattern for handling a response
Most of the time when I'm writing some code that handles the response for a certain function call I get the following code structure:
example: This is a function that will handle the authentication ...
4
votes
2answers
236 views
Help needed with class design and structure
This question is mostly about the best way to approach this problem. Any input is appreciated.
The Problem
In my application i need to send some data to a number of different destinations (we will ...
2
votes
2answers
177 views
Extensibility data model pattern
I was wondering how you'd be able to map the following criterias to common design patterns. I use PHP 5.3 and MySQL 5.5 and have my own mvc framework for my company but some parts could be better and ...
1
vote
3answers
527 views
Effective template system [closed]
I'm building a content management system, and need advice on which theming structure should I adopt. A few options (This is not a complete list):
Wordpress style:
the controller decides what ...