design-patterns

Avoiding sub-type selection in view code

Hi, I have some code where the model contains some classes like (vb.net pseudocode, but could be any OO language): Enum AttributeType Boolean Date String End Enum MustInherit Class Attibute Must Override Function Type As AttributeType End Class Class BooleanAttribute: Attribute Function Type As AttributeType ...

general design suggestions for a drawing application

Hi, I need to design a CAD application in C# which should essentially have a separation between the data and its representation. I am thinking of having a datamodel and a graphic model for representing the geometry of this data. This graphic model will be presented to a view control for displaying through a presentation layer. I want ...

How can I place @Action methods in a separate class from a Swing component?

When developing Swing applications, I've typically defined a delegate interface for each UI component for action callbacks. For example, if there is a class, MyDialog, which contains a button, MyButton, then the ActionListener for MyButton will call MyDialog.Delegate.OnMyButtonClick(Event e). The UI component then becomes "dumb" and requ...

Purpose of factory objects/benefit over using same instance to return type

What is the benefit of a static factory class as opposed to using an instance of the same object to return that object? For example, from the N2 CMS, take a look at this code: Newspage news = Factory.Persister.Get(itemID); // Variable for news can set news related properties. Factory.Persister.Save(news); Factory is static and I am ...

Does ASP.Net MVC 2 validation need some more thought in terms of patterns and use?

Hey guys Here is the lay of the land. Like most people I have my domain object and I have my view models. I love the idea of using view models, as it allows for models to be created specifically for a given view context, without needing to alter my business objects. The problem I have is with type level validation defined on my domain...

A design pattern question

Hi, I am designing an application, and I am unable to point out the correct design for the same. I have one in my mind, but it does not seem to be part of the GOF pattern and so I am not sure whether it is a nice way to go. My project creates data from any of the possible 15-20 documents (the documents are all of same type, but the dat...

Design patterns in Assembly language

Basically, are there any? I'm tempted to think they do exist. For example, a template method can be implemented as a series of "jumps", where the target of a jump is specified "externally". Singleton will be just a well-known location in memory/code, etc. I'm by no means an assembly expert, so these examples might turn out to be comp...

Design pattern for file based communication?

Hi all! I have to extend an existing program (Java-based, but this shouldn't count). This program should communicate with another program X. This program X is .. uhm.. a little bit older and supports only file based communication. This means I have to put my file into some specific folder. The "answer" is placed in another folder where...

What is a good name for class which creates factories? (FooFactoryFactory sounds silly imo)

I don't remember exactly is it a common pattern but I have a class (Factory Method pattern) which has method for creating other classes (Abstract Factory pattern) depending on enum parameter: public class FooFactoryFactory { public FooFactory createFactory (FooFactoryType type) { switch (type) { case AFoo: ...

Is there a Dependency Injection-like pattern for wiring together Subjects and Observers?

A Subject-Observer relationship isn't a dependency relationship: Observers don't need Subjects in order to exist, and vice versa. Yet the "wiring together" of publishers and subscribers is strongly reminiscent of Dependency Injection. My shoot-'em-up game makes extensive use of the Observer Pattern. For example: A controller object spa...

Converting WPF / ADO.NET Data Services application to the MVVM pattern - Examples

I have a WPF application which was written in C#. This application hasn't been written with any particular design pattern in mind, but as I have learnt .NET I've realised that the MVVM model would be suitable. Thus, I'd like to start converting the code. This will be the first time I've used MVVM, and whilst I'm willing to get stuck in,...

Which design pattern does this?

I have a small question regarding design patterns I have this 2 classes which extend from the very same class (doctrine_record) so they mainly have the very same methods and functions however, they now have different attributes. I'd like to create a wrapper that exposes the 2 classes summed attributes, I remember there was a pattern fo...

[object design]Plenty of timed events to synchronize. How to ? :-)

Hi folks ! I'm trying to design an application (in C++ but that doesn't matter I guess, anything object-oriented would work the same) which has to synchronize a bunch of events together. Basically, you would have a several data structure instances which would contain lists of events. An event would have a timestamp and be "runable". T...

Please recommend resources to learn design patterns.

There were some questions that got answers with books specifically, but I wonder if there are any other non-book good resources (pages, blogs, online tutorials) to learn design patterns. ...

ORM to abstract a traditional database plus a WCF service.

Suppose one is using Microsoft's Entity Framework as an ORM to abstract/work with a database. Next comes a requirement which causes the application to have the need to work with a WCF service and a traditional database, simultaneously. To my knowledge no ORM tool exists that can abstract a WCF service in the same manner as Entity Frame...

Designing a clean/flexible way for a "character" to cast different spells in a role playing game

I am creating a role playing game for fun and as a learning experience. I am at the point where my character (a wizard) is cast spells. I am using a strategy pattern to set the spell they are going to cast before casting the spell. The reason I went with this approach is because I want to be able to add different spell types later on w/ ...

ASP.NET MVC with Pipes & Filters Pattern. Benefits ?

Hi everyone, I'm just about to start a new project on ASP.NET MVC using LINQ to SQL for ORM. So, I have read and watched various tutorials about best practices and I wonder: What is the benefit on using the pattern Pipes&Filters in my model (have in mind, I intend to use LINQ to SQL). Why just not use repository pattern in the model for...

How would you model this application?

I've got an MVC application written with Zend Framework that pulls data from an Oracle 10g database and displays this data in Tables and Lists and visually enriches this data through colors and charts. There is no ORM and no Create, Update or Delete involved, just pure Reading. The data is inserted from another application. The data in t...

User Interface functionality modelling languages?

I am looking for a UI functionality modelling language (UML-alike "thing", but for user interfaces) that is already accepted and maybe has its design patterns and handles the problem better than state or activity diagram. (If there is no such thing I'm planning to develop that BTW :)) This question came to mind as a result of a discove...

Refactoring abstract class in C#

Sorry if this sounds simple, but I'm looking for some help to improve my code :) So I currently have the following implementation (which I also wrote): public interface IOptimizer { void Optimize(); string OptimizerName { get; } } public abstract AbstractOptimizer : IOptimizer { public void Optimize() { // Gene...