Wednesday, October 24, 2007

A Java Certification or Not?

Lately I've been thinking about getting a Java Certification, but I've heard some opinions of people saying that a certification does not give an extra value to the person that has it, so I started thinking about it and it seems that some companies actually react when they see in your resume that you have certifications.

To get some more opinions, I posted a question in LinkedIn, I asked this:

For a Java programmer, do you think it really makes a difference to have a Java certification when looking for a new job?

I am interested in knowing if a certification is actually considered when evaluating candidates or if the employers only care about their own evaluations and candidate's past experience.

It was interesting because I got a lot of different opinions from people who are Java developers and from people who recruit.

Most of the answers agreed in one thing, a certification can't hurt no one, so in most of the cases companies would check your experience, your ability to solve problems and some other skills before actually caring about the certification. However, if they are interviewing two people and both of them have the same qualifications, but one has a certification they would probably hire the one with the certification because it is a plus, it means that this person studied Java to pass the test.

In my opinion, I don't think a certification would actually make a big different when your applying for a job if you don't have any experience. However, one of the biggest advantage of getting a certification is that you have to sit and study all the Java items required to pass this test and that gives you a big knowledge of the language because you are learning the theory and that is very important, since there are a lot of developers that can make things work but they don't know what is actually happening or how it is happening, they just know it works.

If you want to check all the answers go to my question in LinkedIn

Wednesday, July 25, 2007

Ruby on Rails - Up and Running Book Review

Recently, I've been interested in learning Ruby on Rails, but at the beginning of my quest I wasn't sure where to begin, there are a lot of documentation in the Web that I could use but I wanted some structured tutorial that guide me through my first experiences with Rails.

Fortunately, the company where I work bought the book Ruby on Rails Up and Running by Bruce A. Tate and Curt Hibbs, so I took it and started reading it and what I found was exactly what I was looking for, a beginners book.

I give this book 4 starts because I think it's really good for someone who is just starting to learn about Rails. It explains the basics of the language and the authors use the same example along each chapter so you can learn all the concepts in the book in a very practical way. The example is a Photo Slideshow application, a very common example actually because it allows you to develop some business logic along with interesting views handled by Ajax and some Javascript effects.

With this book, you can learn the basics of Active Record and Active Record Relationships, Scaffolding, Views, Migrations, Ajax and a bit of Testing.

It is not too long, so you won't feel intimidated by it. It is a good place to start, trust me!

I recommend it!

How to handle Time fields in MySQL and Ruby on Rails

One of these days while I was working in a small application created in Ruby on Rails I came across a field in the database with data type Time. The interesting thing was that Rails does not support Time fields, it supports only Date or Datetime, so what to do?

Since I had to handle Time fields not dates, I had to do some tricks to make this work. I'm going to share with you, in a high level, what I did.

First, in the RHTML page I handled the time (hour and minutes) using my own fields, maybe HTML selects with the possible time values.

Next, I created some Javascript function which would post the time as a String or numeric value to the controller, then in the controller you convert the value to a String notation with the format "HH:MM", for example "08:30" or "14:25".

Then, you create a Ruby Time object using your String time as follows:
timeObj = Time.parse("8:15")

This will create a Time object with the current system date and the given hour and minutes you set.

Finally, when you store your Time object in database, MySQL will truncate the date and store only the time value which is exactly what you wanted to do in the first place.

I hope this helps!!

Prototype Javascript Framework - Creating classes

