design-patterns

What is the best Ruby pattern to use in this Rails situation?

The interaction of the site is based on the input of user. For example, if the user selected "VISA" as payment method, he will be redirected to another controller/actions asking for credit card number. If the user selected "Paypal", then he/she will be redirected to an external website. Instead of putting all logic in the action itself...

Is there a Java equivalent or methodology for the typedef keyword in C++?

Coming from a C and C++ background, I found judicious use of typedef to be incredibly helpful. Do you know of a way to achieve similar functionality in Java, whether that be a Java mechanism, pattern, or some other effective way you have used? Thanks, -bn ...

Alternative design pattern to Observer for .Net

I was initially going to implement an observer pattern in C# 3.0 to solve my problem although it wouldn't be implement exactly in the same way. My problem is that I have a web application with users who can post messages. Notifications do not go directly to other users but to a distributed cache where a statistics objects are updated an...

Recursive Class Design Patterns: Options and Best Practices

Dear all: In advance, thank you for your time. Lately, I have decided to learn Objective-C (I am a long time C-hacker) and after reading the beautiful text by Kochan and diving into the Apple documentation I am still confused as to the best way to implement a recursive class (ie. a class in which an ivar has the type of the same class)...

Same interface in different domains/project

I got this issue: Product class in a SQLBackend that implements IProduct interface. I also got a Product in SAPBackend (ERP, accounting software) that implements the same IProduct. Both backend is in a different project. I want to be able to use pass a Product between this two project so I need the same common interface. I was thin...

Sample WPF apps for line of business apps?

I am learning WPF and wanted to look at source code to some good full fledged WPF apps which are used for business apps, data binding using data bound controls like grids and good use of WPF design and patterns. Not interested in WPF apps which show off WPF's graphics capabilities. Yes I am into your typical boring business apps. Also l...

Is a switch statement applicable in a factory method? c#

I want to return an Interface and inside a switch statement I would like to set it. Is this a bad design? private IResultEntity GetEntity(char? someType) { IResultEntity entity = null; switch (someType) { case 'L': //life entity = new LifeEntity(); break; ...

Suitable Design Pattern for a Simple Chat Application.

Hi. I am designing a simple chat application (just for the kick of it). I have been wondering of a simple design for that chat application. To give you overview.. here are the rules: Anonymous user enter chat just with a nickname. (User id) is presumably assigned by system in background. They can join in (subscribe to) a chat conversa...

Useful software design patterns in .NET

Can you share your most frequently applied (or favorite) software design patterns in .NET development? And why? Please bear with me by asking such a generic question. I am not trying solve any problem specifically. Simply want to know what patterns are used more frequently to help solving problems we face daily. Thanks for sharing your...

How can I avoid/refactor bad singletons in practice?

After careful reading the facts about singletons (the code smell, not the pattern) I wonder: How can I refactor my code to get rid of them? Despite almost everyone agreeing that bad singletons are, well, bad, I could not found any practical advice on how to replace them. Either it's very trivial or very hard. There are some ways I c...

Should mvc web applications be 3 tier?

I will designing a couple of web applications shortly. They will probably be done in asp.net mvc. In my existing web apps, done in delphi, the data access layer is seperated out into a completely separate application, sometimes running on a different server. This is done more for code reuse than for architectuaral reasons. This won't...

How do I control the fetch depth of an eager loading datamapper?

I have a datamapper class that will eager load any property that does not have a Lazy attribute attached to it. I have two entities, State and Country, Country has an inverse relationship to state in that it contains a list of all the states of that country and State has a forward relationship to Country in that it has a property Countr...

Is there any free program for making diagrams of file dependencies extracted from header files?

Looking for something similar to Modelmaker that was for Delphi. Showing dependecies of modules. Any help is appreciated. Doxygen has been great so far. If someone know if it's possible to achieve what I want with Doxygen, then please let me know :) ...

Constructor specialization in python

Class hierarchies and constructors are related. Parameters from a child class need to be passed to their parent. So, in Python, we end up with something like this: class Parent(object): def __init__(self, a, b, c, ka=None, kb=None, kc=None): # do something with a, b, c, ka, kb, kc class Child(Parent): def __init__(sel...

Anyone have examples of the Blackboard Pattern?

Does anyone have any examples of the Blackboard concept from p.165 of 'The Pragmatic Programmer'? I want to have several small sub-systems (DLLs and EXEs) mostly independent of each other. There are some assemblies that will be used by all EXEs. These assemblies will nearly all use the same database. Rather than using interfaces for ...

Extending an object and any child collections?

Hi, I have an class named Foo. This class contains a collection of child objects of type FooChildBase, but I also have a further class of type FooChildTwo which inherits from FooChildBase. Class Foo Public Children As IList(Of FooChildBase) End Class Class FooChildBase Public Info As String End Class Class FooChildTwo Inherits ...

How to read code without any struggle

Hello, I am a new to professional development. I mean I have only 5 months of professional development experience. Before that I have studied it by myself or at university. So I was looking over questions and found here a question about code quality. And I got a question related to it myself. How do I increase my code understanding/read...

Suggested design pattern for email templates?

From the "It must have been done 1 million times before" department...I need to integrate a email templating solution into an existing .Net product. Right now, each component (workflow, admin, etc) sends out their own hard-coded emails. I would like to introduce a new admin site/screen that allows users to pick from a set of email temp...

CFML Design Pattern resources?

As with all development, CFML via ColdFusion, Railo or OpenBD we run into common programming problems. For these problems must programmer turn to patterns (or anti-patterns). However the classic resources like GOF and the modern Head First books both tend to focus on Java. While java is beautiful in its own right, all three cfml eng...

Patterns: Render engine allowing editor integration?

I am trying to determine that if (before I start) on a new project I can pick some suitable patterns which will help with development as the project gets more complicated. The Scenario To have an application that draws 'simple' lines on the screen. Ideally encompassed into a 'Render Engine' which I can package into Silverlight, WPF dem...