I'm working on a fairly large PHP project written in a procedural style (it was written before PHP 5), and I can't help but feel that some of the things I'm doing are a little "hackish." A modification somewhere else can easily break the application. All the design patterns and best practices I've seen seem to only apply to OOP. I cou...
I'm new to Objective-c. For learning purposes I'm trying to build something like a phonebook. So I'll have a class called Person that will have some properties (name, phone, etc).
Right now I'm not preoccupied about persistence. But, I need something to "hold" Person objects. So I thought about create a class called People, but I don't ...
Am I doing something wrong, or is this seriously what the developers expect me to write every time I want to check if two fields are the same?
def clean(self):
data = self.cleaned_data
if "password1" in data and "password2" in data:
if data["password1"] != data["password2"]:
self._errors["password2"] = self.e...
I am generating a sequence of Step objects that differ by "Type" and data contained within. e.g:
The Step objects should basically be structs that look like this
{ GRAB, CASCADE_ONE, FACEUP, SOMEOTHERDATA },
{ DROP, DECK, FACEDOWN, MOREDATA, ANDSOMEMORE },
{ MOVE, 34, 89 },
where GRAB, MOVE and DROP indicate StepType:
typedef enum
...
I need to create an email-notification service (as a part of a bigger project).
It will be used to send several types of notification messages which are based on html-templates.
I can design it in two ways:
The first way is based on the builder pattern. It's universal (as I think) and can handle all necessary cases. But it's not ve...
Myself and my team is taking over a DNN web application done by a software development vendor.
There are some issues like
1. redundant non-standard data / API to access to tab and configuration of a module, and
2. some other architecture related issues.
My goal is to remove things we don't need and steer the application back to DNN be...
As we all know most apps have a data access layer, often using repository classes. Typically we want the repository to operate with strongly typed objects, e.g.
interface IUserRespository
{
User GetUserByID(int id);
void AddUser(User u);
... and so on
}
However, sometimes we want to make a more complex query on a DB, ...
I'm trying to find a tidy solution to a questionnaire problem. Let us say that I have a Questionnaire class which has a collection of Answers, e.g.
public class Questionnaire
{
public virtual ISet<Answer> Answers {get;set;}
}
Answers need to be of different types depending on the question, e.g. date of birth, marks out of ten, why...
I have a question relating to the best use of a design pattern. Its probably my understanding of the patterns thats confusing things but i cant decide which pattern is best suited to the following problem.
I have a client system who will be interacting with a seperate subsystem. The subsystem is quite complicated and so i need an inte...
I'd like to use the Composite pattern for forwarding calls received by one object to others.
At present, objects on the receiving end are all of the same Abstract type but the snag is that they selectively accept different types of objet as parameters according to their concrete type (think different models).
As far as I can see, ther...
If you have one Contact, with a 1:* relationship with Addresses, and possibly one or more other tables used to hold the persisted value objects -- how many repositories should there be?
Should there be just one ContactRepository with one public method (GetContact(), that internally calls a private method (GetAddresses)) that returns a...
Hi,
I'm sure most people who use the entity framework sometimes need an entity only for some business operations without it actually ever getting persisted to the database. For example, an online shop checkout wizard where you want to fill the customer and address info, but only persist it once the customer is at the end of the wizard a...
I have two classes LightA and LightB. I have the source code of LightB but not that of LightA. I extended LightB with LightDimDip. ie LightDimDip:extends LightB. Now I need to apply DimDip feature to lightB also.
Can any one suggest good OOP design.
Once again I remind you people that I cannot modify LightA.
...
Hi All,
I have a an Winform application with 2 forms.
In one form I have a Tab Control with 3 Tabs and navigation buttons to switch between tabs.
On the first tab the user selects a file and on navigating to next tab i want to do some
processing on the file selected in the first tab,and show the result in the 3rd tab.
The other form j...
So, I've always implemented a singleton like so:
class Singleton {
private static $_instance = null;
public static function getInstance() {
if (self::$_instance === null) self::$_instance = new Singleton();
return self::$_instance;
}
private function __construct() { }
}
However, it recently struck me th...
I'm trying to make a bitmap editor app for the iphone which would be similar to Brushes or Layers or a cut-down version of Photoshop. I'd like to be able to support 1000x1000 resolution images with about 4 layers if possible.
I'm trying to design my undo/redo system before I write too much code and I'm having real issues coming up with ...
Hi,
I am stuck with a design problem that I hope you guys can help with. I have a few different classes that have various parameters (more than 20 in each case, and they are mostly different, although some are exactly the same in which case they inherit from a base class). I want to control these parameters through the user of a class c...
I'm currently writing an app that posts some data to a HTML form and parses the resulting HTML response page. Depending on the input my user sends the HTML response can either contain valid payload data or request that the user validate an error in the data they entered.
I'm slightly confused as to how to implement the interface for ...
Hi what would be the best design pattern to use for a data validation scenario where lots of values get passed to a function and all must be checked to be in the correct format and length etc. At the moment im using multiple if statements but it seems very messy.
...
I have an abstract class A and several implementations of it. I expect this to evolve over time, by adding more implementations.
I also have an interface that does something at instances of the above class hierarchy (eg print them).
I want implementations of the interface to provide some special functionality for some of the subclasse...