design-patterns

Building a mutliplayer game site

I am building a site that has a lot in common with a person-on-person chess site. I was thinking of using Rails for the front-end(User Registration, Navigation, etc) and something like Scala or Erlang for the engine(Game state and maybe AI). I was wondering - Is this a good situation to use that type of design? How exactly would be be...

Where to find User Interface (UI) design patterns for Windows applications?

I don't know if this question really suits here, but we'll see :) For web applications there are sites like Pattern Tap and UI-patterns, which have a great collection of design patterns used in UI's. I can't seem to find any websites/books/articles which cover design patterns for Windows Applications. The only useful resource I found ...

NHibernate - Domain Driven Design - Business Rule Question

Hi all, I ve got an employee that holds several addresses in a collection. public class Employee { public string Name { get; set; } public AddressCollection Addresses { get; } } public class AddressCollection : IEnumerable<Address> { private readonly Employee employee; private IList<Address> items = new List<Address>...

Creating an object with a constructor and named members

How would you implement a constructor together with named functions on an object in JavaScript? This is how I'd like to use the object: o("..."); // use the object's constructor o.namedFunction("..."); // use a named member on the object I don't want to have to "new up" object before it's usable... You could say I want the equivalen...

Designing database interaction while following Single Responsibility Principle

I'm trying to adhere to Single Responsibility Principle better, and I'm having issues grasping how to structure the general class design for communicating with a database. In a simplified version, I essentially have a database containing: Manufacturer <== Probes <==> ProbeSettings A probe has a manufacturer. A probe has 1 set of se...

Is using multiple tables an advisable solution to dealing with user defined fields?

I am looking at a problem which would involve users uploading lists of records with various field structures into an application. The 2nd part of this would be to also allow the users to specify fields to capture information. This is a step beyond anything ive done up to this point where i would have designed a static RDMS structure mys...

Is this an anti-pattern?

The situation is this: You have two classes that both implement the same interface and both classes work together to complete some business process. For example networkUserManager and localUserManager implement IUserManager which has a method getUser(). networkUserManager.getUser() puts a request to get a User on the queue and returns...

What is the best way, using the "State" design pattern, to change states?

My current understanding of the State design pattern is basically this: Encapsulate all of the behavior of an object in a particular state in an object. Delegate requests to the "Current" state object. My question is: What is the best way to handle state transitions? In my case, it is likely that "Current" state object will be the one...

Lost access to same property trying to use best practice / design pattern

I had: in a class implementing Validator: an $errormessages property an isCorrect() method In the isCorrect method, I had: switch ($type): case 'email': isEmailCorrect(); case 'password': isPasswordCorrect(); case 'x': isXCorrect(); isEmailCorrect(), isPasswordCorrect() and isXCorrect() had a...

(Hopefully Simple) Question about Unit test seperation

Hi, This question is related to PHPUnit, although it should be a global xUnit design question. I'm writing a Unit test case for a class Image. One of the methods of this class is setBackgroundColor(). There are 4 different behaviors I need to test for this method, Trying to set an invalid background color. Multiple invalid paramete...

How to use "EJBs" and the "Command and Controller Strategy" altogether? (MVC/Servlet/JSP)

Hello there. I'm trying to figure out how to use EJBs inside of a Class which is part of the Command Pattern, and that Command I'm going to use it inside of a Servlet, but inside of the Servlet when I use the Dependency Injection there are no problems, or course, but when I use it inside of a plain class (even running inside of the Servl...

Design pattern and configuration settings

I'm developing an application that transforms xml documents using xslt. The application has a settings dialog for setting values like * input * output (directory) * stylesheet * and so on... The user can also choose to transform to pdf, xhtml, etc, and the settings above differ slightly for each format. Now, I was wondering if anyon...

Getting started with software design using MVC, OO, and Design patterns

NOTE: This question has been updated to provide more detail and insight than the previously. UPDATE: I just want to say thank you to everyone who responded. I'm still pretty much in the dark on what design pattern would work best for the Widget. Perhaps one of the Factory or Builder patterns? I am just getting started on a new proje...

Is there any metaprogramming patterns catalog for Python?

I have just read Python Cookbook. The book is amazing. I think the best use of this book is that it provides lots of examples that show python in real problem applications. Many of the idioms include metaprogramming techniques. I wonder if there is any catalog that summarizes metaprogramming idioms in Python? Python Cookbook is very ...

Practical tasks for students who learn design patterns

I need to compose some tasks (problems) for students who learn design patterns. Please suggest me some practical short-term tasks that would help students understand the theory. I need some interesting ideas for creational design patterns. Thanks! Will be great if you share your experience: when a particular design pattern perfectly f...

What all Design Patterns can I use ?

1. I need to build a "Web Service Server (Simulator)" which generates the xml files and also sends async calls to the client for notification. At this point, I am writing a code to generate dummy XML files which will be used for testing (FileGeneratorClass-- builder)? 2. Also, can I implement this in a way that I do not have to write a...

Help designing my own rough DataContext

Hi All I've done a bit of Linq programming with TDD ASP.Net MVC and loved it. Digressing, I'm now learning webforms against stored procs and cannot use linq. I would like to retain some of the loose coupling and testability enjoyed with MVC. I didn't have the time to learn and setup a dependency injection infrastructure so instead ...

Domain Driven Design - How to use value object on the UI

Hi all, I was wondering how you use your ddd model within a web application. Within Eric Evan Cargo application there's the Cargo class which contains the value object Itinerary. Within Itinerary is a collection of Legs, again a value object. All value objects hide the surrogate id to the outside world. So when using this domain model,...

Django: ForeignKey() or ManyToMany() in this case? Or, other?

I have a model that is something like this: class ReturnAuthorization(models.Model): custom_id = models.CharField(max_length=40) class RMAAPILog(models.Model): return_authorization = models.ForeignKey(ReturnAuthorization) If I were to delete() a return authorization, I can't have it delete all the RMAAPILog()s that are relate...

Agents in minority games: inheritance hierarchy, pluggable behaviour through interfaces or some pattern?

I'm currently building a library to allow a wide variety of different minority games to be simulated. This involves agents choosing between two choices, say, A and B so the primary functionality of an agent is to choose. An agent wins a point for a turn in the game if it ends up in the minority group after all agents have chosen. There ...