design-patterns

Does this variation of the Strategy Pattern have a name?

I have a standard GOF Strategy Pattern: client code holds a reference to an AbstractStrategy, which points to any one of several ConcreteStrategies deriving from or implementing the AbstractStrategy. One ConcreteStrategy delegates to any of several other ConcreteStrategies, depending on its passed parameters, e.g.: public class Concret...

Are WPF and Silverlight command implementations useless for the M-V-VM (M-V-P) pattern?

Please excuse my ignorance, I only started coding in Silverlight recently. I tried implementing the command pattern in Silverlight and hit a wall. They say commands are great, because you can write them into xaml, so you can keep your code-behind clean, also you have loose coupling between your view and your viewmodel because there is n...

Why am I getting an error in C# when mixing explicit implementation and polymorphism?

I am getting this error: type Bar does not implement interface IFoo From this code: public interface IFoo { void DoA(); void DoB(); } public class Foo:IFoo { void IFoo.DoA() { } void IFoo.DoB() { } } public class Bar:Foo { void IFoo.DoA() { base.doA(); } voi...

Does ColdFusion have an answer to ASP.NET's Master Pages?

I'm working on a website that was coded in ColdFusion. I have a CSS/HTML template I would like to apply to the content of every page, without duplicating any more code than necessary. I've gotten kind of spoiled by ASP.NET's master pages, which would be my preferred way to implement this site. Unfortunately, that option is unavailable to...

MVC + Wich pattern for this 1:n relationship

I have a Server application with a GUI. Written in c#. Now I want to use the MVC pattern for the whole Application. Normally you have 1 Model, 1 Controller and maybe n views. Okay, I have one of everything, but I'm not sure with the Model. My Situation: There are 1 server state, that can be online / offline, that has a client count, et...

MVC in C#: Model - Controller relationship

Normally I have one controller and one model. Is there a disgn-pattern to have 1 View with multiple Controllers and multiple Models. Where very controller can have multiple models, too? Some links to related patterns would be nice. ...

Have you ever derived a programming solution from nature?

When you step back and look at ... the nature of animals, insects, plants and the problems they have organically solved perhaps even the nature and balance of the universe Have you ever been able to solve a problem by deriving an approach from nature? I've heard of Ant Colony Algorithms being able to optimize supply chain amongst o...

Design pattern for this application?

You're writing an application that manages online courses. A course is completed in many different ways. A user must do one or more of the follow to complete the course: spend x amount of hours in the course take a test, and pass the test (a passing score could be different for every course) take all the lessons in a course some other ...

Resources for Learning Design Patterns

Recently I came about this concept of Design Patterns, and felt really enthusiastic about it. Can you guys suggest some resources that help me dive into Design Patterns? ...

Status Code Design Patterns

Say you have a 'post' object in a typical blog scenario. A blog post can have different statuses like 'draft', 'published', 'approved', et cetera. What are the best ways to handle this, specifically regarding storing this data in the database in a meaningful way as well as in a meaningful way in code. Generally I've seen these stored as...

High level design pattern for image editing tools

I have recently begin creating an image editing tool which will cater to a very specific need. This is as much for the people who are going to use it as it is for my own entertainment. however, I have hit a bit of an architectural snag early on. Like any image editor, the user will use 'tools' to draw on and manipulate an image. My...

MVC - where do you put AJAX scripts?

I am using Kohana but this question applies to Rails, CI, or any other MVC web development framework. Where is the best place to stick one's server side AJAX scripts? I was planning on creating an Ajax_Controller and using a method/action per individual script. For example, a login form on the home page index.php/home would send an XM...

static class and singleton

Isn't a class with all static members/methods a kind of singleton design pattern? Is there any disadvantage in particular of having such classes? A detailed explanation would help. ...

Design Issue

I have a Channel with some properties and a ChannelProxy extending Channel. This ChannelProxy holds the original values so that Optimistic Concurrency can be applied. You can switch between no concurrency check and Optimistic Concurrency check. Now I want to implement a LazyLoadedChannel which can be a Channel or a ChannelProxy. Extendi...

Static factory method OR Creation method

I am wondering about correct definition for such construction: class A { public static A create() { return new A(); } private A() { } } In Effective Java (Item 1) and on wikipedia article I found that this is called Static Factory Method (some kind of Factory Method). But during reading of Refactoring to Patterns (Chapter 6)...

Checking a data conforms to a list of rules

Hi, I'm interested in understanding if there is a common technique/pattern for checking data in a database conforms to a set of rules. I'm interested, perhaps, in running a service/job each night that churns through the data and raises exceptions to rules. I would quite like the system to be dynamic, i.e. it's quite easy to define new r...

Model View synchronisation (or avoiding synchronisation)

The overall structure of a given software system is model view controller. The view (graphical interface) is a representation of the model (domain object models). However, within the view (graphical interface) there are components (such as JTextComponent). These components too are arranged in Model View Controller. JTextComponent uses D...

Best programming process for creating a graphically-complex Java Swing Application?

I'm starting a fairly complex Swing application that heavily graphics-oriented with about 1000 separate jpegs, 30+ different forms, and timers keeping track of the rate of user-interactions throughout. My question is from a practical programming perspective, after I've already written a storyboard for the entire project and got it appro...

Yeah.. I know.. I'm a simpleton.. So what's a Singleton?

I've tried a few times to understand what a Singleton is. Perhaps I'm just too visual.. so can anyone break it down in a simple analogy. Similar Posts: http://stackoverflow.com/questions/1637635/different-ways-to-initialize-singletons http://stackoverflow.com/questions/86582/singleton-how-should-it-be-used http://stackoverflow.com/qu...

Egg-chicken problem in OOP way

Hi Guys, I have a chicken-egg problem. I would like too implement a system in PHP in a OOP way, in which two classes would play important roles: Database and Log. My idea was to build up the connection by the Database class, which would have public methods eg. runQuery(sUpdateQuery), doInsert(sInsert), etc. The Log class would writing l...