« December 2008 | Main | February 2009 »

January 2009 Archives

January 2, 2009

The Intangible Doppleganger

Can I resell my MP3's> - the post-sale life of digital goods

Can you own an idea? In the era of digital content, this is a question that seems to be occluded by questions of copyright and ownership, but resides fundamentally at the heart of the issue. Although it is understood that the creator holds copyright with regards to the content created, the question of ownership is much murkier when content is duplicated for mass consumption. Who owns those duplicates? What rights are extended to the purchasers when content comes into their possession? Do they have resale rights? At what point does the original content creator relinquish their rights to the purchaser, if ever?

These questions highlight the difficulty of assigning ownership and possession to the intangible. Tangibility or the lack thereof is digital media's Achilles heel. The problem is that by its nature a tangible product or commodity is obviously limited in how many copies can be made of it. This is not true for digital goods. The simple act of transmission implies that it is being duplicated. A physical commodity does not have this characteristic. It can be resold, borrowed, but it is not duplicated in the process. In essence, tangibility is a counter agent to duplicability.

If we look at the definition of the word counterfeit:

... is an imitation that is made usually with the intent to deceptively represent its content or origins.

It is rooted in the physical nature of a commodity. Can the term "counterfeit" be applied to digital media when a copy is as perfect as the original? Does it deceptively represent its content? I think not.

There are those that will argue that media can be counterfeited. CDs, DVDs, books, can all be duplicated. This is true, but what is actually being counterfeited - the medium which delivers the content or the content itself? Ultimately, physical artifacts serve as simple distribution mechanisms. They only serve as repositories for the ideas/content they transport. This leads to a more accurate definition of media - as an amalgamation of physical distribution mechanism and content.

Most of our consumer rights focus on this the tangible asset as the focus of copyright. Once you remove the distribution mechanism out of the equation however and are left with dissociated content, what you actually own is an idea - a cultural meme without physical constraints. Can something this ephemeral ever be constrained to individual ownership?


January 12, 2009

RailRoad II

Here are a few additional notes regarding my experiences with Ruby on Rails. Although there is veritable dearth of information on these topics, the difficulty as ever lies in having a single consolidated reference for these issues. At best, documentation on the web is complete with examples and thoughtful explanations; at worst, it is completely misleading and full of uninformed assumptions.

Required database.yml parameter : database

The database.yml file requires the database : parameter in order to establish a valid connection to the database for a given user. This parameter was not present in earlier versions of the database.yml configuration file. See below for more details documentation regarding the PostgreSQL connection adapter parameters.

Database Adapters: pg versus postgres

At the time of writing this (against rails 2.2.2), there still seems to be a preference in the Rails framework for the pg driver over the postgres driver. Without the pg driver installed, the following error is displayed to the user :

/Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:74:in `establish_connection': Please install the postgresql adapter: `gem install activerecord-postgresql-adapter` (no such file to load -- pg) (RuntimeError)
	from /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:58:in `establish_connection'
	from /Library/Ruby/Gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:53:in `establish_connection'
	from /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:392:in `initialize_database'
	from /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:139:in `process'
	from /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in `send'
	from /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/initializer.rb:112:in `run'
	from /Users/mel/Documents/Workspace/vuespace/src/config/environment.rb:13
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from /Library/Ruby/Gems/1.8/gems/rails-2.2.2/lib/commands/generate.rb:1
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
	from /Library/Ruby/Site/1.8/rubygems/custom_require.rb:31:in `require'
	from ./script/generate:3
aleph:src mel$ gem install activerecord-postgresql-adapter
ERROR:  could not find gem activerecord-postgresql-adapter locally or in a repository
aleph:src mel$ sudo gem install activerecord-postgresql-adapter
Password:
ERROR:  could not find gem activerecord-postgresql-adapter locally or in a repository
aleph:src mel$ sudo gem install activerecord-postgresql-adapter
ERROR:  could not find gem activerecord-postgresql-adapter locally or in a repository
aleph:src mel$ sudo gem -r install activerecord-postgresql-adapter
ERROR:  Invalid option: -r.  See 'gem --help'.
aleph:src mel$ sudo gem install -r activerecord-postgresql-adapter
ERROR:  could not find gem activerecord-postgresql-adapter locally or in a repository

To install the correct the correct pg gem, use the following command:

# sudo env ARCHFLAGS="-arch i386" gem install pg

There seems to be a version difference between the two difference postgres adapeters : pg (0.7.9.2008.10.13) versus postgres (0.7.9.2008.01.28). Only time will tell if this will lead to framework incompatibilities.

