design-patterns

Specification Pattern vs Spec in BDD

I'm trying to explore Behavior Driven Design and Domain Driven Design. I'm getting that written specifications drive the tests in BDD, but also that business logic can be encapsulated using the specification pattern for re-use in domain objects and repositories, etc. Are these basically the same concept just used in different ways, use...

Creating a singleton in Delphi using the new features of D2009 and D2010

I'm looking to create a singleton in Delphi. I've done this before using older versions of Delphi, and ended up using global variables (in the implementation section) and using initialization and finalization to take care of the instance. Also there was no way of preventing the user from creating an instance as you couldn't hide the stan...

How granular should you make your Observables/Listenables?

You have a pull-oriented Observable/Listenable which notifies Observers/Listeners when some state changes. The state consists of more than one nugget of data, and some of your Observers/Listeners don't care about the whole state. Do you generally prefer to notify all the Observers/Listeners anyway and allow them to ignore notifications...

[C#] Is it possible to "extend" the property "class"?

Hello, I'm new to C# (started last week) so be cool with me ;). I'd like to know if I can somehow write a custom property, let me explain: I have some partial classes that I complete by adding properties, but the pattern of all the getters and setters are the same so I'd like to factorize this: public partial class Travel { publ...

C# Basics Making Properties Atomic

It's been given by Microsoft as a framework design guideline that properties should be independent of one another and not rely upon being set in any specific order. Assume you have a triangle class that needs to support dimmensions and an area calculation. How would you model this? This is of course the design that is considered gauch...

Is there a Design Pattern for implementing a parametric search feature w/o using SQL in Java?

I'm not really sure what the best approach is for designing what I would call a "parametric" search or rule engine. I have a Java object which has several fields. I will run the java object against several queries in order to see if it meets certain criteria. An example i can think of is the bug search feature in bugzilla. In the UI ...

How to decouple model/view for widgets

I am writing an application which is used for drawing widgets/menus/controls etc to create application mockups. Each screen is represented as collection of widgets, and each widget is simple class e.g. class Model(object): def __init__(self): self.widgets = [] class Widget(object): def __init__(self): self.x, se...

MVP vs. Presentation Model, which one is better?

UPDATE MVP vs. Presentation Model, which one is better (for desktop application) - in terms of maintainability testability complexity flexibility separation of concern - changing one component (view, controller, model etc) has minimal impact on the others. performance (optional) memory usage (optional) ...

What is a good design pattern for storing User Last Logon information?

You would think it would be a fairly straight-forward problem, but I'm struggling a bit with designing a feature to store the last logon date / time in an ASP.Net (MVC) application. My first instinct was to simply store the value in the database against the user's profile record and update the value to the current date/time on successfu...

Which design pattern?

Hello! I am looking for a couple of patterns or design ideas for implementation in C++ that would allow the following. 1. pool of similar objects objects requested and relinquished by client pool grows when exhausted, does not shrink there will be multiple clients (one pool per client to avoid mutexing) An Object Pool seems most ap...

Design patterns: what are some new ones, where are the existing ones used?

Optional assignment for one of my classes. 30-45 minute presentation/case study on either of these two topics: Examples of currently existing design patterns in real life projects: what problem they solve, why are they better than other techniques, etc New design patterns, what problems they solve that other design patterns can't, etc ...

One DI Container for multiple ASP.Net applications

Hi All, I am trying to design a Infrastructure libraries for my company. Libraries will have typical components like logging, exception handling, email etc. These componants will be used by all the ASP.Net applications hosted on our environment (so hosting environment is my control). My first step in design is that I would not like the...

How should I design user login functionality

Hello, I'm building Rails application and I want to have user registration/login functionality. I also need to have other fields in the User's model such address(street, city, country), facebook info, twitter info, last login time...etc From a design perspective, is it better to have the User model very light-weight and have just usern...

Designing a better API?

What are the best practices and patterns to be followed for designing APIs? How to achieve implementation hiding the best way (C++/Java)? Designing APIs which are generic in nature? Any reference books/links which guide with neat examples to beginners? ...

Critique my simple MVP Winforms app

I'm trying to wrap my mind around the MVP pattern used in a C#/Winforms app. So I created a simple "notepad" like application to try to work out all the details. My goal is to create something that does the classic windows behaviors of open, save, new as well as reflecting the name of the saved file in the title bar. Also, when there are...

Difference between Bridge pattern and adapter pattern.

What is difference between Bridge and Adapter pattern where i can use which pattern. ...

Opposite factory pattern

I was wondering if there is an opposite pattern of the factory pattern. For example, when a certain object needs to be deleted some extra work needs to be done, to undo the configuration which was performed in the factory object. Extending the factory object with a Delete method for instance seems wrong, since the factory pattern is a s...

Live UI update of model changes when the model contains plain data structures only

Please consult me with your opinions on the following topic: I have a model - a structure of the objects. Such as: Event, containing participants Current task Assignee of each task The model is going to be pickled on the server and transferred over the network to the client GUI application. Because of the pickle I'd want to keep the...

Guice-style service locator

Has anybody ever seen/attempted to write a service locator pattern which uses a Guice style configuration system? Currently I have a GWT project (which happens to use GWT-RPC) that uses a command pattern wherein my RPC servlet that looks like this... public interface TransactionService extends RemoteService { <T extends Response> ...

Designing an OO and Unit Test Friendly Query System

I'm working on an application that allows dentists to capture information about certain clinical activities. While the application is not highly customizable (no custom workflows or forms) it does offer some rudimentary customization capabilities; clients can choose to augment the predefined form fields with their own custom ones. Ther...