design-patterns

ActiveRecord Pattern and caching?

Hi, I have in one project classes organized with ActivePattern (example : myObject->Load()) but now we need to implement some caching and caching is problematic. To make it simples, the Load() method in every object call the DAL my giving the $this reference and the DAL fill up the object that all values. It works. But when we add some...

Singleton pattern in web applications

I'm using a singleton pattern for the datacontext in my web application so that I dont have to instantiate it every time, however I'm not sure how web applications work, does IIS open a thread for every user connected? if so, what would happend if my singleton is not thread safe? Also, is it OK to use a singleton pattern for the datacont...

What is the basic pattern for using (N)Hibernate?

I'm creating a simple Windows Forms application with NHibernate and I'm a bit confused about how I'm supposed to use it. To quote the manual: ISession (NHibernate.ISession) A single-threaded, short-lived object representing a conversation between the application and the persistent store. Wraps an ADO.NET connection. Factory for ...

MVC pattern implementation. What is the n-relation between its components

Dear all, I'm working in a C# project and we are , in order to get some unity across the different parts of our UI, trying to use the MVC pattern. The client is windows form based and I'm trying to create a simple MVC pattern implementation. It's been more challenging than expected, but I still have some questions regarding the MVC pat...

DI with disposable objects

Suppose my repository class looks like this: class myRepository : IDisposable{ private DataContext _context; public myRepository(DataContext context){ _context = context; } public void Dispose(){ // to do: implement dispose of DataContext } } now, I am using Unity to control the lifetime of my repo...

Factory configured by a. object's class - how to do it nicely?

In my current project we have a couple of data classes that deal with core concepts of our application domain. Now at some places in our project we have to have different behavior depending on the concrete object in hand. E.g. a JList has the task to render a list of objects but we want the rendering to be slightly different, depending ...

Singleton Properties

Ok, if I create a singleton class and expose the singleton object through a public static property...I understand that. But my singleton class has other properties in it. Should those be static? Should those also be private? I just want to be able to access all properties of my singleton class by doing this: MySingletonClass.Single...

Recommend an Appropriate Object-Orientated Design Pattern To Replace This Code....

I have a menu click event that looks something like this.... Public Sub ToolbarManager_ToolClick(sender as Object, e as EventArgs) Case "New" CreateNewFile() Case "Save" SaveCurrentFile() Case "Exit" ExitApp() Case....... etc... etc... End Sub This strikes me as being 'ugly' - but I'm un...

Multiple presenters interaction

I have two views each with their own presenters and they need a two way communication between them. Like if the user name changes in View A, presenter A needs to notify presenter B of the change and vice versa. Should I create a high level presenter/eventHandler that gets notified when either A or B needs to trigger an event or is there ...

Notification between J2EE components.

Hi There! I have a design problem . My application has multiple J2EE components ,In simple terms one acts as a service provider(Non UI) and others are consumers(UI webapp) . The consumer gets the configuration data from the service provider(this basically reads the data from DB) during the start up and stores it in the Cache. The ...

What are the downsides to using Dependency Injection?

I'm trying to introduce DI as a pattern here at work and one of our lead developers would like to know: What - if any - are the downsides to using the Dependency Injection pattern? Note I'm looking here for an - if possible - exhaustive list, not a subjective discussion on the topic. Clarification: I'm talking about the Dependency I...

Need a single instance of an object using a factory with a way to reset the object's state.

I have used the abstract factory pattern to help with Dependency Injection and make my project more unit test friendly. A good couple of times I have come across the point that we should return objects in a ready-to-use state. Doing extra work like getting an object's state from a database makes it harder to test unless we can mock out t...

Is it ok to wind up using mostly static classes?

I'm currently rewriting an e-shop - but only the client side, i.e. the CMS remains mostly in tact. I am not using a pre-built framework, as the system has to retain backwards compatibility with the CMS and I have to have full freedom of the structure of code. The new system is purely MVC based and I have a Bootstrapper which loads cont...

Implementation question regarding base classes and derived classes.

I have a question regarding the best way to implement this. I'm going to describe my current implementation and how I seem to have painted myself into a corner: I have an abstract class called Package: public abstract class Package { protected String description; protected String packagingCode; protected Dimension dimension...

Circular import issues with Django apps that have dependencies on each other

Hi, I am writing a couple of django apps wich by design is coupled together. But i get sircular import problems. I know it might be bad design, so please give examples of better solutions, but i cant seem to find a better suited design. So if there isnt a better design, how to solve this one? It is basically two django apps, with some ...

How relevant are OO design patterns to web development in PHP?

Singelton, Decoratot, Abstract, Factory, and the list goes on. How relevant are OO design patterns in developing PHP applications for the web? Does it do anything for performance? Or is it just to keep code lean for agile development practices? Who is the major benefactor for implementing these design patterns? Is it the customer or the ...

What is the purpose of the PropertySpecified pattern used by XML Serialization ?

What is the purpose of the PropertySpecified pattern used by XML Serialization ? What problem does it tryto solve ? ...

Associating an Object with other Objects and Properties of those Objects

I am looking for some help with designing some functionality in my application. I already have something similar designed but this problem is a little different. Background: In my application we have different Modules. Data in each module can be associated to other modules. Each Module is represented by an Object in our application....

friendly classes in c#

hey folks! actually i refactor some portion of code. what i want to do is to initialize an object "Task" with an object "TaskArgument". let s say "TaskArgument" is abstract and "Task" implements a method "OnEnterTask(TaskArgument args)" and is sealed (for some special behavior of the existing system, which is out of scope). old code: ...

Is a "factory" method the right pattern?

Hey all - So I'm working to improve an existing implementation. I have a number of polymorphic classes that are all composed into a higher level container class. The problem I'm dealing with at the moment is that the higher level container class, well, sucks. It looks something like this, which I really don't have a problem with (as th...