design-patterns

RAII for singleton

I have a singleton class, whose instance get initialized at global scope within the class's CPP file: Singleton* Singleton::uniqueInstance = new Singleton(); Its header file looks like: class Singleton { public: static Singleton& getInstance() { return *uniqueInstance; } static bool destroyInstance() { delete uniqueInstance; ...

UI and Application relationship

Hi All, I've read a lot of articles about the UI ,buisness logic ,WCF ,IoC, but still, one thing is missing from my mind. I build a winforms application and a console app. the Console App is the brain. Now, in all the client-server architecture the client "know" the server , send him request and get the answer. My qestion is as follow: ...

Using pattern Adapter for Image Viewer

Hi! I do the Image Viewer. I want to use GDI+ for showing a picture in a window. And the library boost::gil for rotating, converting, resizng an image. But GDI+ contains Image class and boost::gil contains other class Image. How can I use the pattern Adapter for my task? Or what pattern should I use? Thanks! ...

MVC model in MFC

how are the classses in MFC match the model-view-control pattern ? the model is suppose to handle the Business Logic , the control suppose to be some kind of mediator and the view suppose to be the gui ? what class in MFC represent each one ? cause it seems pretty different to me as i read more about mfc. (seems like CView represent th...

Is there a DP to solve a problem where one type of class can be used only by another type?

I have a class which I want it's instances to be used only by a certain other classes. Is there a known design pattern for such a problem? An example for such a necessity would be a case of a big application (a team of 10) with BL objects and DL objects under a MVC hood, where I want to make sure only the BL classes can call/use the DL c...

MVVM ViewModel vs. MVC ViewModel

ViewModel is a term that is used in both MVVM (Model-View-ViewModel) and the recommended implementation for ASP.NET MVC. Researching "ViewModel" can be confusing given that each pattern uses the same term. What are the main differences between the MVC ViewModel and MVVM ViewModel? For example, I believe the MVVM ViewModel is more rich...

OO design patterns for multi-threaded synchronisation

Are there any generalisations of object and data and thread interactions given design pattern names? Obviously what goes on a lot is synchronisation on an object, passing messages through a queue and also reference counts in memory management systems. But are there any more OO-oriented names for multithreading design patterns and syste...

Java Design Pattern Help

Hello I am trying to build a framework of IAction objects that will execute in a sequence. Each IAction implementation will execute its processAction() method as it was implemented for. This method returns a IAction, which in most cases is itself, but in some cases may be a pointer to another IAction in the List. The IActionIterator...

Using MVC to implement a framework in JavaScript

Hi, I'm doing .NET MVC a lot so I think I understand the MVC design pattern. I'm analyzing my projects according to the Domain Driven Design (Eric Evans) methodology. Anyways.. But in JavaScript it's hard for me to think "MVC" when I'm creating libraries. Do you have a small example or any experience to share with me on how a small Ja...

Mixing logic and graphics in a class with MVC pattern

I am currently developing a charting application (for the iPhone, although that is largely irrelevant) using their MVC pattern. One aspect of the application is that you can overlay a number of statistics on the charts. I am a little unsure how I am going to structure these classes. For each statistic there will be two aspects. 1. Th...

Best way to create a ViewModel in MVVM

Assume I have a class called Customer. Now I need to render the customer on view. So I created CustomerViewModel to use in binding. I am looking for the best way to create the CustomerViewModel class. Following are my thoughts on creating it. 1 - Create all the properties in the customer again on the view model. Inject the customer inst...

New to start with Design Patterns

Possible Duplicates: which resources would you recommend for learning object oriented programming (C#)? Learning/Implementing Design Patterns (For Newbies) Hello everyone, I was working in Information Technology for few years. I was planning to learn designing / design patterns and wes really confused where to start and how t...

Where would you use a Builder Pattern instead of an Abstract Factory?

I've seen this question rise here and there a few times, but I never found and answer I was happy with. From Wikipedia: Builder focuses on constructing a complex object step by step. Abstract Factory emphasizes a family of product objects (either simple or complex). Builder returns the product as a final step, but as far as the Abst...

Table Module / Table Gateway - Where to put code for loading from gateways?

Not sure if there is a "correct" answer to this, so I've flagged it as community wiki. Apologies for the long pre-amble. I am building a modestly sized web application in .Net, and have settled on a table based architecture. My DAL layer consists of a set of TableGateway classes that handle loading/saving data to the database - these re...

The anti-DRY pattern

I've written this set of code and feel that it's pretty poor in quality. As you can see, in each of the four case statements I'm ending up repeating an awful lot of the same code except for a few variations in each case. Items that vary; session names, gridnames and the ManagerContext group name. Can anyone take this mess of code and sho...

OO / DTO Architecture question

We have an entity (class) containing data and methods (lets call it Person). There are other classes that need to use the data in this object (let's call one of them Accountant), but do not need to use the functionality in it's methods. Would it be better to send the entire Person object to Accountant, or to create a new PersonData o...

What are your templating strategies?

I try to develop my own little framework. For this, I'd like to read up some templating techniques. I know that templating is a really complex topic, but knowing some strategies could help find the right one. Please, if you mention one, don't just write "smarty" for example. Write a little about the concept behind it. Let me start with...

How to avoid long switch ..need help refactoring

hi guys, i needed help refactoring the following class, Following is a class Operation with variety of Operations in switch : i want to avoid the switch statement.I read few articles on using polymorphism and state pattern .but when i refactor the classes i dont get access to many variables,properties Im confused on whether to use o...

J2ME - BlackBerry - design patterns

There are several publications about patterns in j2me: Architectural manifesto: The MVC design pattern in MIDP development by Mikko Kontio Identification of Design Patterns for Mobile Services with J2ME by J. Narsoo and N. Mohamudally Big designs for small devices by By Ben Hui Patterns I use sometimes: MVC - to separate UI from contr...

Using a non-thread-safe component with a multithread component (Design)

Design problem : Using a non-thread-safe component (Collection, API, ...) in/with a multithread component ... Example : component1 : A multithread socket server who send messages ... to a message handler component2 : A non-thread-safe message handler who process messages ... from a server My solution : Adding a thread-safe componen...