design-patterns

How would you classify this type of design for classes?

The following type of design I have seen basically has "thin" classes, excluding any type of behaviour. A secondary class is used to insert/update/delete/get. Is this wrong? Is it anti OOP? User.cs public class User { public string Username { get; set; } public string Password { get; set; } } Users.cs public class Use...

Design Firewall Software

How can I design a Firewall software? The design should have a layered approach. ...

Data Inheritance in C#

Is there a known pattern to inherit data in a hierarchical object structure? I have a hierarchical 'Item' structure which needs to inherit its 'Type' from its 'Parent' (have the same data as default). The type of sub item can be modified by its own, and when the type of parent Item changes, all sub items which their type is not changed, ...

Monostate vs. Singleton

What are the scenarios when one would use a Monostate pattern instead of singleton inorder to maintain a global object? Edit: I know what Singleton and Monostate patterns are. Have also implemented Singleton in quite a few scenarios. Just want to know the scenarios (case examples) where MonoState pattern needs to be implemented. For eg...

What is a wrapper class?

What is a wrapper class? How are such classes useful? ...

Do we need a new GoF book?

Someone asked What is a Wrapper? and it got me thinking - where would I point a new developer in search of some foundational description of useful patterns? The GoF book has long been a foundational part of the canon for OO programming, and all of us at one time or another have benefited from the descriptions of common patterns there. ...

Command Pattern: Client and Invoker

In the command pattern: Why shouldn't the client participant be the same class as the invoker participant? Is there possible scenarios when the client participant and the invoker participant can be the same class? ...

ASP.NET MVC: Authorization inside an Action - Suggested Patterns or this is a smell?

Hello, I have an ASP.NET MVC application using Authorization Attributes on Controllers and Actions. This has been working well but a new wrinkle has shown up. Object: Shipment Roles: Shipping, Accounting, General User The Shipment moves through a workflow. In state A it can be edited by Shipping only. In state B it can be edited b...

Where does the presentation logic go for the View-Model-ViewModel pattern?

In the View-Model-ViewModel, actions are essentially executed by the viewmodel that is bound to the view. However, where would the "presentation logic" go since the code behind isn't used and the viewmodel has no reference or knowledge of the control that invoked it? For example, what if I wanted to animate another control when a button...

How many times have you reused your all-time most reusable component? (Yours)

If you designed a toolkit, an application or a framework, mention the most reusable component you used of them, how portable it is, how many times you reused it, how many programmers worked on it with you, and how much time did it take you to ship it. and also the names of the patterns you applied while developing it. (approximately of ...

Design Pattern for optional functions?

I have a basic class that derived subclasses inherit from, it carries the basic functions that should be the same across all derived classes: class Basic { public: Run() { int input = something->getsomething(); switch(input) { /* Basic functionality */ case 1: doA(); break; case 2: ...

Which design pattern to do this?

I've got a process something like a workflow, assume it like this: Prepare Eat Take your stuff to bin Clean up the table Now what I want to do is even the user cancels the "Eat" event I want them to "Clean up the table" same goes for "Prepare" and "Take your stuff to bin" stages. Currently in my implementation I had to do several c...

XML Serialization is slow

I've inherited a project where the application's data model is an XML document. The developers before me had created an object model based on this xml's schema, and then coded against the object model. After several years of maintenance, this application has gradually started to show its age. The team leader has said that the key reason...

What should come first -- the design pattern or the code?

I'm starting on a fresh new project--should I look at my spec and decide which design patterns to apply, or just come up with a general idea of organization and allow the patterns to emerge organically through refactoring? In your experience, which technique will be most productive and have a greater chance of leading to clean elegant c...

Where can I find large php5 best practises project?

I'm trying to find a project that incorporates the "best practices" that are discussed and debated on a daily basis for almost all languages but I'm trying to focus on php5. Is there a php5 open source project that I can comb through to see working examples of project that exemplifies Units Tests, Dependency Injection and other best pra...

Design: Emailing System in Java

Hi everyone, I'm building an emailing system for a framework I'm developing. Thus far, I've got a generic MailMessage interface that every different type of email message will implement, something along the lines of public interface MailMessage { public String[] getTo(); public void setTo(String[] to); public String getFr...

How to implement Repository Pattern with interface, base and concrete.

I have almost completed implementing my repository pattern by having a IRepository<T> interface, a NewsRepository class and a News entity. The problem I ran into was trying to abstract out common methods to a base Repository class. I could not find a way to abstract the Get method in the NewsRepository as it contains a specific Linq ex...

What rules do you use to delineate MVP methods and members.

When using the MVP pattern, I often come across methods and members which don't seem to fall nicely within the View or Presenter classes...My question is: What rules do you use to decide what functionality lies which classes? I am relatively new to MVP, so please humour me. TIA. ...

"AsyncFuture<T>" or what? Future<T> obtained in a background thread -- is it a pattern?

I'd like to have some work done in a background thread as simple as creating a Future var for it and then asking later for the calculated value. In pseudo-C#-code: AsyncFuture<int> asyncFuture = new AsyncFuture<int>(FuncToCalculateValue); //do some other work, or draw UI if(asyncFuture.NoErrorsHappened){ int realResult = asyncResu...

How to name the following pattern based on messaging and unit of work (XA)?

I'm having a difficulty with naming the pattern used commonly by the application I've been working on for a while. Just to set the scene: this is a JEE application that uses messaging (JMS) a lot, persist data in relational database (JDBC) and relies on global transactions (XA) managed by the application server (JTA). The pattern I'm ta...