design-patterns

Object Model Authorization - OO Design Question

Background Each Project has one Account it is associated with. Each User can have permission to access zero to many Accounts. This in turn means that each User can only access a sub-set of Projects based on the User's Account permissions. The User object is loaded up when the user signs in to the application, and Account permissions are...

Breaking away from MVC

Lately I've been trying to improve upon/move away from the standard MVC setup for web development, and I thought it was about time to throw my ideas at StackOverflow. The general flow is the same in that a bootstrapper creates the initial objects. The difference is that these are then kept in a ServiceManager. Then, instead of dispatch...

What is a design of iChat?

iChat does not allow to change your credentials to your account when List window is open and you are connected to server. I am just wondering how this is implemented. I could imagine that internally iChat has some sort of ICAppDelegate that hold a pointer to ICPreferencesControler and an array of ICListWIndows. And now how preferences a...

Is the null object pattern worth it ?

I was looking at the null object pattern and i am wondering if it worths implementing it or use "if" checks for nulls in my code intsead. As i looked at the implementations it seems hard to keep objects well synchronized with their null implementations. By making changes to the main object we have to check that the null object behaves as...

How to best represent selectable items in a collection within the M-V-VM design pattern?

I'm just beginning to explore the M-V-VM design pattern while redeveloping an application and I'm running across a consistent theme where I have collections that I need my ViewModel to expose to the View which contain items which are to be selected by the user. Please note that when I say "selected" what I mean is that they are chosen in...

Think of AJAX as Model-View-Controller?

I think about AJAX in this way: Model: The server-side where the data is stored and exposed through webservices. In a way this is a model-view-controller within the larger model-view-controller (model = data, view = XML or some other parsable data structure, controller = server-side code that manipulates the data). View: XHTML/DOM Con...

Object Conversion Pattern

Hi there. So I have several different objects coming from external sources (unmodifiable) that represent the same concept. For example, Address. I have com.namespace1.Address (with fields houseNum, street, city), com.namespace2.Address (with fields h, s, c), namespace3.com.CoolAddress (with fields house_num, street, citY). The proble...

message queuing patterns

We have two pieces of architecture. In essence they form a producer and a consumer. Piece 1 (p1) publishes messages to Piece 2 (p2) which processes the message, this process involves sending the message to a remote node, which must ack the message once it has processed it, this process can take a few seconds at best. p2 has a finite len...

Architecture that can be used for Web/Windows/WPF

I need to create an application whose business logic can be used in WEB/WPF apps is there any standard way to do that. I am a Newb to patterns and have been thinking around in the concept of patterns and frameworks. I donot want to reinvent the wheel.:) Any Ideas?. ...

A question of design and object responsibility

Hi. I have a design and object structuring related question. Here is the problem statement: I have a Robot object which is suppose to traverse the ground on its own. It would be provided movement instructions and it must parse accordingly. For example sample input would be: a. RotateRight|Move|RotateLeft|Move|Move|Move Where move is...

How can I make something like a dynamic enumeration in C#?

In an application I'm building I had an enumeration of account statuses: public enum AccountStatus { Active = 1, Trial = 2, Canceled = 3 } However, I needed more information from an AccountStatus so I made a class which has a few extra useful properties: public class AccountStatus { public int Id {get; se...

.NET Object Design

I have a series of objects I have created: Item Order Song etc. Each object has a reasonable number of properties, and I use a datareader where I pass it "SELECT * FROM .objectname." and then I fill a collection of objects, and return the collection. This works as: GetOrdersCollection(), GetSongsCollection(), etc. I understand ...

removing from a collection

I have a collection of instances of class A. At some point an instance of A realizes that it should delete itself. I want to inform the collection of this, but I do not want A to know anything about the collection. What is the best way to go about this? It seems to me like A knowing about the collection is very bad coupling, but if I am...

MVC or MVP? Which design pattern makes the most sense?

Which do you guys prefer? I've been looking into both and there definitely seems to be some inconsistency in what people call them. I will try and jot down what the differences are and you can correct me if I'm wrong. MVC Model holds references to it's own observers (Views), on updates to the model it notifies observers. Views pass a...

Looking for a design pattern

I haven't studied design patterns, but I'm willing to bet that there is one for what I need to do. I'm running a set of different algorithms over a couple of trees. They all implement an interface: public interface DistanceMetric { public double distance(AbstractTree<String> t1, AbstractTree<String> t2); } public class concreteDis...

Sharing data between event handlers?

I'm in a situation where I'd like to send a an object out to multiple even handlers, but have certain ones use data produced by other handlers. This sounds pretty unclear - reading it myself I don't think I'd get what I was talking about - so I'll give an example. Let's say I've got the following: interface ChangeListener { public a...

Design patterns that every developer must know?

What are the design patterns that every developer must know? I'm interested in the context of Java web developers working with Spring & Hibernate. I have often heard that good knowledge in design patterns is essential for working with those frameworks. Can anyone list the specifics? For example, I know that understanding abstract facto...

Developing Web Application

I am a PHP developer who is seeking some guidance. I am developing a paid web application service. I have already developed the first phase of the project. The code is organized but I want to re-implement it in an MVC structure. I have just started using CodeIgniter for my freelance clients and it works really well. Question: What is ...

Alternatives to decorator pattern

I find decorator pattern to be most confusing. Please consider the example provided in "Head first design patterns book". So to get a DarkRoast with double mocha and a whip, you have to write Beverage beverage2 = new DarkRoast(); beverage2 = new Mocha(beverage2); beverage2 = new Mocha(beverage2)...

What are good patterns / techniques to reduce verbosity of Java

One of the things that can be a little annoying about Java is the amount of code you need to express concepts. I am a believer in the "less code is better" philosophy, and I'd like to know how I can write Java without being so frustratingly verbose. Recently, I read the Hidden Features of Java question and was introduced to using double-...