design-patterns

On which pattern are ASP.NET webforms and MVC based? PageController, FrontController?

I am trying to understand the ASP.NET WebForms and MVC from the point of view of understanding the design patterns used. While MVC clearly looks like an implementation of FrontController, I am not very sure about WebForms pages. So, I would appreciate if anyone can help with the following questions around this. Is WebForms based on a ...

Data modeling question

My clients use one of the following when they sign up for my application: Foo API (requires a "auth_key", "password", "email") Acme API (requires a "secure_code", "username", "password") Bar API (requires a "xyz_code", "pass_key") (fake names, and about 15 more omitted for simplicity) I would prefer not to have 10-15 tables in my da...

Is there any good guide for gui programming?

Hi I am a web developer, writing complex widgets and managing their flow, sometimes I feel that I need to know some patterns and practices in GUI programming in general. I am aware of observer pattern, command pattern etc. But I want to know something more ... wondering how "facebook" manages their widgets controls. Suppose i will go thr...

How can I pass a runtime method to a custom attribute or viable alternative approach.

Basically I would like to do something like this at the top of my class (I know this doesn't work as it isn't a constant).... [XmlStorage(IsSingleStorageFile = false, IsSubordinate = true, StorageLocation = "posts" + GetBlogId()] Where GetBlogId() would be a static utility method. I'm building an xml storage framework for a blogging ...

Trying to understand the Post/Redirect/Get design pattern (implemented with PHP)

All, Sorry in advance - I'm not a PHP expert or knowledgeable in design patterns, so this question might be a little basic... Anyway, I'm working on a web app that will require a login. My plan is to have something like this: index.php: this page will contain a simple form that allows users to enter a username and password. The form ...

Strategy pattern vs. Command pattern

Both design patterns encapsulate an algorithm and decouples implementation details from the calling class. The only difference I can discern is that the Strategy pattern takes in parameters for execution, while the Command pattern don't. It seems to me that the Command pattern requires all information for execution to be available when...

Interface, Abstract or Inheritance? C# Design Question

Hi, I have a table which houses two entities, StaticProgram and DynamicProgram. There is one column in that table called ProgramType which determines if a program is of type "Static" or "Dynamic". Though these two entities are stored in one table (I am guessing because the primitive fields for Static and Dynamic programs are exactly the...

singleton in abstract class php

Hi all, I have a simple question. I use a singleton which implements an abstract class. Is it possible to put the getInstance() Method and the variable $_instance in the abstract class instead of the concrete one I want to create? Here's my code: <?php class Command_Log extends Command_Abstract { private static $_instance=null; ...

Managing complex ACLs in Zend Framework

Hello, The manual shows how to configure ResourceAutoloader to use Acls directory to store ACLs. Where can I see some usage cases of such a complex ACLs, so these /acls directories in each module would be really useful? How to manage inheritance and separation of Access Control Lists in each module? How many ACLs do you have for an a...

Extend multiple Java classes without duplication

I have a Java class that can extend either of two third-party classes, which I cannot change. I can choose either of these implementations at compile time with no changes to my class other than the "extends" declaration. Unfortunately I need to choose which implementation to use at runtime, not at compile time. What's the best way to ...

switch case in python doesn't work; need another pattern

Hello, I need a help with a code here, i wanted to implement the switch case pattern in python so like some tutorial said , i can use a dictionary for that but here is my problem: # type can be either create or update or .. message = { 'create':msg(some_data), 'update':msg(other_data) # can have more ...

What is the serialization pattern?

I've seen it referenced in a couple places but I've been unable to find a description of the pattern. ...

How to port Java interface codes into C++ abstract base class?

Im new in OOP programming and C++ and Im currently into learning design patterns. Just grab the Head First Design Patterns book to learn from. Its actually great and Im already getting hold into the basic concepts.The first chapter talks about programming to an interface rather an implementation. Unfortunately for me though, the exampl...

how to run Web client software factory i face to face :"Exception Details: System.InvalidOperationException: '/' matched to the path."?

/ WebClientApplication1' Application Server Error. '/' Matched to the path. Description: An unhandled exception occurred in the execution of the current web request. About the error and where it originated in the code review the stack trace for more information. Exception Details: System.InvalidOperationException: '/' matched to the pat...

Observer Pattern or just create event handling?

I want to create a "modules" layout in my web application so I can easily add more modules of the same type, for example: As an example, my WebApp handles subscriptions and email campaigns, and I want to create an interface to allow easily coupling multiple API's, MailChimp, CampaignMonitor, iContact, etc... so I will create an IMailin...

Resource based ACL vs controller based ACL

Hello, The traditional approach to manage access to controller actions is to create resource (string identifier) for each /module/controller/action, then check the ACL in controller plugin. Lately I discovered very handy Zend_Acl_Resource_Interface, which can be used to control access to any class implementing it. This way, any Model, ...

python global object cache

Hello Little question concerning app architecture: I have a python script, running as a daemon. Inside i have many objects, all inheriting from one class (let's name it 'entity') I have also one main object, let it be 'topsys' Entities are identified by pair (id, type (= class, roughly)), and they are connected in many wicked ways. ...

Design pattern "Container Visitor" without virtual methods?

Hi everybody, I am developing the design of an application and I thought I might apply some sort of the Visitor design pattern, but it turned out that it's not exactly what I am looking for. Maybe someone can point me to the variant I require in this case? Much of my code has a template argument "ContainerType" like template <class Co...

Should a model method call 'save' itself?

Let's say that we have a method inside a model that needs to called only on saved records may update the model itself and thus the model needs to be saved again afterwords Should the "save" calls happen inside the method itself like the following code def result save! if new_record? # do some funky stuff here that may also cha...

Need a design pattern to remove enums and switch statement in object creation

Let's say I am creating a sports game, and in this game there are various positions a player can play, attack, defence, etc. So I start by creating a base class: public abstract class Position { public abstract string Name { get; } } and the subclasses... public class Defender : Position { public override string Name { get {...