Sunday, March 9, 2014

Design Pattern: Active Record

Introduction

Active Record is a design pattern often used to as a means to access information stored in relational databases. Rails explicitly implements a class called ActiveRecord which models this design pattern. This ties back into the Rails idea of Convention over Configuration because Rails exposes its models as classes with methods that allow easy manipulation and access of data fields within a give database table.

Pro

This allows the model to implement behavior that the controller and view shouldn't be bothered with in a clean and scaleable way.

Con

This design pattern might not work well for non-relational databases like MongoDB. However, I do not have any experience with how MongoDB stores and interacts with its data types/ objects so this may not be a valid con to include.

No comments:

Post a Comment