Wednesday, April 20, 2011

Ruby on Rails - Part 2: Just Enough Ruby


Ruby on Rails Screencast - Iteration 2 - Amy Hoy


Ruby on Rails - Part 6: Configuration and Deploy


Ruby on Rails Screencast 1 - David Heinemeier Hansson


Enhancing Your Ruby on Rails Weblog(Part2)


Creating a Ruby on Rails Weblog in 99 Sec(Part1)


High Performance Ruby on Rails and MySQL


Ruby on Rails - Part 5: AJAX and Testing


Ruby on Rails - Part 4: Advanced Active Record


Ruby on Rails - Part 3: Basic Rails


Ruby on Rails - Part 1: Hello World


Ruby On Rails For Absolute Beginners


High Performance Ruby on Rails and MySQL


Web Development with Ruby On Rails


Agile Development?Why Agile?

We follow a systematic and time bound approach to web application development, adhering to the following key agile principles:
  • Short terms goals and smaller release cycles
  • Product is built inside-out, i.e. starting from simple features and gradually adding more sophistication
  • Stable version of product deployed frequently
  • Test driven development to ensure high quality/reliability of codes
  • Concurrent quality assurance to ensure bug-free product all the time
Agile Development
We follow a systematic and time bound approach to web application development, adhering to the following key agile principles:
  • Short terms goals and smaller release cycles
  • Product is built inside-out, i.e. starting from simple features and gradually adding more sophistication
  • Stable version of product deployed frequently
  • Test driven development to ensure high quality/reliability of codes
  • Concurrent quality assurance to ensure bug-free product all the time

A typical software development cycle by RailsTeam: development-process




Agile Development Process
We execute your project in small iterations across several phases depending on the scope of your project.

Project Discovery

We work with you to create a product wish-list, writing out everything which will satisfy business objectives.

Planning

Product development goals are broken down into product releases called Sprints. Sprint goals are executed in smaller development cycles called Iterations. Iterations length usually range from 3 days to 2 weeks.

Daily Goal Setting

Everyday, team members communicate on what they did, what are their roadblocks and their goals for the day. This helps everyone remain on the same page and ensures every team member is aware of overall progress.

Test Driven Development

RailsTeam maintains a test:code ratio of 1:4 to ensure high quality and reliability of code. Both functional and unit tests are written to maintain full code integrity. Any commits on source code repository is done only when both functional and unit test pass 100%.

Quality Assurance

Quality analysts closely work with the team to ensure business rules are implemented correctly. Test scenarios and test cases are documented concurrently. Both automated and manual testing approaches are followed to test the product.

Performance Tuning

At RailsTeam we lay high emphasis on performance and scalability of your app. Performance fine tuned at three levels:

  • Reducing page load time by optimizing html, css and javascripts
  • Optimizing database response time by database caching
  • Improving application response time by action caching and fragment caching

Why Agile?


Agile development reduces the communication gap that occurs between client vs. project manager as well as project manager vs. development team. A smaller development cycle means greater visibility/control over the project. Better quality of codes as there is lot more transparency and communication among the developers themselves.

Product goals are met with accuracy

Due to extremely dynamic nature of development, chances of gap between client requirements and actual functionality is very low.

Product grows organically

New features in product are introduced with extremely realistic approach keeping in mind immediate priorities.

Greater team satisfaction

Since there is reduced amount of 'redundancy' or repeat work in development, the development team stays on top of their spirit. They can see the results quickly and experiment / innovate with greater freedom.

Better product quality

Quality of end result is much better because everything is taken care on a smaller scale. Testing goes on parallel with the development.

Reduced cost of development

There is optimum usage of resource as a result, efforts do not get waste and end user or client does not have to wait for months to see the result. There is a huge savings in cost of development.

 

Tuesday, March 1, 2011

Building a More Efficient Ruby Interpreter


Ruby Interview Questions

