design-patterns

DB: To use identity column or not?

While designing a table my colleague here says that I should avoid identity column as it is specific to SQL Server and MS Access, But I differ with his views as it makes my coding simpler. Should I use identity column or not? If not what is best way to create the identity columns from application code? ...

Flexible Decorator Pattern?

I was looking for a pattern to model something I'm thinking of doing in a personal project and I was wondering if a modified version of the decorator patter would work. Basicly I'm thinking of creating a game where the characters attributes are modified by what items they have equiped. The way that the decorator stacks it's modification...

Aren't there any better ways of displaying an object other than using hierarchy?

I have a class hierarchy as such: +-- VirtualNode | INode --+ +-- SiteNode | | +-- AbstractNode --+ | +-- SiteSubNode And a corresponding NodeCollection class that is build on INode. In order to display a NodeCollect...

Test Data Builder pattern: more useful or more upkeep?

Let me start by saying I'm a huge fan of the elegance of this pattern -- I have a group of basic entities that I have implemented builders for (specifically for testing). However I have found (and this may be the caveat) that as my program evolved I kept having to go back and re-work the builders. In the end, it really hasn't seemed wo...

Coupling is too high - how to design this class better?

Running FxCop on my code, I get this warning: Microsoft.Maintainability : 'FooBar.ctor is coupled with 99 different types from 9 different namespaces. Rewrite or refactor the method to decrease its class coupling, or consider moving the method to one of the other types it is tightly coupled with. A class coupling above ...

Cross-component Communication within a View (MVC)

What are some best practices to orchestrate the interaction between complex components that are in your View? I'm not talking about simple widgets like a combo box or a grid control but components that are made up of multiple widgets and that may deserve being unit tested on their own. Would you: Define abstract interfaces for each c...

Polymorphism vs Inheritance (example problem case)

I am still trying to wrap my head around design patterns and for the second time I'm coming up against the same problem that seems to be crying out for a pattern solution. I have an accounts system with multiple account types. We have restaurant, hotel, service_provider, and consumer account types. Im sure there will be more business a...

What is the best way to implement a petition? (email send after signing the petition)

I need to build a little webapp but I'm not sure what is the best thing to do. A person that subscribe the petition is signing an email sent to X. This will be also saved to a db in order to show online who subscribed. The idea is to have a standard text message, the user submit his name and that name goes into the message as signature...

Application design for processing data prior to database

I have a large collection of data in an excel file (and csv files). The data needs to be placed into a database (mysql). However, before it goes into the database it needs to be processed..for example if columns 1 is less than column 3 add 4 to column 2. There are quite a few rules that must be followed before the information is persiste...

what is the difference between using the visitor design pattern or using an interface ?

What is the difference between applying the visitor design pattern to your code , and code like the following : interface Dointerface { public void perform(Object o); } public class T { private Dointerface d; private String s; public String getS() { return s; } public T(String s) { t...

Is it overkill to put MySQL select statements in a class and CRUD statements in a child class?

I have 2 classes for accessing the database: MovieDAO - access database using "select" statements only; the purpose is for retrieving data for displaying in the web browser. and MovieExtendedDAO (extends MovieDAO) - which is more complete and allows for creating/updating/deleting a movie in addition to the inherited functionality. Th...

Design question: How can I access an IPC mechanism transparently?

I want to do this (no particular language): print(foo.objects.bookdb.books[12].title); or this: book = foo.objects.bookdb.book.new(); book.title = 'RPC for Dummies'; book.save(); Where foo actually is a service connected to my program via some IPC, and to access its methods and objects, some layer actually sends and receives messag...

How to use Data Access Objects for serialized & relational database data access

Hi all, I am developing a C++ domain model class library which should provide some facilities or a framework (i.e. interface classes etc) for writing/reading class instance data to/from both a binary file and a RDBMS. The basis for this library is an application that uses a RDBMS, and there are several methods which instantiate a class ...

What are best fit patterns to use when developing VSX Package or Isolated Shell Package?

When I am developing a bunch of designers/tools, what are some of the best fit patterns that go with a VSX Package and/or VSX Isolated Shell Package? Any samples, links would be great. ...

Are There Any Other Programming Riddles?

Are there any other sources of programming type riddles on the internet? I started my set of daily programming riddles, jokes, and quotes partly to help myself and my team grown in some technical areas... like new .NET 3.5 features, design patterns, anti-patterns, code smells, etc. I would love to find other short programming riddles o...

[C# / MEF] Making imports available around your code.

In my MEF usage, I have a bunch of imports that I want to make available in many other parts of my code. Something like: [Export (typeof (IBarProvider))] class MyBarFactory : IBarPovider { [Import] public IFoo1Service IFoo1Service { get; set; } [Import] public IFoo2Service IFoo2Service { get; set; } [Import] public IFoo3Service ...

Using an ObservableCollection<T> with Background Threads

It seems like Microsoft had a great idea with the ObservableCollection. They are great for binding, and are super fast on the UI. However, requiring a context switch to the Dispatcher Thread every time you want to tweak it seems like a bit much. Does anyone know the best practices for using them? Is it simply to populate an ICollecti...

Are there design patterns on modelling a structure containing Teams, Roles and Skills?

I need to model a system where by there will be a team who will consist of users who perform roles in the team and have skills assigned to them. i.e. a team A 5 members, one performs the team leader role, all perform the reply to email role, but some have an extra skill to answer the phone I'm trying to determine how I can best model t...

Creating the Singleton design pattern in PHP5

How would one create a Singleton class using PHP5 classes? ...

Why does C# not provide the C++ style 'friend' keyword?

The C++ friend keyword allows a class A to designate class B as it's friend. This allows Class B to access the private/protected members of class A. I've never read anything as to why this was left out of C# (and VB.NET). Most answers to this earlier StackOverflow question seem to be saying it is a useful part of C++ and there are go...