design-patterns

Unit Testing with the Mediator Pattern - All Private to Public

I am using the mediator pattern to facilitate unit testing of GUI objects. psudo code Example: Class MyGuiClass { //... Declare and initialize mediator to be a MyMediator private void On_SomeButtonPressed() { mediator.SomeButtonWasPressed(); } } Class MyMeditator { public void On_SomeButtonPressed() { //.. Do so...

Design Pattern - ASP.net

hello all, Need to design ASP.net pages which are mostly datadriven pages (read/write to sql tables) through a interface. This is mostly for maintence of job queues (to job on hold / delete from queue => which in turn is updating or deleting view. What would be best Pattern to do with such maintence pages. Thanks ...

Rails - Namespacing models

Usually there are a lot of models in a Ruby on Rails project, so: Is it a good practice to namespace them (in modules/folders)? What are the downsides? EG: Shop category.rb details.rb Products category.rb base.rb etc (instead of ShopCategory, to have Shop::Category?) Should also the controllers be namespaced in the same man...

Data Access Design Patterns

Hi, Im looking for a pattern which I can use for parent-child relationships when inserting records into a database. As the child record needs the parent record to exist first, Im having to use nasty things like storing the session id then updating the foreign key after saving the parent record. Are there any well know patterns to solve ...

Is there a design pattern for dealing with large datasets over the internet?

I am looking for a design pattern that handles large data sets over the internet, and does periodic updating of these objects. I am developing an application that will display thousands of records in the UI at one time. Additionally, various properties on these objects are quite transient and need to be updated on the client to keep th...

Examples of GoF Design Patterns

I am learning GoF Java Design Patterns and I want to see some real life examples of them. Can you guys point to some good usage of these Design Patterns.(preferably in Java's core libraries). Thank you ...

Architecture and patterns for developing a custom GUI designer via C# & WinForms.

I only have a vague hint of spec so far, but I'm just testing the waters. I need to create a designer that will be used for creating CBT tasks and workflows. It must cater for custom objects (controls) as well as standard .NET WinForms controls. I very lightly scanned some papers long ago on using the Visual Studio SDK and deployable ...

How to teach Design Patterns to a team

I'm a huge fan of the classic Design Patterns book. I very diligently worked to learn most patterns and how they are used (and when they should be avoided). However, I frequently encounter teams where I am the only one touting the book on a regular basis. I was hoping that learning this book would make it easier to explain concepts to...

Is this dependency injection in ActionScript 3?

Hi. I have a Main.fla (controlled by Main.as) that has a child named Slide (a Movieclip controlled by another class, Slide.as). Sometimes, my Slide object have to call the method "nextSlide" on his father, Main object. To do this I tried "this.parent.nextSlide()", but I got this error: 1061: Call to a possibly undefined method nextSli...

Should I use a singleton?

This is a semi-related question to question to the following question I just raised: http://stackoverflow.com/questions/1671259/utility-classes-good-or-bad After determining that a class is to act as a cache for Url parsing rules stored in an XML file, I have considered that a singleton would solve my problem, but introduce global stat...

Is there a data storage pattern similar to mipmaps in graphics?

We've got a bunch of data the users may want to view windows of and do so quickly. They may want to look at a window of the data that is a day, a week, a month, or an arbitrary beginning and ending data. Sorting and summing up all of this stuff in real time is proving to be painful for us so I got the idea of doing something similar to M...

Class design ideas for state machine like object.

I'm writing a state machine like object. Looks like Class A: vector<Actions> m_enter_actions; vector<Actions> m_exit_actions; public: ClassA.... ~ClassA SetEnterActions(vector<Actions> vector) SetExitActions(vector<Actions> vector) Is this the best way to handle this? I wonder if I should have like Class A: EnterActio...

Using xml to load objects. Which is the best approach?

TinyXML I have a XML file that keeps a bunch of data that is loaded into objects. Right now, I have one giant method that parses the XML file and creates the appropriate objects depending on the contents of the XML file. This function is very large and imports lots of class definitions. Would it be better to each class type to do its ...

Moving Data access layer to WCF service

I am at a stage of building a wcf service for my application that will provide the products.. I have, the domain model and persistence layer under the application. For the service I will also need a similar domain model and persistence layer. I don't want to duplicate things and I don't want to also share libraries and couple the applic...

Problems Mapping Composition Relationships using Entity Framework

I'm trying to model my domain model using the entity framework. An example is Page class containing a Content class. public class Page { public virtual int Id { get; set; } public virtual string Name { get; set; } public virtual Content PageContent { get; set; } } public class Content { public IList<Version> Versions { ge...

Circular compositional pattern with RSS Feed and FeedItem classes

I'm designing a small system to parse RSS feeds, and I have two classes: Feed and FeedItem. public class Feed { public string Title{ get; set; } public string Link{ get; set; } public string Description { get; set; } public bool IsTwitterFeed { get; set; } public List<FeedItem> Items { get; set; } } public class Fee...

How are Models (in MVC) and DAOs supposed to interact?

How are models and DAOs supposed to interact? I'm in the process of putting together a simple login module and I'm unsure where to put the "business logic." If I put the logic with the data in the model, how would I access the logic? Currently, I have: A controller that receives form data A model that is a simple reflection of...

Misuse of Observer Pattern?

I have a Car object which contains a latitude field and a longitude field. I use the observer pattern so that any time either of these fields change in my application, my car object is notified. I now find the need to create several other car objects whose default values I wish to have the same as what is the current latitude and the cu...

MVP Vs MVVM - why

Hello, I was using MVP when I was working with winform. but I moved to MVVM when i started playing with WPF or Silverlight. The only thing that I noticed is that we don't need to sync with the data between View and ViewModel in MVVM pattern because of powerful binding. My question are ~ 1) Binding (that helps us not to sync View a...

Dependency Injection and Generic Collections

I'm going round in circles at the moment trying to get the pattern right for using Dependency Injection with a number of IEnumerables. I have three types of object that I want to return from my database: Projects, Batches and Tasks. I want to create a Repository that has the following form: public interface IRepository<T> { IEnume...