design-patterns

Creating my object takes too long. Is it bad practice to create a ton of instances at startup to speed things up later?

I have a wizard class that gets used a lot in my program. Unfortunately, the wizard takes a while to load mostly because the GUI framework is very slow. I tried to redesign the wizard class multiple times (like making the object reusable so it only gets created once) but I always hit a brick wall somewhere. So, at this point is it a huge...

Where are answers of sharpen your pencil section of "Head first design patterns" ?

Hi Where can I find answers of sharpen your pencil section of "Head first design patterns" ? ...

Is this a good reason to use a service bus, alternatives please

I'm in the planning phase of our new site - it's an extension of some mobile apps we've built. We want to provide our users with a central point for communication and also provide features for users who don't want to/can't use the mobile apps. One of the features we're looking at adding is a reputation system similar in nature to the SO ...

The most elegant way to write an abstraction layer

Hi! I'm curious how to write an abstraction layer. By abstraction layer, I mean a wrapper above one or more 3rd party libraries. Or do I have to solve it like this? #include<an3rdpartyl> #include<another3rdpartyl> class layer { private: an3rdpartyl* object1; another3rdpartyl* object2; public: //... int loadModel(char* ...

Fast undo/redo for bitmap editor when memory is limited?

I'm trying to write a bitmap editor for a mobile device (i.e. a limited version of Photoshop). The user's document consists of ~4 bitmaps around 1000x500 in size each. I want a robust and efficient undo/redo system that's as simple as possible. I'm aiming for about ~0.2s to undo or redo an edit. I'm looking for some feedback on my curre...

Best design pattern for storing control state

I have a tab control that loads panels as each tab is clicked. I want to add State by having the panel created on the first tab load, and then save the panel and retrieve it after that. Would that fit under the repository design pattern or is there a better one to use? ...

Selecting Instances of an Interface Based On Specific Value

I'll start here with a little bit of background. We have an ASP.Net MVC web application that sits upon a structure roughly based upon the Onion Architecture concept. Therefore, we have the following (simplified) vertical structure: ASP.Net MVC controller layer Application service layer Business Service layer NOTE: The above is simpli...

Implementing the Command Pattern using C# Action delegate

Is it possible implement the GOF command pattern using a Queue of Action delegates? I have been trying to wrap my head around it for a while and I am stumped because each of the possible actions I want to add to the queue may have a varing number of parameters. Any suggestions? Am I barking up the wrong tree by focusing on the command ...

Design pattern(s) for a webservice enabled telerik treeview for navigation of a document site

I am currently working on a document management system in ASP.NET 3.5 using the Telerik AJAX toolkit. It consists of masterpage with a title banner across the top and a RadTreeview down the left hand side for navigation through the site. The treeview uses a combination of static nodes and dynamic ones. The dynamic nodes are populated via...

Is there a name for this pattern?

I am basically quite sure this pattern must exist and possess a name... for now I will call it "gate pattern"... Here it is: In my webpage's javascript, I have to trigger various asynchronous processes. Let's not discuss how trully async js is, but anyway I have to trigger 2 or 3 AJAX calls, must be sure, the UI build-up has finished, ...

How to handle billions of objects without "Outofmemory" error

Hi All, I have an application which may needs to process billions of objects.Each object of is of TRange class type. These ranges are created at different parts of an algorithm which depends on certain conditions and other object properties. As a result, if you have 100 items, you can't directly create the 100th object without creatin...

Changing the type of an entity at some point of its life

I have the following hierarchy: Party is a base class, extended by Person and Corporation. I need to change the object class of an entity at some point of its life, and I don't know what's the best way to do this. I'm modeling the financial world, so I have that a Party can own shares of a Corporation, while only Corporation can have s...

Billing system best practices

Dear Gurus, I'm currently developing a web application for one of my clients. This client requested a small billing module. The client istelf is small SIP provider. There are several pricing items, plans, etc. All they different types of payment like onetime, monthly, annual. Are there any best practices, good books, articles on blling...

Pattern where only one handler of many should act based on specialization

I'm trying to rewrite some code to break some coupling issues and make it easier to modify in the future. Right now, I have a static factory method in a base class that, depending on the situation, picks an appropriate implementation. The decision is based on degrees of specialization: While types A and B both can handle this, B...

What is the name of this pattern or technique?

There are objects which need two other objects as parameters. This parameter objects may change during runtime. I use another object which holds the references to the parameter objects. These references are always up to date. All the other objects ask this objects for the current parameters. They don't have to be updated anymore. Onl...

Has POAD (Yacoub) made any progress in the last 10 years?

Sherif M. Yacoub is the author of Pattern-Oriented Analysis and Design: Composing Patterns to Design Software Systems. The last time this book about Pattern Driven development was published was in 2003, and it is now out of print. Does anyone know if any progress has been made in this approach to Software Engineering? Or are there other,...

Socket-based Message Factory

I'm looking for some ideas on implementing a basic message factory that reads a header from an input stream and creates the appropriate message type based on the type defined in the message header. So I have something like (roughly.. and I'm willing to change the design if a better paradigm is presented here) class MessageHeader { ...

Design Pattern required for database schema with two classes both composing a third class.

Consider a system which has classes for both letters and people; both of these classes compose an address. When designing a database for the system it seems sensible to have a separate schema for the address but this leads to an issue; I don't know how to have a foreign key in the address table cleanly identify what it belongs to because...

C#: Enum anti-patterns

There has been a lot of talk of Enums in general violating Clean Code-principles, so I'm looking for people's favorite Enum anti-patterns and alternative solutions for these. For example I've seen code like this: switch(enumValue) { case myEnum.Value1: // ... break; case myEnum.Value2: // ... bre...

What is the easiest solution for transparent remoting with Delphi?

I have a two tier Delphi for Win32 application with a lot of business logic implemented in a god object I want to outsource into a separate service. This separate service should be accessed by multiple clients via TCP/IP telnet-style protocol. How do I go about making the transition most simple? Precisely, I'd like to keep this simplic...