1) Explain about the programming language ruby?
Ruby is the brain child of a Japanese programmer Matz. He created Ruby. It is a cross platform object oriented language. It helps you in knowing what your code does in your application. With legacy code it gives you the power of administration and organization tasks. Being open source, it did go into great lengths of development.

2) Explain about class libraries in ruby?
Ruby has a strong set of class libraries and it covers from a variety of domains such as thread programming, domains and data types. Also ruby is a new language and it also has additional libraries coming every day. Many of the new languages which do exist have huge libraries because of their age.

3) Explain about portability?
Ruby language can be ported to many platforms. Ruby programs can be ported to many platforms without any modification to the source code. This feature made the language very useful and highly used by many programmers worldwide. Some of the platforms used are DOS, UNIX, WINDOWS, etc.

4) Explain about garbage collection feature of ruby?
Ruby is an object oriented language and every object oriented language tends to allocate many objects during execution of the program. Ruby deletes unallocated and unused objects automatically. This feature can be controlled by applying proper syntax and program through ruby.
5) Explain about the command line options?
Ruby`s language is executed from the command line like most of the scripting languages. Programming and behavior language environment can be controlled from the interpreter itself. Some of the commands which are used are as follows –d, -h, -e prog, -v, -T, -r lib, etc.
6) Explain about environment variables present in ruby?
Following are some of the environment variables used to control the behavior programming of ruby. While programming ENV object lists some of the current variables. RUBYLIB path searches for libraries. Make sure that you separate each path with colons. RUBYOPT passes command line options to Ruby interpreter. There are many more which can be obtained by searching the huge pool of library.

7) Explain about operators in Ruby?
Like all the modern languages Ruby supports many different operators to its credit. Most of the operators in Ruby are in fact methods due to the object oriented nature of the language. This feature gives Ruby an edge over its competitors. Semantics of these operators can be changed due to the object oriented nature of the language.
8) Explain about the defined operator?
Define operator defines whether a passed expression is defined or not. If the expression is defined it returns the description string or null if the expression is not defined. If a variable is defined it gets initialized. If method_call is defined as true then method also gets defined. This is also the same case with super and yield.
9) Explain about methods?
Methods in ruby basically perform two functions, named operation and the code present in the class which does a specific function. In Ruby all your algorithms live in methods which inturn is present on objects. Ruby does not have any provision for functions. Code present in Ruby is always a method of some object. Behind the scenes ruby gives you the flexibility to work with methods as functions if you are considering working with other languages.
10) Explain about normal method class?
This function calls a method and it can take any number of arguments and expr. Make sure that you put an asterisk or an ampersand before the expression. Last expr argument can be declared with a hash without any braces. If you want to increase the size of the array value then make sure that you put an asterisk before expression. “::” can be used to separate the class from methods.
11) Explain about ruby names?
Classes, variables, methods, constants and modules can be referred by ruby names. When you want to distinguish between various names you can specify that by the first character of the name. Some of the names are used as reserve words which should not be used for any other purpose. A name can be lowercase letter, upper case letter, number, or an underscore, make sure that you follow the name by name characters.

12) Explain about variables?
There are four different types of variables they are local, instance, global, and class. Variables can be used in the program without any declaration and they can contain data of any type. A local variable contains lower case characters followed by name characters. Instance variable starts with a @ sign followed by name characters.
13) Explain about Class variable and global variable?
A class variable starts with an @@ sign which is immediately followed by upper or lower case letter. You can also put some name characters after the letters which stand to be a pure optional. A class variable can be shared among all the objects of a class. A single copy of a class variable exists for each and every given class.
To write a global variable you start the variable with a $ sign which should be followed by a name character. Ruby defines a number of global variables which also include other punctuation characters such as $_ and $-k.
14) How does ruby deal with extremely large numbers?
Unlike other programming languages ruby deals with extremely large numbers it doesn’t have any barriers. There is no limit on the extent of limit of number usage. Ruby performs this function with two different classes they are fixnum and bignum. Fixnum represents easily managed small numbers and bignum represents big numbers. Ruby entirely handles the functioning of these two classes which leaves a programmer to concentrate on his arithmetic operations.
15) Explain about Float, Dig and Max?
Float class is used whenever the function changes constantly. It acts as a sub class of numeric. They represent real characters by making use of the native architecture of the double precision floating point.
Max is used whenever there is a huge need of Float.
Dig is used whenever you want to represent a float in decimal digits.
16) Explain about interpolation?
Interpolation is a very important process in Ruby. Interpolation is the process of inserting a string into a literal. There is only one way in which you can interpolate a string into a literal by placing a Hash (#) within {} open and close brackets. This refers to a new name to by referring to the copy of the original method.
17) Explain about ruby code blocks?
Ruby code blocks form an important part of ruby and are very fun to use. With the help of this feature you can place your code between do-end and you can associate them with method invocations and you can get an impression that they are like parameters. They may appear near to a source of the code and adjacent to a method call. The code is not executed during the program execution but it is executed when the context of its appearance is met or when it enters a method.

Saturday, February 19, 2011

Ruby On Rails Programming

Lately, i’ve been quite interested in learn more things abour Ruby Programming. To be sincere, i always wanted to learn a bit more about the language, but I’ve been into some WordPress Theme programming the past 2-3 months. Hopefully, i will write some posts about this subject as well, in the future.

What is Ruby on Rails ?

Ruby, as you may know, is a very well known scripting language, with an exceptional and clean syntax. I’ve always been a fan of Python and i must say that moving to Ruby is a totally different programming style. Luckily, learning Ruby is quite easy. It indeed offers some very good techniques, like code blocks etc, but overall, it resembles interpreted language, like Python and Perl also are.

On the other side, Ruby on Rails is something completely different and harder to learn. RoR (widely used for Ruby on Rails), is actually a framework for creating web applications. As simple as that. You may already know the Django alternative for Python. Sounds … ok, but is it just that ?

Why Ruby on Rails is Really Really Good

RoR is really great because it makes the life of the programmer a WHOLE lot easier. Imagine that you wanted to write a php function that checks whether  passwords match in a simple registration routine. Using php, you would need to get the input, compare it and write an html page that presents the error to the user. Lots of work for doing a simple thing. But with ruby :
view source
print?
validates_confirmation_of :password

is just enough !

Installation of RoR

Installing RoR is a pretty easy procedure for the well known operating systems. There is an installer for Windows, you can use a package manager for Linux and macports for mac OS (as i currently use). For more information on the whole process, please take a look at the official ruby programming website.

The MVC (Model - View - Controller) Model.

MVC is the programming model that RoR utilizes. If you have used a templating system like smarty in the past, you have most probably already used the model. This model simply identifies that our web program has 3 different entities that we need to look after. The model, the view and the controller. But, what is the difference ? Now, i could describe that in words, but i prefer providing an example as well :

The View is the easy entity. It is what our program prints out to the browser of a user.

The Controller closely relates to data. It is the part where data is initialized, to be then provided to the View and shown to the user.

The Model is the auxiliary entity where we write our large functions that operate on data.

Now, think of this situation. You have a page that presents some products for people to buy. The Controller is the first thing that gets utilized. Once the browser requests the page, the controller takes action. Therefore, when the products page is requested, the Controller understands that this page was called and provides the gateway between your large functions and your view. Now, the Model contains functions such as getAllProducts(). This function is called by the controller, to provide an instance of all the products. This variable, most times a class variable like @products, is going to be used in the view.

Hope this starts to make sense, i've tried to describe it to the best of my knowledge. I do not want to take this post any further. In my next one about RoR, i will describe how to create a test project, use migrations and more. Have fun with Ruby, play a little bit with it, it is really worth it, you have my word !

Ruby on Rails

There’s been no shortage of “magic bullet” technologies over the years, and one of the hottest things in web development at the moment is Ruby on Rails.   At Headshift we’re using Rails for an increasing number of projects, and we’re seeing more and more interest from clients in this technology.   Having said that, it’s not always clear what Ruby on Rails actually IS, so what follows is an overview of the whats and whys, in as non-technical terms as possible.

Java, dot Net and even historical aberrations such as Visual Basic have all been up and down the hype curve over the years, so you could be forgiven for regarding the interest in Ruby on Rails as more of the same.   As a consultancy we pride ourselves on being technology-agnostic – but nevertheless, we’re Ruby on Rails fans for a number of reasons.

What is Ruby on Rails?

Ruby on Rails is – depending on who you’re talking to, and the context in which you’re talking to them in – a number of different things:

It’s a set of technologies

Ruby on Rails, as the name suggests, is two things:  Ruby is an object-oriented scripting language which has been around since the mid-1990s, and has developed a devoted following from developers who appreciate its simplicity, readability and flexibilty.

Rails is a framework written in Ruby, and it’s the nature of the framework that makes RoR so powerful.   An awful lot of what developers do is covering old ground – most web applications have a database behind the scenes, for example – so most web applications will need database integration.   One approach is to rewrite this from scratch every time – while it’s an approach, it’s one that can be slow, expensive and prone to bugs.

A framework on the other hand takes common design patterns such as database handling and provides a set of standardised functionality that new applications can hook into.   This makes it a lot quicker to set up these standard functions – and also makes it less likely that bugs will be introduced, because if lots of applications are using the same functionality it’s likely that bugs will be quickly spotted and squashed.

It’s a set of design approaches

Rails is an “opinionated” framework – it has a set of ways of doing things, and while these can be overridden when necessary, in most situations it’s easier and quicker to use the standard approach.  This can be summarised as “convention over configuration” – for example, Rails has a standard way of abstracting an underlying database structure into classes, objects and attributes which means that it will behave in the same way from application to application and developer to developer.

Rails also uses the “model, view, controller” design pattern (or MVC for short).   This is something that’s been around successfully for years – it breaks down an application into the underlying data and business logic (the model), presentation of data to users (the views), and the code that orchestrates the interactions between model and views (the controllers).  There are some subtle but powerful advantages to an MVC approach – for example, if the models are responsible for maintaining the database and enforcing business logic, if a field must have a certain number of characters or value this can be enforced in one place (the model) rather than relying on checking at every point where the values might be changed.

“Don’t repeat yourself” is another core Rails “philosophy” – if an element of a page such as a menu is used repeatedly, then rather than rebuilding it time and time again, Rails makes it supremely easy to abstract it into a module which can be reused.

It’s a community

Both Ruby and Rails are open-source, and there’s a vibrant community which has grown up around them.  The chances are that someone has experienced – and solved – your problem at some point in the past, so rather than having to reinvent the wheel the Rails community is valuable source of help and advice.  That’s not to say that other technologies don’t have communities, but Rails seems to attract people who are naturally at home with open-source ways of working.  This also helps to explain the rapid growth in the number of plugins and code modules that have been written to extend the framework.

Why is Ruby on Rails so hot?

This is a topic that’s worthy of an entire blog post in its own right, so I’ll just look at a couple of reasons.   Rails development fits very well with Agile project management techniques – which can result in true rapid application development.  Clients are often surprised at how quickly a Rails application can be put together, and how flexibly it can respond to changes in requirements as they are discovered over the course of the project.

Speed doesn’t necessarily have to sacrifice quality, though – testing is crucially important for creating reliable software.   Rails treats testing as an integral part of development rather than an afterthought – to the extent that it’s almost easier to test than not!   A particularly powerful technique is the use of “continuous integration”.   As development takes place, tests are developed along the way – and when a new piece of code is written, all the existing tests are run to ensure that the new functionality doesn’t inadvertently break something elsewhere.

And I’ve mentioned the fact that Ruby and Rails are open-source – again the topic for a whole blog post, but the combination of quality resulting from “many eyes” looking at the code and the low cost make open source an attractive proposition in the current economic climate.