Here it is a quick review of how you can implement classes in Javascript using the Prototype Framework. (This was taken of the Prototype reference document that you can find in http://beta.bigmedium.com/projects/prototype-pdf/index.shtml)

If you are familiar with Object Oriented Programming, handling classes in Javascript would be really easy and Prototype makes easier.

Another advantage of using classes in Javascript is that you can have cleaner code, easy to use and maintain.

I'll show you now how to create a class using Prototype.

create() -> Function

Returns an function that acts like a Ruby class.

Class.create() returns a function that, when called, will fire its own initialize method.It also lets you more easily subclass by overriding a parent's constructor.

Example:

var Person = Class.create();
Person.prototype = {
    initialize: function(name, lastname, age) {
         this.name = name;
         this.lastname = lastname;
         this.age = age;
     },
     myAge: function() {
         alert("My age is " + this.age);
    }
};

var john = new Person("John", "Doe", 25);
john.myAge();
// -> alerts "My age is 25"

var Employee = Class.create();
Employee.prototype = Object.extend(new Person(), {
     initialize: function(name, lastname, age, job) {
         this.name = name;
         this.lastname= "lastname";
         this.age = age;
         this.job = job;
     },

     myJob: function() {
         alert("I work as a " + this.job);
    }
});

var susan = new Employee("Susan", "Smith", 30, "Teacher");
susan.myJob();
// -> alerts "I work as a Teacher"

Friday, July 13, 2007

Prototype Javascript Framework - Utility Methods

Here it is a quick review of the most important utility methods of the Prototype Framework. (This was taken of the Prototype reference document that you can find in http://beta.bigmedium.com/projects/prototype-pdf/index.shtml)

$

$(id | element) -> HTMLElement
$((id | element)...) -> [HTMLElement...]

If provided with a string, returns the element in the document with matching ID; otherwise returns the passed element.

The function also extends every returned element with Element.extend so you can use Prototype's DOM extensions on it.

$$

$$(cssRule...) -> [HTMLElement...]

Takes an arbitrary number of CSS selectors (strings) and returns a document-order array of extended DOM elements that match any of them.

The $$ function searches, by default, the whole document.

Current set of supported selectors:

  • Type selector: tag names, as in div.

  • Descendant selector: the space(s) between other selectors, as in #a li.

  • Attribute selectors: the full CSS 2.1 set of [attr], [attr=value], [attr~=value] and [attr|=value]. It also supports [attr!=value]. If the value you're matching against includes a space, be sure to enclose the value in quotation marks ([title="Hello World!"]).

  • Class selector: CSS class names, as in .highlighted or .example.wrong.

  • ID selector: as in #item1.


$A

$A(iterable) -> actualArray

Accepts an array-like collection (anything with numeric indices) and returns its equivalent as an actual Array object.

$A doesn't perform DOM extensions, since the array could contain anything (not just DOM elements).

$F

$F(element) -> value

Returns the value of a form control. This is a convenience alias of form.Element.getValue.

$H

$H([obj]) -> Hash

Creates a Hash (which is synonymous to “map” or “associative array” for our purposes).

A convenience wrapper around the Hash constructor, with a safeguard that lets you pass an existing Hash object and get it $F | 5 back untouched (instead of uselessly cloning it).

$R

$R(start, end[, exclusive = false]) -> ObjectRange

Creates a new ObjectRange object. This method is a convenience wrapper around the
[ObjectRange](/api/objectRange constructor, but $R is the preferred alias.

$w

$w(String) -> Array

Splits a string into an Array, treating all whitespace as delimiters. Equivalent to Ruby's %w{foo bar} or Perl's qw(foo bar).

Try.these

Try.these(Function...) -> firstOKResult

Accepts an arbitrary number of functions and returns the result of the first one that doesn't throw an error.

document.getElementsByClassName

document.getElementsByClassName(className[, element]) -> [HTMLElement...]

Retrieves (and extends) all the elements that have a CSS class name of className. The optional element parameter specifies a parent element to search under.

Tuesday, June 19, 2007

Ruby on Rails - Some tips

I've been trying to learn Ruby on Rails, it is an interesting framework that makes developers life a lot easier.

I found some tips or notes that I think I can share with you so they might be helpful when you are doing some programming in Rails yourself.

Hope this helps!!

  • Name your tables in plural, the class would be generated in singular.

  • When migrating a schema_info table is created to keep track of the schema version.

  • The id column is an int and it's generated automatically, also it uses auto_increment so you don't have to worry to set this value.

  • Foreign keys should be named using the name of the class plus "_id", for example product_id.

  • Every ActiveRecord class has a transaction method to handle transactions.

  • The relationship "belongs_to" corresponds to the "many" side of the many_to_one relationship.

  • When you use acts_as_tree, the name convention is parent_id, it would recognize it by itself. This would create a parent and children variables, where children is an array.

  • There is a layout file for each controller. You can create just one that can be used by every controller, setting the property layout in the application base controller or directly in every controller.

  • In the routes file you can specify the default action to be executed when entering the site. When doing this remember to delete the index.html under the view directory root.


More coming later...