design-patterns

How do you store request URL's in Javascript to satisfy the DRY principal?

Are there any commonly used patterns in Javascript for storing the URL's of endpoints that will be requested in an AJAX application? For example would you create a "Service" class to abstract the URL's away? ...

What does your Objective-C singleton look like?

Mine is merely (or a close variant thereof): static MyClass *gInstance = NULL; + (MyClass *)instance { @synchronized(self) { if (gInstance == NULL) gInstance = [[self alloc] init]; } return(gInstance); } ...

Relational Database Design Patterns?

Design patterns are usually related to object oriented design. Are there design patterns for creating and programming relational databases? Many problems surely must have reusable solutions. Examples would include patterns for table design, stored procedures, triggers, etc... Is there an online repository of such patterns, similar to m...

In Django, where is the best place to put short snippets of HTML-formatted data?

Hi there, This question is related to (but perhaps not quite the same as): http://stackoverflow.com/questions/61451/does-django-have-html-helpers My problem is this: In Django, I am constantly reproducing the basic formatting for low-level database objects. Here's an example: I have two classes, Person and Address. There are multiple...

Should I not subclass by type of object if there are many types?

I am working with a log of events where there are about 60 different "types" of events. Each event shares about 10 properties, and then there are subcategories of events that share various extra properties. How I work with these events does depend on their type or what categorical interfaces they implement. But it seems to be leading t...

Using events rather than exceptions to implement error handling

I'm working on some code that uses a pattern in its business and data tiers that uses events to signal errors e.g. resource = AllocateLotsOfMemory(); if (SomeCondition()) { OnOddError(new OddErrorEventArgs(resource.StatusProperty)); resource.FreeLotsOfMemory(); return; } This looked superficially rather odd, espec...

Practical Uses for the "Curiously Recurring Template Pattern"

What are some practical uses for the "Curiously Recurring Template Pattern"? The "counted class" example commonly shown just isn't a convincing example to me. ...

Parameterized singleton patterns

The link over here lists ([http://www.yoda.arachsys.com/csharp/singleton.html][1]) some singleton patterns in C#. The article also describes the obvious that a singleton is not meant to accept parameters which “as otherwise a second request for an instance but with a different parameter could be problematic”. This means that any paramete...

What's the common way for OOP Pattern design (Data Access)

Hi, Originally there was the DAL object which my BO's called for info and then passed to UI. Then I started noticing reduced code in UI and there were Controller classes. What's the decent recomendation. I currently structure mine Public Class OrderDAL Private _id Integer Private _order as Order Public Function GetOrder(i...

Encapsulating an algorithm into a class

I'm wondering how (un)common it is to encapsulate an algorithm into a class? More concretely, instead of having a number of separate functions that forward common parameters between each other: void f(int common1, int param1, int *out1); void g(int common1, int common2, int param1, int *out2) { f(common1, param1, ..); } to encapsula...

What book/resource would you recommend for learning non-OOP design?

I realized that OOP is the only area where I can produce results I'm satisfied with. To be more specific - mainstream static-typed OOP like C++,C# or Java. May be it is so because I've read enough books and articles on it and because most of my programming experience is in OOP. And may be because OOP is just really good :) Each time I h...

Best Book to Study Integration Patterns

I recently finished a book and discussion group about Software Design Patterns. We have now started to study Integration Patterns. I am currently reading the free Microsoft Integration Patterns PDF. It is pretty good thus far, but it is old and I figured that there might be a better option available. Any recommendations for books, b...

Same Presenter working with different Repositories

Hi All, You do you manage the same presenter working with different repositories using the MVP pattern? I just have multiple constructor overloads and the presenter simply uses the one that is suitable for the scenario. AddCustomerPresenter presenter = new AddCustomerPresenter(this,customerRepository); presenter.AddCustomer(); p...

Composite primary keys versus unique object ID field

I inherited a database built with the idea that composite keys are much more ideal than using a unique object ID field and that when building a database, a single unique ID should never be used as a primary key. Because I was building a Rails from end for this database, I ran into difficulties getting it to conform to the Rails conventi...

Is there anything inherently wrong with long object invokation chains?

I've organized my code so that the data is organized hierarchically. I find myself crawling up the tree using code like the following: File clientFolder = task.getActionPlan().getClientFile().getClient().getDocumentsFolder(); Now, since I'm not drilling down into the task object, I'm drilling up to its parents, I don't think I'm loos...

Are there any viable alternatives to the GOF Singleton Pattern?

Let's face it. The Singleton Pattern is highly controversial topic with hordes programmers on both sides of the fence. There are those who feel like the Singleton is nothing more then a glorified global variable, and others who swear by pattern and use it incessantly. I don't want the Singleton Controversy to lie at the heart of my qu...

Should Model make service calls to get data

We are build a website using MVC pattern. So far all the pages we built used models which had to operate on Reference data(which is cached when the website loads for the first time). But now we have reached that stage of the flow where we have to deal with Transactional data (which is specific to that flow). Till now we created model cla...

Accounting Software Design Patterns

Are there any good resources (books, authoritative guides, etc.) for design patterns or other best practices for software that includes financial accounting features? Specifically, where is good information about handling issues like the following: Internal representations of money quantities Internal representations of accounts, jour...

Should repositories implement IQueryable<T>?

I'm considering one of two IRepository interfaces, one that is a descendant of IQueryable and one that contains IQueryable. Like this: public interface IRepository<T> : IQueryable<T> { T Save(T entity); void Delete(T entity); } Or this: public interface IRepository<T> { T Save(T entity); void Delete(T entity); I...

What would a Log4Net Wrapper class look like?

Greetings, I have been looking for a logging framework for .net (c#) and decided to give log4net a go after reading up on a few question/answer threads here on stackoverflow. I see people mentioning over and over that they use a wrapper class for log4net and I am wonder what that would look like. I have my code split up into different ...