design-patterns

Patterns for implementing field change tracking.

Hi all For one of my recent projects, I had to implement field change tracking. So anytime the user changed a value of a field, the change was recorded in order to allow full auditing of changes. In the database, I implemented this as a single table 'FieldChanges' with the following fields: TableName, FieldName, RecordId, DateOfChange,...

Patterns to implement this grammar into C# code

Hey guys, I'm creating this little BNF grammar and I wanted to <template>::= <types><editors> <types>::= <type>+ <type>::= <property>+ <property>::= <name><type> <editors>::= <editor>+ <editor>::= <name><type>(<textfield>|<form>|<list>|<pulldown>)+ <textfield>::= <label><property>[<editable>] <form>::= <label><property><editor> <list>:...

Repository Pattern Standardization of methods

All I am trying to find out the correct definition of the repository pattern. My original understanding was this (extremely dumbed down) Separate your Business Objects from your Data Objects Standardize access methods in data access layer. I have really seen 2 different implementation, and there are no formal examples online, the on...

DB Strategy for inserting into a high read table (Sql Server)

Looking for strategies for a very large table with data maintained for reporting and historical purposes, a very small subset of that data is used in daily operations. Background: We have Visitor and Visits tables which are continuously updated by our consumer facing site. These tables contain information on every visit and visitor, ...

Object Events, how do are they implemented

Events are really awesome, and I wouldn't know what I would do without them, but they're a mystery to me. I'm talking about events in a sense, a function(s) is called if a property, or value, a special event happens. I have only the vaguest idea how these actually work. I know it's an observer pattern, but I don't truly know how it wor...

Implementation/interface inheritance design question.

I would like to get the stackoverflow community's opinion on the following three design patterns. The first is implementation inheritance; the second is interface inheritance; the third is a middle ground. My specific question is: Which is best? implementation inheritance: class Base { X x() const = 0; void UpdateX(A a) { y_ = g(...

Auto increment with a Unit Of Work

Context I'm building a persistence layer to abstract different types of databases that I'll be needing. On the relational part I have mySQL, Oracle and PostgreSQL. Let's take the following simplified MySQL tables: CREATE TABLE Contact ( ID varchar(15), NAME varchar(30) ); CREATE TABLE Address ( ID varchar(15), CONTACT_ID va...

Application Design: Single vs. Multiple Hits to the DB

I'm building a service that performs a set of configured activities based on the type of request that it receives. Each activity involves going to the database and retrieving/updating some kind of information. The logic for each activity can be generalized and re-used across different request types. The activities may need to particip...

C# Static constructors design problem - need to specify parameter

I have a re-occurring design problem with certain classes which require one-off initialization with a parameter such as the name of an external resource such as a config file. For example, I have a corelib project which provides application-wide logging, configuration and general helper methods. This object could use a static constructo...

Design pattern for data entry forms with LINQ2SQL

I am about to start a new winforms data entry application, it already has the database designed which I am comfortable with. I was going to use LINQ2SQL to access the tables to keep things type safe but am now wondering about design patterns, something I am just getting into. Since LINQ is giving me objects to use should I still create...

Configuration and Model-View

I am using the Model-View pattern on a small application I'm writing. Here's the scenario: The model maintains a list of directories from where it can extract the data that it needs. The View has a Configuration or a Setting dialog where the user can modify this list of directories (the dialog has a JList displaying the list in addition ...

Pattern for resource reservations

Is there some kind of design pattern to handle resource reservations? The problem I'm trying to solve basically could be described with a restaurant situation where an certain amount of clients can reseve some tables (resources) for certain time frames. ...

How to handle payment types with varying properties in the most elegant way.

I'm using ASP.NET MVC 2. Keeping it simple, I have three payment types: credit card, e-check, or "bill me later". I want to: choose one payment type display some fields for one payment type in my view run some logic using those fields (specific to the type) display a confirmation view run some more logic using those fields (specifi...

book with good examples for each implementation?

i've read about design patterns and it seems that there are a lot of different design patterns to use. i wonder if there are some books that acts like a reference. "you want to build a framework, then consider this, this and this pattern". also giving some examples. then jumps to another implementation eg. search engine and gives some ...

design pattern tools to use?

i have noticed that every area has some tools you can use to make things easier. eg. css = dreamweaver doctrine/propel = orm designer // you dont have to hardcore code schemas manually and remembering all the syntax/variables mysql = mysql workbench // the same etc. in this way you get aided and dont have to type things the hard wa...

free design patterns templates to use for Visual Paradigm?

i know that you can create your own design patterns and save them for later use. but i wonder if there are free templates you can download and use, eg. factory, singleton and so on. then you dont have to recreate/copy-paste and you will have accurate patterns. ...

Dynamic Object Initialization In JavaScript (just like PHP Reflection allows)?

Hi All, Using Reflection in PHP I can dynamically create a object like so $target = 'core_domain_Person'; $reflect = new ReflectionClass($target); $obj = $reflect->newInstance(); I would like to replicate this same concept in JavaScript is there a way to do this out of the box? Or is there a way to replicate what Reflection is doing?...

What does "program to interfaces, not implementations" mean?

One stumbles upon this phrase when reading about design patterns. But I don't understand it, could someone explain this for me? ...

Multiple leaf methods problem in composite pattern

At work, we are developing an PHP application that would be later re-programmed into Java. With some basic knowledge of Java, we are trying to design everything to be easily re-written, without any headaches. Interesting problem came out when we tried to implement composite pattern with huge number of methods in leafs. What are we tryin...

Design pattern for an object behaving differently when clicked, depending on a global state

I am using Unity3D for this question, but this is a general software engineering question. Entities (interactive objects) in Unity3D are built with components or behaviors. By putting together behaviors together, you define the exact behavior of the object. I am pondering how to have different objects react differently, when clicked, b...