design-patterns

Design patterns for messaging / event driven infrastructure

Hi, I'm building my first system that relies heavily on a message queue for reasons other than scaling. To cut a long story short there will be many clients connected to a central server via the internet, each client has the ability to edit data on the server, when such an event occurs the other clients need to be updated live. Does an...

C# How to split the following large complex class.

I've managed to program the following THWorkingMemory class, into a antipattern, the God Object. I planned it to be a fairly small class with around 20 methods, but now it's packed with queue handlers, timers, threads, callbacks, powershell queue callbacks, event handlers, lock handlers and about 50+ methods, i.e. the lot. The class has...

Coding classes with the same behaviour + unique behaviour

I have a set of classes which have similarities and differences. They derive from an interface, which defines the unique behaviour amongst these different classes, and a base class to call the common functionality in the several classes. Is there a design pattern which governs how these sort of classes are created? Is it acceptable to u...

How to plan a project...

I am about to embark on a project mostly using C# that will involve client and server communication. I'm wondering how to plan out a project like this. I usually just jump into smaller projects and figure things out as I go because I have a diagram in my head. How do I design a complex project before knowing everything it will require...

How To create a UML diagram for Source Code Files?

I have one scenario That our program output will generate two source code files as ABC.c (1 code file) ABC.h (1 header file) these two files will be added to many other external programs and exe of those programs will be created Now my issue is for drawing a deployment diagram for those source code files, how can i display this sce...

abstract an Interface `ISingleton` to be base class

Hi , I have 3 interface classes IVideo , IAudio , IGPIO and three other classes that will implement those interface: Video_impl , Audio_impl , GPIO_impl. Things is simple so far. But then ,I want all those object to be singleton. Here are the questions: Is it a good idea to abstract an Interface ISingleton , so that Video_impl , Audi...

How to properly use a NHibernate ISession object - Session Is Closed! errors

I'm running into issues with my ISessions in NHibernate. I keep getting "Session Closed!" errors. Can some one please show me the correct pattern including a definiion of the following methods and when to use each: ISession.Close() ISession.Dispose() ISession.Disconnect() Here's my problem. I have a callback setup to fireoff a process...

C# code that generates javascript on the fly

Is it OK to generate code like this on the fly? Or is this a major code smell? How can this be made better? I'm new to web but I'm stumbling across this all the time and I don't really understand why. // Create a js function that applies foo to each group of controls foreach (KeyValuePair<string, Dictionary<Control, string>> pair in ...

Who is responsible for initializing a model from remote sources

I know that I am for responsible for this in the code, but in a object-oriented and MVC sense, who should really load the model. I have a model for representing RSS feeds that is being loaded from a url. The model is really thin and the controller manages downloading and parsing of the XML and then passes it on to the model. Is it better...

Persistence Pattern - Rule based Observer

I'm trying to add functionality to an app where a user can subscribe for changes made either: To another entity (by any user) By another user (to any other entity) A combination of the two (this last one's optional, but makes the problem more challenging) I'm wondering how best to persist these rules to the database. I'm naturally t...

Implementing Singleton across requests to HttpHandler

I am attempting to create a singleton service that is used to process incoming requests to an HttpHandler. At the moment the service is being instantiated on every request. I make a call to the static class that holds an instance of the service, implemented as a singleton as below: public static class ServerApplication { static Servi...

Returning a inherited class as base class type with Web Services

I suspect I am being very silly here but I have the following setup Class MustInherit myBaseClass 'some stuff End Class Class myInheritedClassA inherits myBaseClass 'some more stuff End Class Class myInheritedClassB inherits myBaseClass 'some more stuff End Class I then have a web service that has a method F...

Design pattern for handling multiple message types

I've got the GOF sitting on my desk here and I know there must be some kind of design pattern that solves the problem I'm having, but man I can't figure it out. For simplicities sake, I've changed the name of some of the interfaces that I'm using. So here's the problem, on one side of the wire, I've got multiple servers that send out d...

Coding standards and design patterns in PHPSpec library

I really like the codebase of PHPSpec. Could any of you guys mention any standards and/or design patterns that are prominent in this library as that is how I want my code to be? ...

Front-end vs back-end developers, Working Together strategy?

Right now im in the middle of a product (WebApp) release, we are working with ASP.NET MVC. Im a BackEnd dev, but now i must implement the front end with the design, is this the way to do it? code all the basic HTML and then re-implement the final markup. NOTE: *in one of the MIX videos i heard that when the MVC team work on the Nerd din...

What is the most appropriate design for an object who's database key is made up of multiple columns?

Suppose I have a table in my database that is made up of the following columns, 3 of which uniquely identify the row: CREATE TABLE [dbo].[Lines] ( [Attr1] [nvarchar](10) NOT NULL, [Attr2] [nvarchar](10) NOT NULL, [Attr3] [nvarchar](10) NOT NULL, PRIMARY KEY (Attr1, Attr2, Attr3) ) Now, I have an object in my applicatio...

MVC Object Oriented Techniques - How to minimise queries and maintain flexibility?

Hello there I am using an objected oriented MVC framework in PHP (Kohana) and have kind of mashed together a few techniques to get stuff done. Problem is I am not sure how to keep things clean without calling lots and lots of queries per page. To illustrate my example, I'll imagine I am designing a stack overflow like site: I have ...

Applying Patterns to User Interface design, not only application design

I am a dotnet newbie. After years of procedural coding, my company is moving on to the HOTTEST new trend i.e WINDOWS FORMS :) Our Application is TabbedMDI. Basically we have a menu on the left and clicking an entry opens a new tab for CRUD. I have seen some MVP samples that have a couple of textboxes and it demonstrates moving the code...

When is it a poor design choice to use a factory instead of simply returning a bean?

Our application makes heavy use of factories to spit out objects, but I often wonder if they are always really necessary, and it wouldn't simply be better to create an instance of a "known object" as a bean. The argument is that developers are often customizing the implementation of these returned objects (which are returned with their i...

Clearing/resetting a model in qt (removing all rows)

I'm a little confused about what the correct way to reset or clear the data in associated with a QAbstractItemModel. I'm writing an application in which the user can "start over" with a new set of data (empty, or small). Should I be deleting the old model when the user makes this request? Or should I leave the model alone and just remov...