A Simple Application with the Design Patterns Table Data Gateway, Domain Model, Factory Method and Singleton

Daneesha Bartholomeusz
2 min readFeb 16, 2022

[Note: You can find the files on my Github repository here. This application will be useful for interview processes. I don’t have a problem with anyone copying this code and enhancing it for such purposes. All the files, including the Stored Procedures are checked into the repository.]

I wanted to write some simple applications with design patterns applied. This post is a start.

In this application (which is a narrowed down version of a much bigger application I’m developing) I have applied the patterns Table Data Gateway, Domain Model, Factory Method and Singleton.

There’re 3 tiers to this application. Data Access, Domain and Presentation.

To the Data Access layer I have applied Martin Fowler’s design pattern Table Data Gateway. To the Domain layer I have applied Martin Fowler’s design pattern Domain Model.

The objects in this application are Links and Quotes. This application manages a person’s record of links and quotes they save.

Data Access layer has two classes. Link Gateway and Quote Gateway which references the tables Link and Quote in the database.

Here’s how the Link table looks like.

Here’s the Quote table.

I’m using Stored Procedures for data access. (You can find the Stored Procedures in my Github repository).

The Domain layer has an interface IItem. Which is implemented by abstract class Item. Which in turn gets extended by Link and Quote classes.

As the Factory Method classes you’ll find these references. Product — IITem, Concrete Product s— Link and Quote, Creator — Page, Concrete Creators — LinksTab, QuotesTab.

The application consists of two tabs which display links and quotes in turn. You can view the links and quotes, add new ones and update or deleted existing ones.

I have added several User Controls. Each of these sets of inputs are a User Control. They’re called LinkView and LinkViewAddNew. (You can have User Controls for the Quotes similarly.)

Unfortunately I haven’t fully completed this project. For that it’ll take more time and I have to move on to other design patterns which are so many. However I have given all the code necessary for enhancing the application.

Here is the Github repository where you’ll find all the files.

Thanks!

-Daneesha

--

--