ActiveRecord

To use the scaffolding in any meaningful manner requires a clear object model that can be used to represent system objects. The ActiveRecord::Migration class provides detailed usage information that is required to generate these classes and the associated database types. However, details such as the rails type to database type mappings are not easily found in Rails API. The following links highlight the most important features of ActiveRecord objects which will hopefully allow more informed use of this fundamental Rails object.

Object Associations

As ever, the initial challenge when creating an application is to create an object model that reflects the system being designed without imposing unnecessary limitations. There are a number of relationships that can be modeled through Rails, but it is important to understand both the usage and limitation of these mechanisms.

  • Rails only supports Single Table Inheritance - By default only Single Table inheritance is supported by Rails. Essentially, different subclasses are represented by a :type field in the database table. To avoid confusion, treat type as a Rails keyword an only use it when you want to model Inheritance.

  • Polymorphism is supported through the :has_many :has_one/ :as mechanism - common functionality can be shared amongst objects by implementing an interface. This requires the implementing object to have interface_id:integer and interface_type:string columns within their database models.

  • The difference between :has_one and :belongs_to is largely where the foreign key resides. - The :belongs_to implementation should have the corresponding foreign key to the referenced object.

  • Many-to-many relationships can be modeled in a number of ways. Direct relationships can be modeled using has_and_belongs_to_many. If the association needs to be manipulated independently, the has_many :through relationship will do provided a join table is created to associate the two models.

  • Secondary associations using :through. Both the has_one and has_many associations support secondary references through intermediate objects.

Object Hierarchies

There are built-in mechanisms with Rails to model ordered lists, trees, and hierarchies.

  • :act_as_list - allows a collection of object to function as an ordered list. This requires a position column within the model.
  • :act_as_tree - allows a collection to behave as a tree. Requires the parent_id column within the model.
  • :act_as_nested_set - allows a collection to behave as a hierarchy. The advantage over :act_as_tree is that individual nodes can be retrieved with their dependent objects. This model requires the use of the following columns : parent_id, lft, rgt.

Validations

Data sanitation is paramount to preventing a whole host of database injection attacks. Always assume that any publicly submitted data can be used to compromise the system. To mitigate these types of attacks, ActiveRecord supports validation of conditions and fields (see above). It is highly recommended that validations be exercised in the testing framework to ensure their proper functioning.

January 18, 2009

Professional Developer Tools OS X

There are just some tools that make life easier. Although I'm a self proclaimed CLI junkie, I think that adhering to fundamentalist attitudes only leads to atrophy. To that end, I'd like to suggest a couple of tools that I grudgingly have to admit are better than their command line equivalents. Its not these tools should be used without knowledge of their CLI counterparts; it's just that having graphical equivalents somehow refines their usage and reduces cognitive resistance when you're in the Flow.

Cornerstone

I can't say enough about Subversion, but trying to keep track of changes between commits and doing diff comparisons with your working set versus the last revision is nothing short of a PITA. Thankfully, there is mature, stable graphical Subversion client for OS X - Cornerstone. It does a great job of abstracting various Subversion operations and does not suffer from extreme featuritis. Give it a try if your tired of looking up man pages to get just the right svn syntax.

Araxis Merge

While diffing files is old hat, the output is just barely human readable. Too much effort is expended by the user trying to visually grep the output. They say a picture is worth a thousand words, in the in spirit of "Ut pictura poesis" I would have to agree when using a visual diff tool. Having side by side comparisons greatly improves the ability to use diffs in a more coherent manner. Thankfully, Araxis has ported their flagship Merge tool to OS X. Like Cornerstone, the features are implemented with minimal clutter. This allows it to integrate cleanly into an XCode based work flow. With its seemless integration with Cornerstone, checking working copy diffs to a source code repository can't get any easier.

O'Reilly Safari

Do your self a favor and forget the forest of books that inevitably become obsolete and sign up for a Safari subscription. Technical books have a limited shelf life. Prevent become antiquated and get the latest documentation without the hassle of having to lug around a dead tree. It's not that I don't like physical books, but the rate at which technical documentation evolves makes it unrealistic to have a well stocked reference library without having to spend a fortune. Combined with the BookBag iPhone app, you can have your cake and eat it too.


About January 2009

This page contains all entries posted to Z1R0 in January 2009. They are listed from oldest to newest.

December 2008 is the previous archive.

February 2009 is the next archive.

Many more can be found on the main index page or by looking through the archives.

Creative Commons License
This weblog is licensed under a Creative Commons License.