Displaying Google Maps in the Android Emulator

Google Emulator - Embed Web maps.
This is a quick and dirty way to display Google Maps in Android. Its really not that hard and after learning how to do this you can easily start thinking about how you want to architect your Android App using the different bundles that come with google (Maps are only one of them!!).

Fire up Eclipse / Create your Project

Easily set up your own project here => I am using GANEYMEDE eclipse, which is the international version of the popular Eclipse IDE. If you don’t have the Android SDK you can download it from here and you can download Eclipse from here.Also make sure you have the latest version of Java => download it from here.

Continue reading

Active Record in Rails

Any web developer will know how important a database and its relationship can be to their web application. With that being said i would like to introduce you to Active Record.  Active Record is a Ruby library that allows your Ruby programs to transmit data and command to and from various data stores, which are usually relational databases.  You can also say that Active Record allows Ruby to work with databases.

Brief History behind Active Record

Active Record is a design pattern originally published by Martin Fowler in his book Patterns of Enterprise Application Architecture.  David Heinemeier Hansson (the creator of the Rails framework) took the concepts laid out by Mr. Fowler and implemented them as a Ruby library called Active Record.

Active record has been released with the Rails framework to the public and is also available as a part of the core bundle with its own Ruby Gem.

Active Record and the ORM Pattern

At the core of Active Record is object relational mapping or “ORM.”  These relational databases can be represented well by object based code; if we look at an example of a dummy accounts table in a typical database it would look like this:

Accounts table
     ID field (integer; auto-incremented; primary key)
     Username field (text type field)
     Password field (text type field)

If we look at the Active Record Account class (or model) it would look something like this:

If we look through our Rails code, we could possible create instances of different account objects like below:

Active Record Differs from other ORM Libraries

Active record out of the box makes a number of configuration assumptions, without requiring any outside configuration files or mapping details.  The previous example takes advantage of Active Record Assumptions, so we are not required to to configure or set up any specific instructions.  This is unlike many ORM libraries such as Java’s Hibernate.

MVC Concepts and Active Record

Active Record is most famous as being an important part of the Ruby on Rails framework, and is being copied by many other frameworks such as Code Igniter.    What MVC does it that it breaks code into logical groupings and programs into logical functional groupings.  With Rails, the model section is generally your Active Record classes and other data-descriptive or datacommunication code. The view section remains primarily for the user interface, which tends to be a heavy dose of HTML in most Rails applications.

CRUD Database Transactions and Active Record

Ususally there are four tasks one can perform when working with databases, and as a group are referred ot as CRUD. 

  1. (C): Creating 
  2. (R): Retrieving
  3. (U): Updating
  4. (D): Deleting

There are many more options to that we can consider here, but the above is the most generic or the most common.

How the Active Record Library applies to Ruby code

What you have to remember is when working with Active Record is that its all Ruby code.  Anything you do with Ruby objects (inheritance, overriding methods, etc etc) can also be done with Active Record objects. The whole idea is to represent database records and objects, but they really are two separate things; Ruby onjects and database records.

Active Record:  The smart choice

There are many reasons why Active Record is the smart choice.  One is its easy to install, simple to write and read, and also a full feature object based code.  If you look below at the benefits of Acitve Record, there is no doubt that this library is worth learning about.

  • Simplified configuration and default assumptions (Convention over Configuration).
  • Associations among objects.
  • Automated mapping b/w tables and classes and b/w columns and attributes.
  • Data Validations.
  • Callbacks
  • Inheritance hierarchies.
  • Direct manipulation of data as well as schema objects.
  • Database abstraction through adapters.
  • Logging support.
  • Migration support.
  • Active Record integrated in other emerging frameworks like Merb.

Is Ruby the fastest growing language on the web?

There is alot of hype sorrounding Ruby and Ruby on Rails.  As a fanboy of Ruby and gearing myself up to start developing Ruby on Rails apps I am always trying to inform myself of the future of this awesome programming language.

SAN FRANCISCO — With Java now a very mature language with millions of developers, the Ruby language is among the fastest growing programming languages, and the number of Ruby developers is expected to quadruple over the next five years.In a panel discussion at the Sun’s CommunityOne day preview to JavaOne here on May 5, Mark Driver, an analyst at Gartner, said, “There are under one million professional Ruby developers now and we’re projecting there will be four million plus by 2013.” Driver later told eWEEK that Gartner’s research shows “strong interest” in Ruby and that the percentage of developers that will be creating commercial systems versus those that are hobbyists will be even greater for Ruby than for other languages. “Ruby will be more interesting to commercial developers,” he said.

The panel discussion featured a variety of participants, including some core contributors to the JRuby project and a trio of Ruby developers. In addition, while broaching the issue of Ruby’s growth, the session also at times compared Ruby to other languages such as PHP and Java itself. JRuby is an implementation of Ruby that runs on the JVM (Java Virtual Machine).

Charles Nutter, a Sun engineer who is a core committer to JRuby, said one reason developers are beginning to look at Ruby is that “Ruby is the flavor of the week, and there are a lot of ways to solve the problems of the Web.” 

Continue reading

The No-Framework PHP MVC Framework

A An insightful post by the King of php himself can be found here: THE NO FRAMEWORK PHP MVC FRAMEWORK. Confusing? hahah – well Andy Jeffries ( A PHP, RUBY ON RAILS AND MYSQL Developer) sums it up really well here:  DESIGN PATTERNS VS AGILE DEVELOPMENT

I posted this in a forum in the morning today, please read the reply i got:

Keep an open mind …….

A good framework:

1. better separates presentation from logic
2. has a clear documented structure
3. has features

He uses a view, controller, and model but he doesn’t use a “front controller”. URL’s are mapped directly to views. That’s not necessarily bad, (that’s the asp.net way) but:

– without a messy .htaccess file, you miss out on nice flexible hackable urls
– you miss out on pre processing like showing a cached page without loading the entire view file and all it’s includes. 

I believe this person who commented on my post in the forums has a POINT WORTH NOTING…