patterns

Adding Methods to Nullable Types

We have come across a scenario where we need to track the setting and unsettling of a nullable type. so something like int? value if(value.isSet()) { addTocollection(); } we would also need a clear function value.clear(); The concept is that the data has an extra state that is the set state. so NULL(set) and NULL(unset) have...

Python/GAE web request error handling

I am developing an application on the Google App Engine using Python. I have a handler that can return a variety of outputs (html and json at the moment), I am testing for obvious errors in the system based on invalid parameters sent to the request handler. However what I am doing feels dirty (see below): class FeedHandler(webapp.Requ...

.Net patterns vs. GOF

Since the GOF book was put together well before .Net came into being, are there any specific patterns described in GOF that are not appropriate for .Net? And if so, for what reason? This is a question relating to a recent bounty discussion. ...

Why can't non-partial active patterns be parameterized in F#?

The following F# code works as I expected, printing `Matched as 'A': let (|Char|_|) convf = function | LazyList.Nil -> None | LazyList.Cons (x, _) -> Some (convf x) let test = function | Char System.Char.ToUpper x -> printfn "Matched as %A" x | _ -> printfn "Didn't match" test (LazyList.of_list ['a']) However, if I c...

asp.net mvc view of a controller inside of a view of an other controller

so i have a "Parents" controller with list and edit view for it (to view add/edit/delete parents) and a "Children" controller same thing (view list add/edit/delete children) and now i need to refactor; to put the children view inside the parent view, so that when you edit a parent you can see the list of his children and edit/delte/add...

When is lazy evaluation not useful?

Delay execution is almost always a boon. But then there are cases when it’s a problem and you resort to “fetch” (in Nhibernate) to eager fetch it. Do you know practical situations when lazy evaluation can bite you back…? ...

UI Patterns in JavaScript

What UI patterns do you usually use in JavaScript? By UI patterns I mean best practices to be used to build and organize UI, generated/managed from JavaScript (apart from libraries like jQuery or YUI). For example, if you came from .NET world you are familiar with MVC (Model-View-Controller) patterns family. In the world of WinForms a...

WCF : Pattern for closing the state of a ServiceClient

Hi I want to ensure that a WCF-ServiceClient State will be closed after using the service. I implemented the following Code to ensure that: public static class ServiceClientFactory { public static ServiceClientHost<T> CreateInstance<T>() where T : class, ICommunicationObject, new() { return new ServiceClientHost<T>(); ...

What is this pattern called?

Private someSub() If someBoolean = True Then Exit Sub ' do some great work because someBoolean is False End Sub I know there is a name for this. The idea is to check something and if it isn't what you want then you stop code processing. I thought it was called "escape pattern", but Google isn't confirming that name. ...

Pattern for sharing functionality between controllers

I'm writing an iPhone application and I find that there are three controllers in the application that have very similar functionality. They are similar enough that it doesn't make sense to separate them into three separate classes, so I have a "mode" property that clients of the class use to specify how the controller should behave in c...

Patterns for string manipulation (in C# or other languages)

I often find myself writing quite ugly code when doing string manipulations. The code does what's expected, but I would like to feel satisfied with how it looks as well as it performs. Are there any good books, websites, forums that addresses common string manipulation problems? And how would you code the following example scenarios? A ...

Unable to install Mobile Client Software Factory July 2006 (refresh)

I'm trying to install Mobile Client Software Factory July 2006 (refresh) on a XP OS. But it is failing with an error message This installer requires the Guidance Automation Extensions, June 2006 CTP or later, which is not present on the computer. Please install it and try again. But I've installed Gu...

Which design pattern?

Hello! I am looking for a couple of patterns or design ideas for implementation in C++ that would allow the following. 1. pool of similar objects objects requested and relinquished by client pool grows when exhausted, does not shrink there will be multiple clients (one pool per client to avoid mutexing) An Object Pool seems most ap...

C++ Templates and Factories

I've been playing with C++ for a few years now, and want to become adept at using and factories. Are there some good web tutorials and/or textbooks that cover this well? I started programming prior to the wide use of the term "patterns" ('80's)... but when I first saw the term I recognized the "pattern" of it's usage. A good referenc...

When do I need to manage managed resources?

I have been looking at the standard Dispose pattern and I'm just wondering what I need to write to free managed resources? If these resources are 'managed' already then surely I shouldn't need to do anything. If that's the case, and my class doesn't hold any unmanaged resources (hence no need for it to be finalized by GC) then do I only...

MOSS Web Parts or .aspx pages/controls

When developing in MOSS I would be interested to hear peoples views on whether they choose to wrap functionality in web parts or to create .aspx pages and deploy those to MOSS and how best to make that decision. ...

Threading pattern: Chaining and looping

Hi, I need to use a WCF API to save data into a DB. Ordinarily, I'd use chaining, like the example below: IClientBroker clientBroker = UIContext.CreateWcfInterface<IClientBroker>("Data/ClientBroker.svc"); clientBroker.BeginSetClientBusinessName(_client.ID, businessName, (result) => { _client = ((IClientBroker)result.AsyncState)....

Looking for some OOAD advice for Reporting

I have the need to create an arbitrary amount of reports in many different file formats. Most of the formats I am able to use Smarty to template the output. However, outputting to Excel and PDF complicate things and require the use of FPDF or TCPDF and PHPExcel. I am trying to figure out the best way to organize my classes via one or ...

How to hide the constructor and "general" functions from individual objects?

I'm looking for advice on the best way to structure my program. Here is what I have now, and the problems I see with the design: I have a class with a private constructor and a submit() method, to carefully control the objects created, and every object created is added to a global list. The program has several functions that perform "bi...

Using flyweight pattern to share bitmaps between bitmap objects

Hello stack overflowers, I have a desing that uses the flyweight pattern to share bitmaps that are shared between bitmap objects which manage drawing ops, etc. and integrate in the gui library. This is an embedded device so memory is at a premium. Currently I have done a working implementation with a std::vector of auto_ptr of a light cl...