design-patterns

Session vs singleton pattern

Hi, I have a web application where I would like to pull user settings from a database and store them for Global access. Would it make more sense to store the data in a Singleton, or a Session object? What's the difference between the two? Is it better to store the data as an object reference or break it up into value type objects (ints ...

Proper LINQ to Lucene Index<T> usage pattern for ASP.NET?

What is the proper usage pattern for LINQ to Lucene's Index<T>? It implements IDisposible so I figured wrapping it in a using statement would make the most sense: IEnumerable<MyDocument> documents = null; using (Index<MyDocument> index = new Index<MyDocument>(new System.IO.DirectoryInfo(IndexRootPath))) { documents = index.Where(d...

Applet networking patterns

Hi SO. I have an applet that connects to a server, it receives some commands and based on that it haves to draw (or move) different things. Which patterns should I use? I assume that the network connection and applet should run in two different threads? Thanks, Kristoffer ...

Are there any design-patterns specifically useful for game-development?

This question's been bugging me for a long time. I've always wondered how game developers were solving certain problems or situations that are quite common in certain genres. For example, how would one implement the quests of a typical role-playing game (e.g. BG or TES)? Or how would you implement weapons with multiple stacking effects ...

C# MultiThread Safe Class Design

I'm trying to designing a class and I'm having issues with accessing some of the nested fields and I have some concerns with how multithread safe the whole design is. I would like to know if anyone has a better idea of how this should be designed or if any changes that should be made? using System; using System.Collections; namespace ...

Modeling related objects and their templates

Hello everybody! I am having trouble correctly modeling related objects that can use templates. This is not homework, but part of a small project in the university. In this application the user can add several elements, which can either be passive or active. Each concrete element has different attributes, these must be set by the user....

disadvantages of builder design pattern

What would be the disadvantages of using the builder design pattern. Are there any?? edit - I want to know whether there is any bad consequence of using builder design pattern? As in the GOF book, they have mentioned the good and bad consequences of design patterns. But they haven't mentioned any bad consequence for builder design patte...

Design pattern for Fat Client - Thin Client to use Common code?

Windows-based client application and web-client application(consuming the same code which windows-client uses) what is the preferable pattern for this scenario? Is it ok to have the code in the common place where both the projects and refer it as dll i.e one which is a windows app and other which is going consume the same code which wind...

When can we expect Core JEE Patterns from SUN/Oracle like we already have for J2EE?

Just like we have www.corej2eepatterns.com for J2EE, when can we expect any resource(book) on patterns for JEE5/6? ...

Java Singleton Pattern

Edit: Answered - error was method wasn't static I'm used the Singleton Design Pattern public class Singleton { private static final Singleton INSTANCE = new Singleton(); // Private constructor prevents instantiation from other classes private Singleton() {} public static Singleton getInstance() { return INSTANCE; ...

Is there a recommended way to use the Observer pattern in MVP using GWT?

I am thinking about implementing a user interface according to the MVP pattern using GWT, but have doubts about how to proceed. These are (some of) my goals: the presenter knows nothing about the UI technology (i.e. uses nothing from com.google.*) the view knows nothing about the presenter (not sure yet if I'd like it to be model-agno...

What is the best software design to use in this scenario

I need to generate HTML snippets using jQuery. The creation of those snippets depends on some data. The data is stored server-side, in session (where PHP is used). At the moment I achieved this - retrieving the data from the server via AJAX in form of JSON - and building the snippets via specific javascript functions that read those dat...

Design Pattern - Complex MultiObject Versioning w/Out-of-Sequence awareness

Here's the deal/challenge, We have to keep track of information and it's linear changes. We also have to keep track of changes that are out-of-sequence. For example A happened then B happened. Sometime later, we learn of C which actually happened before B. Along with this challenge, we have many objects that have to be versioned th...

What types of objects should the ViewModel reference in the MVVM pattern?

I've seen quite a few examples of MVVM. I can see that the View should reference the ViewModel. I've seen recently an example of a ViewModel referencing a View, which seems wrong to me, as it would result in tighter coupling. Given that ViewModel is often described as an intermediary between the View and the Model, is there more to the V...

How often are design patterns used in the workplace using PHP

Hey everyone, I read a book awhile back called PHP Design Patterns and Practice, and ever since then I have been using design patterns whenever I think they are needed. However it just occurred to me that maybe most companies do not use design patterns very often for PHP, or at all. What I was wondering is, do most companies use design ...

JavaScript Resource Management Design Pattern

As a web developer, a common problem I find myself tackling is waiting for something to load before doing something else. In particular, I often hide (using either display: none; or visibility: hidden; depending on the situation) elements while waiting for a background image or a CSS file to load. Consider this example from Last.FM. The...

Design Pattern for Changing Object

Is there a Design Pattern for supporting different permutations object? Version 1 public class myOjbect { public string field1 { get; set; } /* requirements: max length 20 */ public int field2 { get; set; } . . . public decimal field20 { get; set; } } Version 2 public class myObject { public string field1 { get; set; } /...

Writing a synchronized thread-safety wrapper for NavigableMap

java.util.Collections currently provide the following utility methods for creating synchronized wrapper for various collection interfaces: synchronizedCollection(Collection<T> c) synchronizedList(List<T> list) synchronizedMap(Map<K,V> m) synchronizedSet(Set<T> s) synchronizedSortedMap(SortedMap<K,V> m) synchronizedSortedSet(SortedSet<T...

Decorator that can take both init args and call args?

Is it possible to create a decorator which can be __init__'d with a set of arguments, then later have methods called with other arguments? For instance: from foo import MyDecorator bar = MyDecorator(debug=True) @bar.myfunc(a=100) def spam(): pass @bar.myotherfunc(x=False) def eggs(): pass If this is possible, can you provi...

What should go in each MVVM triad?

OK, let's say I am creating a program that will list users contacts in a ListBox on the left side of the screen. When a user clicks on the contact, a bunch of messages or whatever appears in the main part of the window. Now my question is: how should the MVVM triads look? I have two models: Contact, and Message. The Contact model co...