design-patterns

C# abstract class, works with array initialization.

Hey All, As we know that we CANNOT create the instance of abstract class. I just want to know that if we create the array of abstract class, it will sure work. E.g. public abstract class Creator { public abstract void DoSomething(); } Creator creator = new Creator(); // this will give you compilation error! Creator[] creator = ...

What is this pattern called?

What is this pattern called, when you give an object a parameter in its constructor and the object populates it's fields with the parameter? For example: /// <summary> /// Represents a user on the Dream.In.Code website. /// </summary> public class User { /// <summary> /// Load a user by providing an ID. /// </summary...

Calling a function from a "child" class referring the main class...

hi, i've some difficult to explain my problem, because i'm also not good in english :|! I've the following code namespace StighyGames.MyGames { public class MyGames { ... ... CarClass myCar = new CarClass(...); Main () { MyGames game = MyGames(...); } } Game is my "main" object (my application). In my CarClass i've ...

Good Book for J2EE design Pattern

Hi All, Looking for some suggestion about a good refrence book for J2EE design pattern.I do have knowledge about some patterns but not that much so looking for a good Refrence material. any help in this regard will be much helpfull Thanks Umesh ...

Where in my application belong the DTO's that are used to export and import in structured format?

Our users need to be able to export data in CSV format, edit some of the records, and upload the data again. The data does not map to entities, you could say that the object graph is flattened to fit in the Excel-based workflow. Right now this happens in the controllers because I thought these DTO classes were view models. It smells but...

Win32 MVC pattern implementation

Hi, I'm currently working on a win32 application and I'm thinking I should probably use the MVC pattern. Now according to the pattern, the code that handles user interaction should be in the controller so that I can update the model and/or view accordingly. But in Win32, would that mean that my windowProc should be in the controller ? I...

Saving Data with the Factory Pattern?

I've been becoming more familiar with the Factory Pattern (along with Strategy Pattern) and what a great benefit the pattern can have. However, I've been struggling with the following situation: Previously, I would have done something like the following, where there's a manager class that would build and save a Car. There's no depende...

DTO pattern vs Memento pattern

What are the differences between DTO pattern(by Fowler) and Memento pattern(by GoF) in motivation and implementation aspect? Can it be the same classes? If yes, how can I name them (xxxDTO or xxxMemento)? Do they have any principal difference in implementation? Where are their place in MVP architecture? Thanks. ...

Design pattern that can replace chained switch/goto?

Hello! I have a code for updating my application resources to current application version. This code is called after application update. int version = 1002; // current app version switch(version) { case 1001: updateTo1002(); goto case 1002; case 1002: updateTo1003(); goto case 1003; case 1003: ...

Class Hierarchy - ADT Hierarchy ~ Object, Ownership, container, wrapper, iterator, visitor,

I took a data structures class at a community college and transferred over to a university into a software engineering program. The data structures class i took covered. Queue,stack combined with circular arrays, hash tables and trees. My friend is currently taking data structures at the university i transferred to. They are teaching him...

DAO vs ORM(hibernate) pattern

Hi all, i read in some articles DAO is not mandatory with hibernate and its implementation is by "it depends", in other words, we can choose between ORM vs DAO pattern. Ok, let's assume that i don't want use a DAO pattern, so im using only session CRUD and query operation provided by hibernate(my ORM). Especially for the "search" and "...

How can we create library from Application? (Deriving library/API from Applications)

Dear Experts, My intent is to create a library/API for small scale distributed multi-user game /simulation. i have created couple of applications using java RMI, i tried to keep them simple and to achieve decoupling and now i want to transform those or want to derive/extract from them a generic template. Can somebody please shed ligh...

a succinct description of the factory design pattern

Hi all, Im having trouble getting my head around the concept of the factory design pattern. As far as i understand its to allow calling code not to have to worry about how an individual object is instantiated, simply to know that it will implement a particular interface. I cant see how this saves any code though. for instance, if i ...

how to write a layout manager?

I'd like write a layout manager for j2me. I already have widgets and panels (panel is a set of widgets in this context). Now I'd like to add dynimc layout management so when i call doLayout on the outer most panel, internal widgets and panels rearrange according device's width and height. I was wondering whether there any well known pa...

Implementing a robust persistent undo/redo feature

I'm writing a bitmap editor where I use the Command Pattern to represent actions that will transform the document. I keep all the commands executed so far in a list and, to implement undo, I restore the document to its initial state and then replay all but the last command. I would like my undo/redo system to have the following feature:...

Which design patterns to use for a XNA strategy game?

I'm creating a real-time strategy game based on XNA. Which design patterns are worth considering? ...

Which are C# native built-in design patterns?

Which design patterns are build-in supported by C# regardless framework version? I'm thinking of patterns such as Observer pattern that can be found in interface IObservable. ObservableCollection, INotifyPropertyChanged etc. Please provide with the namespace of the pattern in your answers! ...

Best way to implement observer pattern in Delphi

I found different implementations of the observer pattern in Delphi, like: Sourcemaking Design Patterns and Delphi Hobbyist. In general, what is the best way to implement an observer in Delphi? I would say using interfaces because the code is more readable. ...

MVVM pros and cons?

MVVM pattern pros and cons taking SDLC in consideration? In may experience many use cases are not fully investigate since they are to complex or because there isn’t enough time. In really you are always short of time. It doesn’t justify bad design but such is life. MVVM force you to fully know your Model and ViewModel limitation. Often ...

Searching childs

Hello I have class A. Class A is responsible for managing the lifetime of B objects and it contains container of B objects that is map<BGuid,B>, and each B object contains container of C objects which is map<CGuid,C>.I have one global A object for the entire application. I have the following problem: I have CGuid object and I want to u...