I am looking into designing a system where users build a template item and then create many instances based on this template.They then need to be able customise each instance but I also need for them to be able to make changes to the template and have all instances updated. These items are fairly complex, each consisting of many components that will be stored in numerous database tables.

I see two implementation paths.

  1. Store complete copies of the templates to create the instances and migrate updates to the instances.
  2. Store records only for the changes and build each instance from a combination of the template and instance changes.

I believe the first option would create a lot of unneeded extra data however the 2nd way introduces complexities in querying the data.

This seems like it has probably been implemented many times before but I am having trouble finding much reading material. Are there common names for data models or pattern options used in implementations of such systems?

Any advice on benefits or pitfalls of each option, other options, or implementation guidance would be useful too.


Sorry I may not have been clear. I was looking more for a name for the general architecture not a design pattern. It is the end users who create instances not developers.

For example the system might allow users to define templates to model manufacturing processes of many items. Then at different sites where facilities or requirements are different, the end user would would use one of these templates to define a process specific for that site. Things will be added, removed and modified for each site.

I believe I will go with option two mentioned above - storing only delta changes, not complete copies.

  • Like a "Country"-template But the template won't have to take care if it's Hungary or Brazil? Looks like Factory pattern to me, Feb 28, 2012 at 15:36

4 Answers 4


I think what you are looking for is the Abstract Factory Pattern.

Consider phone numbers:

Phone numbers have a particular rule on which they get generated depending on areas and countries. If at some point the application should be changed in order to support adding numbers form a new country, the code of the application would have to be changed and it would become more and more complicated.

In order to prevent it, the Abstract Factory design pattern is used. Using this pattern a framework is defined, which produces objects that follow a general pattern and at runtime this factory is paired with any concrete factory to produce objects that follow the pattern of a certain country.



When I first read your question, GoF's Prototype Pattern came to mind.

However, in general design patterns apply to relatively low levels (most of them involve relationships between just few classes). Also when you use patterns, you only use the idea but implement your own code. That idea simply lets you implement your code faster because you are coding something that has already been thought out to some degree by someone else.

What you are looking for is not really a design pattern because the scale/scope of what you are achieving to do is much larger. And as far as I understand, you are actually curious if someone out there has something that does what you want. In other words, you are looking for a framework.

I'm not aware of any generic frameworks that you could reuse, but if you are curious if anyone out there did anything similar, I think Microsoft's Dependency Property framework that is part of WPF fits the bill. Each object, which has to derive from DependencyObject root class, has a set of properties and in some cases these sets are very big. Property values can come from object itself (what you call instance values), or they can come from styles, templates, themes, or system defaults.

Dependency objects implement your option (2). They only store locally what was modified on that instance and each property value is calculated at runtime by walking a set of sources where the property value could possibly come from.

Although I never thought about it, but I guess you could derive your own set of classes from DependencyObject and take advantage of the entire framework while not coding anything WPF-specific.


If I understand you correctly, user creates few templates, then based on some template creates multiple "usefull" instance that change or add something and later changes the template and wants this change to be reflected in all instances based on such template.

I would call it data inheritance.

Because its like creating base class, inheriting it and then changing base class.


The word you are looking for is instantiating

e.g. I am Instantiating this template with this parameter.

Along with templates, also look up generics for more reading material.

  • The word "instantiation" doesn't really speak to the intricacies of the OP's scenario. He's actually looking for a software pattern, not a vocabulary lesson. Feb 28, 2012 at 16:04
  • @RobertHarvey "Is there a name for this pattern" - Yes there is, it called instantiating. So yes OP did ask for a vocab lesson. Try taking a comprehension lesson yourself.
    – NWS
    Feb 28, 2012 at 19:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.