design-patterns

WCF Data Contract and Reference Entity Data?

Hello, Soliciting feedback/options/comments regarding a "best" pattern to use for reference data in my services. What do I mean by reference data? Let's use Northwind as an example. An Order is related to a Customer in the database. When I implement my Orders Service, in some cases I'll want the reference a "full" Customer from an O...

Example of JavaScript observer pattern

Can anybody send me the good links of the observer pattern in JavaScript? ...

how to change arrow mark from left to right in treeview design asp.net 2.0

how to change arrow mark from left to right in treeview design asp.net 2.0 ...

C++ Singleton design pattern.

Recently I've bumped into realization/implementation of Singleton design pattern for C++. It has looked in the following way (I have adopted it from real life example): // a lot of methods is omitted here class Singleton { public: static Singleton* getInstance( ); ~Singleton( ); private: Singleton( ); s...

MVVM, Animations and Commanding - Best way to kick off animations?

Users love animations. See the iphone for a good example :) Everything a user does in the iphone kicks off an animation. Enter MVVM and Commanding (I'm thinking about Silverlight 2 specifically). A user action triggers an event via Commanding, and we're sitting in the ViewModel thinking about how to trigger a nice animation for the u...

Singleton code excerpt, an interview-question

I had another interview question. I thought this was silly, but maybe there is something I am missing. The question asked which GoF pattern this is (answer: singleton), and, if there are any problems, how I solve them. I don't see any problems. I mentioned this is never freed and I expect that from this pattern. That is all I said. Am I...

UML: Can someone explain the Factory Method diagram for me?

i dont have an idea what the broken arrow from the ConcreteCreator to the ConcreteProduct means. i searched in the internet and i came up with "Dependency". can someone explain the dependency in layman's terms? thanks! image grabbed from http://www.dofactory.com/Patterns/PatternFactory.aspx ...

Using The Repository Pattern, Is It Best To Save Parent and Children Objects Together Or Separately?

Having a parent object Employee with a list of Address child objects: class Employee { List<Address> addresses; } and a Repository method: void Insert(Employee); Should the code within this repository attempt to save the parent Employee as well as the child Address objects, or should separate repositories handle the parent and ...

Is this a good enough system-error-to-user-friendly-error translator?

this is how I translate the thrown errors: catch (NpgsqlException ex) { if (tx != null) tx.Rollback(); if (ex.Message.Contains("foreign key constraint")) throw new Exception("Cannot delete this, this record is already referenced on other record(s)"); else ...

Do you see any (anti) patterns in my design? How to recognize pattern?

Hi, i have a Web App coded in ABAP / BSP. I´m interested to deliver fine code so maybe you can help my recognize some good or bad pattern. Actually i do following. Declare a base class object and instantiate it dynamically based on some parameter with a sub class. The base class has some methods for data fetching () the sub classes use ...

What design pattern?

I have a class A maintaining a list of objects class B. But each object of class B can be referenced in any object of class A. Class B also maintains a list of objects of class A where it is being referenced. The program can and will create (several) objects of both class A and B 'at will' and also delete them. If I use C# I can add and...

Proper Design of a MVC Project

I've been using Kohana for a couple months now, and am still relatively new to the MVC style of organizing your code/presentation/db-layer. Unfortunately, while there is plenty of documentation on how to create a controller, establish a view, and interact with a db via a model, I've not found many resources that deal with clean, and sugg...

Problems implementing the "Observer" pattern

I have met an interesting problem while implementing the Observer pattern with C++ and STL. Consider this classic example: class Observer { public: virtual void notify() = 0; }; class Subject { public: void addObserver( Observer* ); void remObserver( Observer* ); private: void notifyAll(); }; void Subject::notifyAll() { ...

Reference to Design Patterns in ANSI C?

Can you point me to a reference of design patterns in Standard C (C89 or C99)? (Not C#, not C++.) ...

Design Patterns - Strategy Pattern

I am a beginner in Design Patterns. Suppose I am developing a C# application to track the development works performed by various members in development team (i.e. a Project Tracker). I am trying to be inspired by Strategy Pattern. So I am designing my classes and interfaces as follows: interface IEmployee { void Retires(); vo...

Are Singletons really that bad?

It's understandable that many design patterns can in some cases be abused, and like mom always said: "Too much of a good thing isn't always good!" I'm noticing that these days, I'm using Singletons a lot, and I'm worried that I might be abusing the design pattern myself, and running deeper and deeper into a bad-practice kind of habit. ...

Design for converting objects

I'm trying to come up with a good design for converting a set of different objects into a common object. Basically, I receive one (of many slightly different) complex object from system A, and must convert it into a simpler object for system B. The objects I'm converting from all inherit from the same base class, so part of the convers...

Brushing up a knowledge of C++, C#, ASP.NET and Design patterns

I've been a software developer for 10 years and came all the way from a wild world of assembly language programming, then server side of C++ and COM, and for the last 5 years I was comfortably settled in a quiet world of .NET, C# and development of business applications. The problem is - the last couple of years was so comfortable and I...

What factors drive you to use embedded scripting in your applications?

What factors do you weigh in your decision process when you select an embedded scripting, and can issues of configuration and variation be overcome purely with IOC and the Plugin pattern? Many times the Strategy Pattern and Decorator Pattern are good way to tame variation in domain logic. The problem set I am faced with is that calcula...

Observer pattern implemented in C# with delegates?

There is a question already answered which is http://stackoverflow.com/questions/32034/in-c-isnt-the-observer-pattern-already-implemented-using-events It asks if the observer pattern is already implemented in c# using events. While I get the events and observer pattern, isn't the observer pattern really just delegates and events is a f...