design-patterns

Developing multiple user interfaces for an application

I want to develop an application which has a graphical user interface that could be developed by using different widget toolkits. For example I want to use Qt, GTK+ or even ncurses as a building block for my user interface for the same application. Moreover users could choose which GUI implementation will be used during the next startup ...

Is testability alone justification for dependency injection?

The advantages of DI, as far as I am aware, are: Reduced Dependencies More Reusable Code More Testable Code More Readable Code Say I have a repository, OrderRepository, which acts as a repository for an Order object generated through a Linq to Sql dbml. I can't make my orders repository generic as it performs mapping between the Linq...

How does ruby allow a method and a Class with the same name?

I happened to be working on a Singleton class in ruby and just remembered the way it works in factory_girl. They worked it out so you can use both the long way Factory.create(...) and the short way Factory(...) I thought about it and was curious to see how they made the class Factory also behave like a method. They simply used Factory...

Decorator pattern in C++

Can someone give me an example of Decorator pattern in C++ ? I have come across the Java version of it. But C++ i have found it difficult to understand the examples that are given. ...

Some good websites to learn about JavaScript and programming architecture?

I'm not sure if 'architecture' is the correct term, but I've been looking for some articles online which talk about programming design and more about how best to use languages such as JavaScript in a code design sense rather than the actual syntax itself. I have found many websites but a lot seem to be very out dated, and I'm not sure w...

Function chaining depending on boolean result

This is just an efficiency question really.. I'm interested to know if there is a more efficient or logical way that people use to handle this sort of scenario. In my asp.net application I am running a script to generate a new project my code at the top level looks like this: Dim ok As Boolean = True ok = createFolderStructure() ...

What is the best way to create a debugging web page for a computation in Java?

I'm developing a website that uses some complex computations (NLP-related). My customer wants to have "debugging" webpages for some of these computations where he can run them with arbitrary input and see all the intermediate results that occur during computation. Before this request all of the computations were encapsulated in beans an...

Design pattern to encapsulate common funtionality among UI controls

I'm brainstorming some ideas around a pattern to use for the following scenario. I have some 3rd party controls that I want to add common functionality to. Functionality is added by handling several of the the events and doing certain things when the events fire along with adding some private variables to hold some state info between e...

How to handle circular dependency of logger service

I have a service layer with a logger class Service layer references DAL for Logger class to get its email credentials to use while sending email for critical log items. I want to use this logger inside the DAL since there is stuff that needs to be logged there also - but with my current architecture I cannot. I see this could somewha...

Naming remote proxy classes

What are some good names for the client and server side classes that communicate over the network when implementing a remote proxy? The classes are often called stub and skelleton but I don't find those names very "intention revealing". Are there any other (better) alternatives? ...

How to face observable object containing an observable field

Hello, I need a hint concerning MVC and Observer-Pattern. For example a model contains the classes "Address" and "Person". The Address class contains the fields street:String, zipcode:String, location:String. Whereas the Person class contains the fields name:String, firstName:String, address:Address. My approach so far looks something ...

why grouping Design pattern in three parts?

Design pattern can separeted 3 important part: "http://www.dofactory.com/Patterns/Patterns.aspx". why three part? Creational Patterns Structural Patterns Behavioral Patterns How can i separete it into three part? According to what? ...

How to extend this design for a generic converter in java?

Here is a small currency converter piece of code: public enum CurrencyType { DOLLAR(1), POUND(1.2), RUPEE(.25); private CurrencyType(double factor) { this.factor = factor; } private double factor; public double getFactor() { return factor; } ...

How to solve the "Growing If Statement" problem?

I've been doing some reading about design patterns and wanted some perspective. Consider the following: Dim objGruntWorker as IGruntWorker if SomeCriteria then objGruntWorker = new GoFor() else if SomeOtherCriteria then objGruntWorker = new Newb() else if SomeCriteriaAndTheKitchenSink then objGruntWorker = new CubeRat() end i...

Are SOLID principles really solid?

The first pattern stands for this acronym is SRP. Here is a quote. the single responsibility principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class. That's is simple and clear till we start to code ) Suppose we have a class with well def...

Is this the correct way of speaking to a "Content Manager" Class?

I am creating a silverlight site. I am currently breaking out my ideas into pieces of functionality. One of the idea's I have is the concept of a content manager. This is essentially a UI control with 4 regions. Top, Bottom, Right & Left. I also have a collection of objects that are considered "Menu Items". These are controls that functi...

Design suggestions for creating document management structure using hidden shares.

I need to add some document management functionality into my software. Documents will be grouped by company name and project name. The folders need to be accessed by the application using the id numbers of clients/projects, but also easily browsed by the end user using windows explorer. Clients and Projects will be stored in a databa...

UI Design - design pattern for city/country drop down? (ASP.NET MVC)

What is the best way to do a city/country dropdown pair in ASP.NET MVC? I see lots of places with country above city, but that's unnatural: in real life we write city/country. I've used city, then country, but the problem is that the user then has to go backwards after changing the country. The other problem is what do you do about cit...

Design pattern to integrate Rails with a Comet server

I have a Ruby on Rails (2.3.5) application and an APE (Ajax Push Engine) server. When records are created within the Rails application, i need to push the new record out on applicable channels to the APE server. Records can be created in the rails app by the traditional path through the controller's create action, or it can be created by...

Question about a possible design pattern...

I have such a design in my mind.... My aim is to reuse the program with some features included and without some features. What is it called in the literature? More information: there are events.. Events cause calls to function1() or function2()... Features have functions which are called when events takes place. A feature may influence ...