patterns

Zero SQL deadlock by design - any coding patterns?

I am encountering very infrequent yet annoying SQL deadlocks on a .NET 2.0 webapp running on top of MS SQL Server 2005. In the past, we have been dealing with the SQL deadlocks in the very empirical way - basically tweaking the queries until it work. Yet, I found this approach very unsatisfactory: time consuming and unreliable. I would ...

A way of casting a base type to a derived type

I'm not sure if this is a strange thing to do or not, or if it is some how code smell...but I was wondering if there was a way (some sort of oop pattern would be nice) to "cast" a base type to a form of its derived type. I know this makes little sense as the derived type will have additional functionality that the parent doesn't offer wh...

Is there a Dependency Injection framework for PHP4?

I'm stuck on a PHP 4 server, and I would like to start moving an old legacy project to modern Design Patterns, including Dependency Injection. Are there any dependency injection frameworks that will work with PHP 4? ...

Generic type args which specificy the extending class?

I want to have a class which implements an interface, which specifies the specific subclass as a parameter. public abstract Task implements TaskStatus<Task> { TaskStatus<T> listener; protected complete() { // ugly, unsafe cast callback.complete((T) this); } } public interface TaskStatus<T> { public void complete(T...

C++ Strategy Design Pattern, making an interface array

After having implemented the strategy pattern, I wanted to make an array of the interface-type, to which I can then add any concrete type. For those who don't know the strategy pattern: http://en.wikipedia.org/wiki/Strategy_pattern In this particular example I would want to make a StrategyInterface array, which I can then fill with con...

Should new web applications follow the MVC or MVP pattern?

Note that I am not asking which to choose (MVC or MVP), but rather if one of the two should be used for a web application. I realize that it might be too much work to convert an older application from its current design to a MVC or MVP pattern. However, what about for a new app? It appears these are the most popular architecture pattern...

How does Databinding work with Structured Software

Hi. I've been doing some Web-Projects lately that rely on heavy Data-Binding and have been quite happy with the results. Databinding Webforms works mostly the way I need it and I spared myself tons of code. One thing that still feels weird is that I have application logic and database logic mixed throughout the application. Datasources...

What type should Struts ActionForm properties be?

I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a specific question regarding ActionForms. Some of them have only String properties (even for numbers), some of them use the seemingly appropriate types (Integer, Date, String, etc). What's the best practice here? Also, it seems that if a property is of type Intege...

How to deal with monstrous Struts Actions?

I inherited this gigantic legacy Java web app using Struts 1.2.4. I have a specific question regarding Actions. Most of the pages have exactly one Action, and the processExecute() methods are hideous monsters (very long and tons of nested if statements based on request parameters). Given that Actions are an implementation of the command...

Architectual design patterns

I am looking for some architectual design patterns for enterprise application development. I am aware of the all of the GoF patterns, and MVC, and such things, but I am looking for patterns that emerge at a larger scope. In particular I have a somewhat larger enterprise desktop and website application, they share certain functionality, a...

Storing the state of a complex object with Memento pattern (and Command)

Hello, I'm working on a small UML editor project, in Java, that I started a couple of months ago. After a few weeks, I got a working copy for a UML class diagram editor. But now, I'm redesigning it completely to support other types of diagrams, such a sequence, state, class, etc. This is done by implementing a graph construction framew...

What is a good and known JavaScript MVC pattern?

What is the best way to manage the JavaScript files and the functions/objects context in an ASP.NET MVC app? ...

What is the meaning of '(?i)password' in python regular expression?

Pexpect can be used to automate tasks in python (does not need TCL to be installed). One of the simplest routines of this class is the 'run()' routine. It accepts a dictionary of expected question patterns as keys and the responses as values. For example pexpect.run ('scp foo [email protected]:.', events={'(?i)password': mypasswor...

Tips for writing fluent interfaces in C# 3

I'm after some good tips for fluent interfaces in C#. I'm just learning about it myself but keen to hear what others think outside of the articles I am reading. In particular I'm after: when is fluent too much? are there any fluent patterns? what is in C# that makes fluent interfaces more fluent (e.g. extension methods) is a complex fl...

Adaptive Base Design Patterns

I have been thinking about design patterns that are 'adaptive.' I am familiar with GoF designed to deal with known problems. What I am thinking about are the new, evolving technologies that the code I write will need to adapt to so that it can interact with evolving apis, programming languages, etc. I am adding an example to get at ...

Quick method to convert classes implementing same interface

How, in Java, to quickly (or generically) convert one class that implements an interface into another class that implements the same interface? I mean, if they're a POJO one class setters should take the other class getters as arguments. Is there a Pattern for this situation? ...

Algorithm/pattern for selecting sub-collections using LINQ and C#

I have a C# collection of strings. Each string is a sentence that can appear on a page. I also have a collection of page breaks which is a collection of int's. representing the index where the collection of strings are split to a new page. Example: Each 10 items in the string collection is a page so the collection of page breaks would b...

patterns for controllers in MVC application

What are your favourite patterns for writing a controller? ...

Parallel Programming and C++

I've been writing a lot recently about Parallel computing and programming and I do notice that there are a lot of patterns that come up when it comes to parallel computing. Noting that Microsoft already has released a library along with the Microsoft Visual C++ 2010 Community Technical Preview (named Parallel Patterns Library) I'm wonder...

Finding a pattern in a set

What algorithms could i use to determine common characters in a set of strings? To make the example simple, I only care about 2+ characters in a row and if it shows up in 2 or more of the sample. For instance: 0000abcde0000 0000abcd00000 000abc0000000 00abc000de000 I'd like to know: 00 was used in 1,2,3,4 000 was used in 1,2,3,...