Archive

Posts Tagged ‘Design Patterns’

ORM patterns which are ‘Invisible to the eye’

February 10th, 2010 Frank No comments

The more I work with design patterns*, the more I come to respect them as a design tool. For grad-school, I’m writing a DVCS and I needed some information on ORM patterns. While I’m not sure if this is a real term, I Googled it and found a great article on Invisible to the eye.

The article can be found at: http://giorgiosironi.blogspot.com/2009/08/10-orm-patterns-components-of-object.html

For my project, I’m mainly interested in the Data Mapper and the Table Data Gateway. Both are patterns from Martin Folwer’s book Patterns of Enterprise Application Architecture.

While I’ve not read the book yet, I think I might… After classes…. Anyway, I mostly wanted to share on the 10 ROM patterns listed at Invisible to the eye.

*If  you’d like a good intro to design patterns, I love Head First Design Patterns

Invisible to the eye

Object Relational Mapping > A ‘Design Pattern’ Solution

April 23rd, 2009 Frank No comments

There has been a lot written about Object Relational Mapping — or ORM but I came up with a design that I intend to apply to my own projects and wanted to publish and share the idea.

This idea was my own; when I wrote this I hadn’t seen this idea published elsewhere. However, the idea is derived from a set of very common design patterns. It would not surprise me in the least if another designer/developer already implemented a similar idea. However, I digress…

Preliminary Information

The ORM is a method to take data stored in a relational database-type structure and represent the same data as object orientated classes.

I feel that the ten thousand foot level the idea is straight-forward. Assume that we are using the MVC (Model-View-Controller) design pattern for your application. Furthermore, lets assume that we’ve got a simple object to which will represent our Model (part of the MVC).

Lets assume our model object is the following:

Data Model Example

Data Model Example

The idea is to take a mix of the strategy and the decorator pattern. The strategy pattern is a design pattern that allows you to define the interface for an algorithm which can be different depending on the implementation.

The idea of the decorator pattern is to simply add responsibility to a class (through inheritance). My ORM is a combination of the two patterns.

The Design – a Class Diagram

The pattern is simple.

Diagram with OR Design

Diagram with OR Design

We use the interface to represent the ability to write out or read in with the Encoder. You’d implement the interface on to a derived class of the target class.

Why do we implement this interface on a derived class? Strictly speaking, we don’t have to. Though, this is intentional and part of the pattern that I’m trying to describe. This is the part of the strategy pattern working for us. This would allow us to implement different encoders for different types of storage mediums.

This means that we could create a set for SQL server, XML and perhaps a web service if so inclined.

Usage

The usage, I imagine, to be simple. Setup your basic interface and then derive a target class and apply the interface. Implement your interface to write the object and read the object to/from your storage medium.

One point of doing this, is that if a model object contains a collection  or an instances of another model object, you can use this interface to write and retrieve that object.

An Example

In all honesty, I had hoped to put together a simple but working example of this. I’ve not had the time and I’ve been sitting on this post for a while. I wanted to get this post out. I still hope to get together a simple example but for the time being the description is all I’m posting.

If you have specific interest in an actual implemention of my concept here, please leave a message below. The interest will help modivate me to take the time to get something together.

“Windows OOP” vs. “Cocoa MVC”

March 23rd, 2009 Frank No comments

While I don’t agree with the following article that windows developers (the author is looking at .NET, I believe) can’t implement the MVC design pattern, I do agree with the article that MVC is probably a better way to implement one’s interface. I want to direct your attention to the following article.

http://www.cimgf.com/2008/07/29/cocoa-tutorial-windows-oop-vs-cocoa-mvc/

Programming Books To Read

January 29th, 2009 Frank No comments

Programming books are elusive for me. I often ry to start reading them and 99.9% of the time I end up not finishing the book… Even though, I usually will gt more than half way though the book. This is a very bad trend the I’m aiming to reverse this year. As I posted earlier, I’m currently reading Head First Design Patterns and am at the halfway point.

I intend to finish the book yet and I’m still doing good with reading it. I usually read after work for at least 20 to 30 minutes. It is usually good enough for me to cover about 5 pages. I’ve read the book for as long as 3 hours before but that isn’t possible to do every night… :-)

Several great bloggers have posted several book lists. I’m sure that most developers that have been following blogs are aware of them but as a reminder they are below. Check them out… How many of the books on their lists have you read? What would you add to their list and why?  (Leave a comment below, I’m really curious as I’m going to start building a list of books to read.)

http://www.hanselman.com/blog/SixEssentialLanguageAgnosticProgrammingBooks.aspx

http://www.codinghorror.com/blog/archives/000020.html

I specifically want to put Head First Design Patterns on their lists. I know that the Head First series can look a little silly (when simply flipping though the book), however I feel that the content is very well presented, is kept relevant and can hold your attention (this is very important to finishing the book as well as getting something out of it).

I know some might argue but that is my two cents.

Plans for The Open Source U

January 11th, 2009 Frank No comments

My plans for this site are not quite clear. I feel that I’ve got a very clear objective but the plan on how to achieve that objective is still a bit fuzzy.

As I describe in my about page my mission plan (for a lack of a better term) is:

Understand the design, architecture and implementation of certain major Open Source software for my personal and professional growth.

On this site, I do intend to walk though the dissection of certain open source software. Additionally, I’m going to walk though and explain by example certain design patterns as well as post example software.

Lately, my main focus has been software architecture. That is, how is software put together. This is as opposed to how certain functions work or operate. I’m looking at the high level of software design.

Head First Design Patterns Book Cover

Head First Design Patterns Book Cover

I’m currently reading Head First Design Patterns. I love the book and this book is probably the main reason for my interest in overall software architecture. The architecture is something that I’ve not spent much time on in my career as I mostly put together software segments rather then the overall software.

Recently, I’ve become responsible to design the architecture of a existing project that is in terrible need of being re-done. I hope to learn things from the book and from the internet to help me in this effort.

As for the software dissection side of things, I’m thinking of starting with Firefox. In fact, I’ve actually started as I’ve always wanted to dissect Firefox; it intrigues me. A little bit ago, I posted a question on Stack Overflow titled: How Does FireFox Work? Source Code Walk Through?[^]

Check out the post for some of the responses I got. The one that is marked as the answer is what I’ve decided to follow.

I hope to start writing up my findings and understandings later this week. Though, with work my schedule can get dicey.