design-patterns

List<Customer> all or nothing.

I am creating a webservice using Windows Communication Foundation (WCF) and I currently don't know what the best way to do validation with it is. I have two methods: CreateCustomer(Customer) and CreateCustomers(List<Customer>). If a client passes in a list of customers, and some of the customers are invalid, should I reject the enti...

Is Inversion of Control specific to OO languages?

Another way to ask this question is: what is Inversion of Control according to you? I ask this question because the Wikipedia article on IoC has been hijacked by a non-OO explanation. This is taken from the discussion page and is from 2007: I took the liberty to completely rewrite the page, as the previous content was completely tak...

Why should I isolate my domain entities from my presentation layer?

One part of domain-driven design that there doesn't seem to be a lot of detail on, is how and why you should isolate your domain model from your interface. I'm trying to convince my colleagues that this is a good practice, but I don't seem to be making much headway... They use domain entities where ever they please in the presentation a...

Model-View-Controller: when should changes to the view be determined by the controller?

Model-View-Controller seems to allow two types of changes to the view: Whenever the model changes, the view receives a change notification so it can update its visual representation accordingly. The controller is given direct access to the view's API for the purposes of "View Selection". What exactly is "View Selection", and under wh...

Is dependency injection just another name for the strategy pattern?

Are these terms equal or are there any important differences between dependency injection and the strategy pattern? Too me it seems like Martin Fowler just renamed the strategy pattern with a catchier name, am I missing something? ...

Pattern Question

Just starting to learn patterns. Here's a simple question I have. I have an object Report that contains Pages, each of which contains various ReportElements (Table, Paragraph, Image) and so on. Suppose I want to create an infrastructure for taking a Report and spitting various representations of this Report such as an RTF-formatted docu...

How to improve my architecture design skills

What are some good ways I can improve my system architecture design skills? I'm particularly interested in designs I can learn from... can anyone shoot out some examples of good design practice, lessons learned, things to guide me? ...

MonoState, Singleton, or Derived Forms: Best approach for CRUD app?

I have a fairly large CRUD WinForm app that has numerous objects. Person, Enrollment, Plan, CaseNote etc. There are over 30 forms that make up the app with the UI broken down logically. Member, Enrollments, Plans, CaseNotes, etc. I am trying to figure out how I can create my Person Object after searching on the Search Form and pass ...

Is using one-to-one interfaces with domain entities a good or bad practice? Why?

One thing I see in some DDD enterprise apps that I work on, is the use of interfaces that are identical to the domain entities, with a one-to-one mapping of properties and functions. Indeed a domain object is always used through it's one-to-one interface, and all domain entities have a one-to-one interface in this style. For example: ...

How Asynchronous method invocation pattern in c# works and implemented?

I am moving lots of code loosely based on asynchronous method invocation. How is it typically implemented (preferably in production)? How does it work? How is it used? How is it implemented? ...

Decorator Pattern Using Composition Instead of Inheritance

My previous understanding of the decorator pattern was that you inherit Window with WindowDecorator, then in the overridden methods, do some additional work before calling the Window's implementation of said methods. Similar to the following: public class Window { public virtual void Open() { // Open the window } } pu...

Handling combat effects in game development

I'm trying to nut out a highlevel tech spec for a game I'm tinkering with as a personal project. It's a turn based adventure game that's probably closest to Archon in terms of what I'm trying to do. What I'm having trouble with is conceptualising the best way to develop a combat system that I can implement simply at first, but that wil...

Can you create class properties dynamically in PHP ?

Is there any way to create all class properties dynamically ? For example I would like to be able to generate all class attributes from the constructor and still be able to access them after the class is instantiated like this: $class->property. To be more specific, when I'm dealing with classes that have a large number of attributes I ...

Best practices for developing customized B2B Java software?

I'm working on Java-based server software that needs to be customized for a few, but large customers. A separate instance of the server runs for each customer. Each customer has sufficiently differing requirements such that different business logics is required for each of the implementations. At this time, the different business logic...

Java without singletons

Merely out of interrest: do you think Java would have been a better language if static variables would have been excluded, effectively replacing Singletons with singletons? Definition here. If you think so: could you elaborate on what motivation there might have been for including it in the language? ...

Design patterns for event-driven logic

I'm developing a desktop application which depends on the XML data it receives from a server. There are several files, needed to be downloaded at different time. A number of data structures is populated with parsed data. The correspondence between files and data structures isn't 1-to-1, as a matter of fact may be rather complicated. Ap...

Any suggestions for a crash course on design patterns?

I am going to be giving developers at my company a crash course on design patterns (after coming across some scary code recently). One of the most important things I want to put across is that they save time in both the long and short term (which they really do!) - as developers here are put under quite a bit of time strain. All in all ...

C#, accessing classes from a referenced project

In C#, I am developing several Windows Services which have some standard functionality so I have put all this common functionality into a separate referenced utility project. I have a situation where I need to create instances of business classes which reside in my Windows Service project from the utility project using Activator.CreateI...

Composite Guidance for WPF : MVVM vs MVP.

Hi, I am confused. Maybe you can help me :) I have been following the guidance of CAG and found the MVP pattern very natural to me. Suppose I have a UI-ready Model (for example : implements INotifyPropertyChanged), I use the presenter to bind this Model to a view (presenter knows an interface of the view), keeping my Code-Behind as sma...

Front Controller vs. Façade pattern

Okay, I have done a bit of searching online and found this thread, but it still does not quite clear it up for me. What exactly is the difference between a Front Controller Pattern and a Façade pattern? As I understand it so far: A Façade pattern does not contain any business Logic, but merely centralizes access to multiple objects. A...