Sunday, February 04, 2007

Foreign Keys and Views!

In their Beginning Ruby on Rails E-Commerce, Christian Hellsten and Jarkko Laine use MySQL-specific SQL code to add foreign key constraints with cascading deletes to some of the tables defined using the ActiveRecord concepts. Having done so, and in order to enforce these constraints, they resort to incorporating code, in the "view" components of their application for adding objects to the tables. These additions to the already generated views ensure that the new objects posted to the database do not violate the foreign key constraints. I'm really not sure if there are other ways to define such constraints within Rails so that one does not need to use DB-specific SQL which obviously cannot be digested by ActiveRecord database migration tools. If there's no such alternative, I could be tempted to conclude that ActiveRecord has features that are mis-matched to some of the assumptions behind normalization principles of relational algebra. However, I should not be this judgmental yet. I've just begun to learn about Rails.

Tailing a log

To tail a log file during tests of a Rails application, you can try "tail -f logs/test.log". If you do a "rake" of your project, this will show the beginning and rollback of various transactions against the test database.

About Rails

Beginning Ruby on Rails E-Commerce, published by APRESS, provides a decent, practical introduction to Rails programming model, with a very useful example than runs through the book.

Wednesday, January 31, 2007

Apache / Derby and Java DB

All the current uses of Apache / Derby (shipped as Java DB with the JDK, beginning with JDK 6) are truly astounding.

Tuesday, January 30, 2007

Development, The Agile Way

Scrum is a light-weight agile software development process composed of Sprints, during which the next release of a system is being developed. To read about Scrum see ControlChaos and MountainGoatSoftware. (MountainGoatSoftware's Scrum page summarizes things quite nicely in the first paragraph on the top.)

Monday, November 13, 2006

Sun Microsystems Inc. Opens Java

See my posts here and here.

Friday, September 08, 2006

On Web 2.0

Here is what a recent Financial Times article says about Web 2.0 technologies:

The principle behind Web 2.0 is that millions of internet users come together in cyberspace to be part of online communities. This is driven by the ubiquity of the internet – a billion people are now online and many have access to relatively cheap high-speed internet.

There has also been a generational shift. Young people have grown up with the web and are willing to socialise and share personal information online.

Monday, September 04, 2006

Brevity and Ruby

Code brevity can be a saving grace.
Containers, blocks, and iterators are core concepts in Ruby. The more you write in Ruby, the more you'll find yourself moving away from conventional looping constructs. Instead, you'll write classes that support iteration over their contents. And you'll find that this code is compact, easy to read, and a joy to maintain.
Dave Thomas, Programming Ruby: The Pragmatic Programmers' Guide, 2nd Edition, 2005 (page 57)

Monday, August 07, 2006

Learning to Program -- Code Sample

Here's the Ruby code for the second exercise in "Mixing it Up" chapter of Chris Pine's Learn to Program

puts '=====Your favorite number======='
puts 'What\'s your favorite number?'
fnum=gets.chomp
puts 'Have you considered changing your favoriate number to '+x=(fnum.to_i+1).to_s
puts 'Why not choose the number '+x+' which is not only bigger but also better!'