design-patterns

Calling DI Container directly in method code (MVC Actions)

I'm playing with DI (using Unity). I've learned how to do Constructor and Property injection. I have a static container exposed through a property in my Global.asax file (MvcApplication class). I have a need for a number of different objects in my Controller. It doesn't seem right to inject these throught the constructor, partly because...

What is it called when an object member returns the object, enabling you to string method calls?

Perhaps I'm just not using the right Google-age. But I am trying to remember what the term is for when you return the object from one of it members to enable you to do something similar: class obj { obj function method() { return this } } obj->method()->method()->method()->method() I used to know this but it has t...

Should I use a class in this: Reading a XML file using lxml.

Hi everyone. This question is in continuation to my previous question, in which I asked about passing around an ElementTree. I need to read the XML files only and to solve this, I decided to create a global ElementTree and then parse it wherever required. My question is: Is this an acceptable practice? I heard global variables are ba...

Perls Of Wisdom For a .Net Programmer

Hi Guys, I like to think that recently I have moved from complete beginner to beginner. It has been a hard road and one on which I took many wrong turns. Very rarely in any profession is there a place where so many rock stars gather, this is something I would like to take advantage of. What I would like to ask is what are your perls of...

Doubleton pattern in C++

I am aware of the singleton pattern in C++, but how do you get two instances of an object? Is there any such pattern where we could easily get two objects? For the logic I could think of is that I can change the singleton pattern itself to have two objects created inside the class. This works, but if the requirement grows like if I need...

Implement Apect-oriented-like nested around filters with Ruby?

I'm trying to write a class that supports nested around filters without introducing an Aspect-oriented library. class Foo attr_accessor :around_filter def initialize #filters which wrap the following one are the ones with interesting logic #vanilla do-nothing filter @around_filter = lambda { yield } # or lambda {|&blk| ...

What would you like to correct and/or improve in this java implementation of Chain Of Responsibility ?

package design.pattern.behavioral; import design.pattern.behavioral.ChainOfResponsibility.*; public class ChainOfResponsibility { public static class Chain { private Request[] requests = null; private Handler[] handlers = null; public Chain(Handler[] handlers, Request[] requests){ this.handlers =...

Is the design notion of layers contrived?

Hi all I'm reading through Eric Evans' awesome work, Domain-Driven Design. However, I can't help feeling that the 'layers' model is contrived. To expand on that statement, it seems as if it tries to shoe-horn various concepts into a specific, neat model, that of layers talking to each other. It seems to me that the layers model is too s...

How should nested components interact with model in a GUI application?

Broad design/architecture question. If you have nested components in a GUI, what's the most common way for those components to interact with data? For example, let's say a component receives a click on one of its buttons to save data. Should the save request be delegated up that component's ancestors, with the uppermost ancestor ultimat...

How to design authentication in a thick client, to be fail safe?

Here's a use case: I have a desktop application (built using Eclipse RCP) which on start, pops open a dialog box with 'UserName' and 'Password' fields in it. Once the end user, inputs his UserName and Password, a server is contacted (a spring remote-servlet, with the client side being a spring httpclient: similar to the approaches here...

Architecture of a single-page JavaScript web application?

How should a complex single-page JS web application be structured on the client-side? Specifically I'm curious about how to cleanly structure the application in terms of its model objects, UI components, any controllers, and objects handling server persistence. MVC seemed like a fit at first. But with UI components nested at various dep...

Would ViewModels fit in the Model View Presenter pattern?

Having used ViewModels in MVC, I was wondering if applying the same to the MVP pattern is practical. I only have a few considerations, one being that MVP is already fairly hard to implement (with all the additional coding, not much on the seeming complexity) or that ViewModels already have a slightly similar way of modeling data or entit...

mvp design pattern - question

hi, When I have a button which only changes something in my view (e.g. such that some text appears if I press it), can I write its whole code in the file with my view or should I include event handling of this button in the presenter? This is problem for me, because I don't know, if the presenter handles all events from the view or only...

Patterns/Best Pratices Parameters WebService

Camarades, I am developing a WebService, and wish to make it accessible to everyone, in all languages in a simple and practical way. For one of the access, I need to send two pieces of information, a token and an XML. In this case, was in doubt, I use parameters: String - String or String - XmlDocument? Well, in other words, my questi...

What book are you recommending for a deep study of Design Pattern?

Possible Duplicate: Best book/resource for learning Java design patterns? Hi! I porposed to study Design Patterns in Java. Can you recommend me some good books for this? Thanks advance. ...

Design-patterns for memcache-client-like connection management?

I need to manage connections to a number of services, hosted across a number of servers. Each service is available on more than one server for redundancy. What I'd like to do is build a client, similar to memcached or beanstalkd clients, that can connect to the services in a round-robin fashion; if a connection goes down it tries the ne...

EF4 and ASP.Net MVC to Test and Develop without mapping to an underlying database (until later)

Hi I want to develop an ASP.Net MVC application with EF4 Model First design and only generate the actual database much later, ideally at the end of the project. Based on some of the ideas here: http://elegantcode.com/2009/12/15/entity-framework-ef4-generic-repository-and-unit-of-work-prototype/ I want to create something like an ...

Design pattern for loading multiple message types

As I was looking through SO I came across a question about handling multiple message types. My concern is - how do I load such a message in a neat way? I decided to have a separate class with a method which loads one message each time it's invoked. This method should create a new instance of a concrete message type (say AlphaMessage, Bet...

Bridge or Factory and How

I'm trying to learn patterns and I've got a job that is screaming for a pattern, I just know it but I can't figure it out. I know the filter type is something that can be abstracted and possibly bridged. I'M NOT LOOKING FOR A CODE REWRITE JUST SUGGESTIONS. I'm not looking for someone to do my job. I would like to know how patterns co...

'Forward-Compatible' Program Design

The majority of my questions I've asked here so far on StackOverflow have been how to implement individual concepts and techniques towards developing a software-based NES clone via the XNA environment. The small samples that I've thrown together on my PC work relatively great and everything. Except I hit a brick wall. How do I merge a...