CSC/ECE 517 Fall 2010/ch2 2a mw: Difference between revisions

From Expertiza_Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 8: Line 8:
All too often programmers are faced with the challenge of persisting objects from their program into a datastore.  Custom code is created for this purpose that can be complex or difficult for others to understand as well as not seem natural.  Applications that are designed to persist data have the need to know how the objects correspond to the information stored in these database tables.  [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails], first released in 2005, is able to provide a uniform method to help resolve these complicated issues without sacrificing function by using ActiveRecord (AR).  AR is a persistence engine that comes as part of Ruby on Rails.  It creates a 'persistable' domain model from business objects and database tables, where logic and data are presented as a unified package [http://en.wikipedia.org/wiki/ActiveRecord#Ruby 3].  AR is admired for its simplistic and elegant approach of removing these levels of complexity.  It allows for a 'pluggable' solution to many different popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle.  Ruby, Ruby on Rails, and ActiveRecord continue to grow in popularity due to not only the curiosity of programmers but their ability to improve function and feature sets while maintaining the initial intent of the language, “trying to make Ruby natural, not simple” -- Yukihiro “matz” Matsumoto [http://www.ruby-lang.org/en/about/ 7].   
All too often programmers are faced with the challenge of persisting objects from their program into a datastore.  Custom code is created for this purpose that can be complex or difficult for others to understand as well as not seem natural.  Applications that are designed to persist data have the need to know how the objects correspond to the information stored in these database tables.  [http://en.wikipedia.org/wiki/Ruby_on_Rails Ruby on Rails], first released in 2005, is able to provide a uniform method to help resolve these complicated issues without sacrificing function by using ActiveRecord (AR).  AR is a persistence engine that comes as part of Ruby on Rails.  It creates a 'persistable' domain model from business objects and database tables, where logic and data are presented as a unified package [http://en.wikipedia.org/wiki/ActiveRecord#Ruby 3].  AR is admired for its simplistic and elegant approach of removing these levels of complexity.  It allows for a 'pluggable' solution to many different popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle.  Ruby, Ruby on Rails, and ActiveRecord continue to grow in popularity due to not only the curiosity of programmers but their ability to improve function and feature sets while maintaining the initial intent of the language, “trying to make Ruby natural, not simple” -- Yukihiro “matz” Matsumoto [http://www.ruby-lang.org/en/about/ 7].   


ActiveRecord uses a [http://en.wikipedia.org/wiki/Single_Table_Inheritance Single Table Inheritance] to allow for inheritance capabilities and provides a set of macros for association relationships between classes of objects, such as belongs_to, has_one, has_many, etc.  AR is not only a component of the [http://en.wikipedia.org/wiki/Model-view-controller Model view-controller] for Ruby on Rails but it is also a standalone ORM package for Ruby itself.  Other languages have been able to learn from AR and have tried to add this for themselves.  Let’s take a closer look at some other implementations that attempts to duplicate AR’s elegance.
ActiveRecord uses a [http://en.wikipedia.org/wiki/Single_Table_Inheritance Single Table Inheritance] to allow for inheritance capabilities and provides a set of macros for association relationships between classes of objects, such as belongs_to, has_one, has_many, etc.  AR is not only a component of the [http://en.wikipedia.org/wiki/Model-view-controller Model view-controller (MVC)] for Ruby on Rails but it is also a standalone ORM package for Ruby itself.  Other languages have been able to learn from AR and have tried to add this for themselves.  Let’s take a closer look at some other implementations that attempts to duplicate AR’s elegance.


==Other Examples of Language Extensions==
==Other Examples of Language Extensions==
===ADO.NET Entity Framework===
===ADO.NET Entity Framework===
[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework], Microsoft's ORM, part of [http://en.wikipedia.org/wiki/.NET_Framework .NET] 4.0.  First developed in 2008, the Entity Framework tries to remove ORM mismatches that often plague conventional database oriented programs.  ADO uses an Entity data model (EDM) and an Entity-Relationship data model to define the Relationships associated to each Entity.  The EDM consists of a schema and a mapping specification.  The schema defines the data types from the entities and the mapping provides the connections between the database scheme and the conceptual scheme.
[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework], Microsoft's ORM, part of [http://en.wikipedia.org/wiki/.NET_Framework .NET] 4.0.  First developed in 2008, the Entity Framework tries to remove ORM mismatches that often plague conventional database oriented programs.  ADO.NET uses an Entity data model (EDM) and an Entity-Relationship data model to define the Relationships associated to each Entity.  The EDM consists of a schema and a mapping specification.  The schema defines the data types from the entities and the mapping provides the connections between the database scheme and the conceptual scheme. The Entity Framework has its own version of a query language called Entity SQL which continues to focus only on the conceptual entities and relationships as opposed to the actual database.  It also works with many popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle.


===Django===
===Django===
[http://en.wikipedia.org/wiki/Django Django], (ORM is included in Django framework) open source
[http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django], is an ORM included in Django open source framework for Python.  Django, which follows a MVC [http://en.wikipedia.org/wiki/Architectural_pattern_%28computer_science%29 architectural pattern], was originally released in 2005 with the primary goal of making complex, database driven websites easier to create and maintain.  Instilled in its principles are emphasis on rapid development, don’t repeat yourself, and reusability. It works with many popular databases available today to include: MySQL, SQLite, MS SQL Server, PostgreSQL, and Oracle.


===Enterprise Objects Framework===
===Enterprise Objects Framework===
Line 41: Line 41:
#[http://en.wikipedia.org/wiki/ActiveRecord#Ruby ActiveRecord Ruby]
#[http://en.wikipedia.org/wiki/ActiveRecord#Ruby ActiveRecord Ruby]
#[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework]
#[http://en.wikipedia.org/wiki/ADO.NET_Entity_Framework ADO.NET Entity Framework]
#[http://en.wikipedia.org/wiki/Django Django]
#[http://en.wikipedia.org/wiki/Django_%28web_framework%29 Django]
#[http://en.wikipedia.org/wiki/Enterprise_Objects_Framework Enterprise Objects Framework]
#[http://en.wikipedia.org/wiki/Enterprise_Objects_Framework Enterprise Objects Framework]
#[http://ruby-doc.org/docs/ProgrammingRuby/ Programming Ruby - The Pragmatic Programmer's Guide]
#[http://ruby-doc.org/docs/ProgrammingRuby/ Programming Ruby - The Pragmatic Programmer's Guide]
#[http://www.ruby-lang.org/en/about/ Ruby – A Programmers Best Friend]
#[http://www.ruby-lang.org/en/about/ Ruby – A Programmers Best Friend]
#[http://www.djangoproject.com/ Django Project]
#[http://msdn.microsoft.com/en-us/library/e80y5yhx%28v=VS.71%29.aspx ADO.NET]
#[http://developer.apple.com/legacy/mac/library/documentation/LegacyTechnologies/WebObjects/WebObjects_4.5/System/Documentation/Developer/EnterpriseObjects/DevGuide/EOFDevGuide.pdf Enterprise Objects Framework]

Revision as of 00:24, 17 September 2010

Introduction

In the previous article for which the link does not exist yet, we learn that metaprogramming is where the computer code interacts with other programs as data and performs many of these interactions at compile time rather than runtime. This built-in interaction allows the programmers to take advantage of these capabilities and focus their time on the rest of their program logic instead of the details of some of the lower level coding. In this article, we will take a closer look at one of the styles of metaprogramming referred to as language extensions for object-relational mapping (ORM) through examples and some comparisons of language extensions and tools.

Language Extensions

Language extensions for ORM have often been traditionally classified as design patterns or software tools used to perform basic create, read, update and delete (C.R.U.D.) operations on relational databases, that is, until recent new approaches such as ActiveRecord have grown in popularity. ActiveRecord is not just a design pattern it is an increase of function to the active record pattern approach by adding inheritance and associations. Examining ActiveRecord and other language extensions will allow for comparisons of the ease of programming using these language extensions verses the conventional database oriented systems approach.

Ruby and ActiveRecord

All too often programmers are faced with the challenge of persisting objects from their program into a datastore. Custom code is created for this purpose that can be complex or difficult for others to understand as well as not seem natural. Applications that are designed to persist data have the need to know how the objects correspond to the information stored in these database tables. Ruby on Rails, first released in 2005, is able to provide a uniform method to help resolve these complicated issues without sacrificing function by using ActiveRecord (AR). AR is a persistence engine that comes as part of Ruby on Rails. It creates a 'persistable' domain model from business objects and database tables, where logic and data are presented as a unified package 3. AR is admired for its simplistic and elegant approach of removing these levels of complexity. It allows for a 'pluggable' solution to many different popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle. Ruby, Ruby on Rails, and ActiveRecord continue to grow in popularity due to not only the curiosity of programmers but their ability to improve function and feature sets while maintaining the initial intent of the language, “trying to make Ruby natural, not simple” -- Yukihiro “matz” Matsumoto 7.

ActiveRecord uses a Single Table Inheritance to allow for inheritance capabilities and provides a set of macros for association relationships between classes of objects, such as belongs_to, has_one, has_many, etc. AR is not only a component of the Model view-controller (MVC) for Ruby on Rails but it is also a standalone ORM package for Ruby itself. Other languages have been able to learn from AR and have tried to add this for themselves. Let’s take a closer look at some other implementations that attempts to duplicate AR’s elegance.

Other Examples of Language Extensions

ADO.NET Entity Framework

ADO.NET Entity Framework, Microsoft's ORM, part of .NET 4.0. First developed in 2008, the Entity Framework tries to remove ORM mismatches that often plague conventional database oriented programs. ADO.NET uses an Entity data model (EDM) and an Entity-Relationship data model to define the Relationships associated to each Entity. The EDM consists of a schema and a mapping specification. The schema defines the data types from the entities and the mapping provides the connections between the database scheme and the conceptual scheme. The Entity Framework has its own version of a query language called Entity SQL which continues to focus only on the conceptual entities and relationships as opposed to the actual database. It also works with many popular databases available today to include: MySQL, SQLite, SQL Server, PostgreSQL, and Oracle.

Django

Django, is an ORM included in Django open source framework for Python. Django, which follows a MVC architectural pattern, was originally released in 2005 with the primary goal of making complex, database driven websites easier to create and maintain. Instilled in its principles are emphasis on rapid development, don’t repeat yourself, and reusability. It works with many popular databases available today to include: MySQL, SQLite, MS SQL Server, PostgreSQL, and Oracle.

Enterprise Objects Framework

Enterprise Objects Framework, Mac OS X/Java, part of Apple WebObjects

Programming using Language Extensions

Several language extensions have been introduced in previous sections of the article show some examples and comparisons of them.


Programming using External Tools

Which is better? Language Extensions or External Tools

Conclusion

What’s Next?

2b. Software for CRC cards. Software packages support the creation of CRC cards, and other artifacts of o-o design. Compare them on ease of use, and also look for evidence of how much easier they make the overall design task.


References

  1. Comparison of web application frameworks
  2. List of object-relational mapping software
  3. ActiveRecord Ruby
  4. ADO.NET Entity Framework
  5. Django
  6. Enterprise Objects Framework
  7. Programming Ruby - The Pragmatic Programmer's Guide
  8. Ruby – A Programmers Best Friend
  9. Django Project
  10. ADO.NET
  11. Enterprise Objects Framework