design-patterns

Keeping everything loosely coupled and extendable: Too many layers, too small ROI?

Hello, I (now more than ever) see developers write huge amounts of layers such as: implementation PresentationLayer -> interface IMyDTO -> implementation MyDTO -> interface IMyService -> implementation MyService -> interface IMyDomainRepository -> i...

What advantage will Composite pattern bring me over just Array?

I'm recently working on a tree structure, multiple nodes, multiple and increasable levels, and a print() method. At first, i thought it should be a Composite, i then wrote down some possible design and codes: $struc = new Node(‘name0’, ‘id0’, ‘desc0’); $node1 = new Node(‘node1’, ‘id1’, ‘desc1’); $node2 = new Node(‘node2’, ‘id2’, ‘desc...

Design Patterns for Microsoft ( or other software producers) Desktop Application

This question is similar to What is the most common design patterns for any windows forms application? UI Design Pattern for Windows Forms (like MVVM for WPF). But I would like to ask something more specific: I want to know what design patterns Microsoft use to built their impressive array of desktop apps suites, including VS 2008...

How to layout the code of a simple game?

I'm coming from a background mostly developing websites, and maybe some simple form-based apps. MVC works well for that, but I don't quite see how that's applicable to a game. So how do you guys do it? I'm developing with Qt and OpenGL, if that's relevant. I have a QGLWidget which I'm basically using as a central hub at the moment. Shou...

ASP.NET MVC - Sharing Session State Between Controllers

I am still mostly unfamiliar with Inversion of Control (although I am learning about it now) so if that is the solution to my question, just let me know and I'll get back to learning about it. I have a pair of controllers which need to a Session variable, naturally nothing too special has happen because of how Session works in the first...

Is Builder pattern replace factory pattern?

I know this question is asked many times but I just want to clear more on this. Can a builder pattern replace factory pattern. Yes Builder pattern create and return a complex object step by step and this can be done in factory pattern also. ...

Design pattern for default implementation with empty methods

Is there a specific design pattern that describes the scenario where a non-abstract default implementation is provided that implements all or some of the methods on the interface with empty, NO-OP implementations. This being done with the intent of alleviating subclasses with the burden of implementing methods that they themselves may no...

Function with variable number of args in C and a design-oriented question

I have a C function named SetParams(...) with a variable number of arguments. This function sets up a static data structure (let us name it Data). SetParams is used with pairs of arguments, e.g. SetParams("paramA", paramA_value, "paramB", paramB_value) etc. It can also be called many times, e.g. SetParams("paramA", paramA_value); SetPar...

C# - Programmer Challenge for Interviews - Programming to an Interface & Patterns

What is a good simple problem to throw at Jr. and Mid level developers to to find out given the opportunity to Program to an Interface (like a simple Factory pattern) if they will do it? ...

Achieving State like pattern without having +3 entities? C#

Here is the design problem in pseudo example: It is ASP.NET User control (UC) which uses the "Food" object as data source and this object has property FoodType - "Veg" || "Nonveg". The user control changes UI display depending upon FoodType property. In code-behind class of User Control, some methods have same if/then/else condition: ...

Nice general way to sort nulls to the bottom, regardless?

I'm writing some custom Comparators, and I'd like them to push null items to the bottom of the list, regardless of whether I'm sorting ascending or descending. What's a good strategy or pattern for approaching this? Offhand: simply write separate ascending and descending comparators, sharing code where possible; delegate null handli...

Is global constants an anti-pattern?

I've always thought having a class just for the sake of holding constants is a bad design. But recently, I've tried googling for it and found only that having an interface as a constants is bad an anti-pattern - no mention of using a class of constants. I'm of the opinion that since a class of constants is really not much different from...

Patterns/Practices for encapsulating predicates

I'm guessing most of us have to deal with this at some point so I thought I'd ask the question. When you have a lot of collections in your BLL and you find that you're writing the same old inline (anonymous) predicates over and over then there's clearly a case for encapsulation there but what's the best way to achieve that? The project...

How is Non-Virtual Interface pattern imlemented in C++?

I am curious about both, a h single and multi-threaded implementation. Thanks ...

Refactor help c#

I have several hundred lines of code like this: if (c.SomeValue == null || c.SomeProperty.Status != 'Y') { btnRecordCall.Enabled = false; } if (c.SomeValue == null || (c.SomeProperty.Status != 'Y' && c.SomeOtherPropertyAction != 'Y')) { btnAddAction.Enabled = false; } if (c.SomeValue == null || c.SomeProperty.Processing !=...

.net application architecture

I'm currently trying to design an application and I'm having trouble trying to decide on the architecture to use for it. This will be a .net application and essentially what this application will have is a server running some specific software that this application will interact with. On this server there needs to be a provisioning ser...

Do you know any designe pattern for AOP?

Do you know any designe pattern for Aspect Oriented Programming? Do you know a book or a list of such design patterns? I am looking for design patters which specifically could be implemented in AOP. I am not interested in implementing classical DPs in AOP. I'm looking for problems which could be solved much more easier using AOP. Even a ...

Two model view designs and communication between models

I have a dialog box with two disctinct parts. Each part uses a model view design. But when a model is updated, the second one has to be updated too. I’m wondering if it exists any best pratice or design pattern for communicating (update notification) between two models. That's not realy possible to have two views and only one model. Tha...

Why are EventHandlers object parameter is just an object type?

why are EventHandlers designed this way? void uxSave_Click(object sender, EventArgs e) why not this? void uxSave_Click(Button sender, EventArgs e) ...

Is there any good examples or frameworks that can teach me n-tier development?

The title tells it all, I need to see how others solve this to get a grasp around it. WebForm applications won't help me, as I don't understand WebForms and it would really confuse me (if possible) even more. If such a example or framework would fit together with Entity framework it would rock my world. Edit - Added some info: WinFo...