Archive for work

einführung in ruby on rails

Monday, December 31st, 2007

auch wenn es schon diverse howtos und einführungen im internet zu ruby on rails gibt, habe ich mich entschlossen, eine von mir kürzlich zu dem thema erstellte präsentation hier zu veröffentlichen. ich hoffe es erleichtert dem ein oder anderen den einstieg in rails…

surveys about agility and success

Tuesday, November 20th, 2007

at this years w-jax conference i attended a keynote by scott ambler, who’s one of the guys pushing the agile movement for several years now. in his talk he presented results of surveys about adoption rates of agile techniques and success rates of agile it-projects. there are some interesting numbers in it, despite the fact that they are mostly covering the situation in the states. it would be even more interesting to collect data for these topics in europe, too, and draw some comparisons. for me the most important findings are:

  • 69% of organisations have adopted agile techniques so far
  • the most effective agile practices are “iterative development” and “regular delivery of working software”
  • one-third of projects are done with two week iterations
  • 44% of organisations had a success rate of 90% or above for agile projects
  • project success rate for agile projects is 10% higher than for “traditional” projects
  • only 42% of offshoring projects are successful, but they are considerably more succesful in asia than in the rest of the world
  • the number of successful projects is dropping significantly for teams larger than 10 members
  • 80% of it-managers and 70% of project managers put the needs of their staff over beeing on time and on budget
  • 70-80% of it-personnel see a healthy workplace beeing more important than beeing on time and on budget, but only 53% of business stakeholders share this opinion :-(

rails error wrapping for select input fields of referenced models

Sunday, September 16th, 2007

during my rails development i recently came across the problem mentioned here. this is my concrete scenario…
first of all there are two model elements referenced by belongs_to resp. has_many:

class WorkingTime < ActiveRecord::Base

  belongs_to  :project

  validates_presence_of :project, :message => 'Please select a project!'
  validates_associated :project
  validates_presence_of :hours_worked

end

class Project < ActiveRecord::Base
  has_many :working_times
end

the input form to create an instance of this model looks something like this:

[...]
<%= error_messages_for 'working_time' %>

<label for="project_of_working_time">Project</label>
<%= select :working_time, :project_id,
    Project.find(:all).collect {|p| [ p.name, p.id ] },
    { :include_blank => true }, :class => "working_time_select" %>

<label for="working_time_hours_and_minutes_worked">Hours Worked</label>
<%= text_field 'working_time', 'hours_worked', :size => 5  %>

[...]

now if you try to save the form without selecting a project an appropriate error message is shown. this is not really remarkable. but the problem is that the select input field isn’t highlighted correctly like other input fields (i.e. the hours_worked if it is empty). i had a hard time to figure out the reason for this.

the error highlighting is based on the errors object that is passed to the view in case of validation errors. when the view is evaluated every input field looks in this object for an error associated to it by its name. if the method errors.on(name of input field) returns a value, a html-snipped is wrapped around the input field (btw, if you want to change the snipped, look here). here is an example for the input textfield hours_worked:

<div class="fieldWithErrors">
<input id="workind_time_hours_worked"
     name="working_time[hours_worked]" size="5" type="text" value="" />
</div>

the issue with the above mentioned working_time / project relation is that the validation error is mapped to the field project and not to project_id, since this is what i described in the model working_time. because the view cannot get the link to the project-error, the field will not be highlighted. you can validate this with a unit-test:

require 'working_time'

class WorkingTimeTest < Test::Unit::TestCase

  def test_create_without_project
    @working_time = WorkingTime.new
    @working_time.hours_worked = 3
    result = @working_time.save
    assert !result
    errors = @working_time.errors
    assert_not_nil errors[:project]
    assert includes_match?(errors[:project], 'Please select a project!')
  end
end

the only solution is to change the validation in the working_time model from project to project_id. this is quite confusing because the working_time model actually doesn’t have a project_id field. what makes this even worse is that you also get validation errors if a project instance will be set in the working_time model. therefore the following test always fails:

require 'working_time'
require 'project'

class WorkingTimeTest < Test::Unit::TestCase

  def test_create_with_project
    @working_time = WorkingTime.new
    @working_time.hours_worked = 3
    @working_time.project = Project.find(1)
    result = @working_time.save
    assert result
  end
end

i hope this issue will be fixed in a future version of rails.

how to test view helpers in rails

Thursday, August 9th, 2007

as you probaby know, ruby on rails has a very handy test integration. you can easily write unit tests for your rich domain model and some functional tests (that can be roughly compared to http-units in the java world, but with integrated webserver) for the controller and views.

unfortunately, one part of rails basic implementation architecture cannot be tested as easy as the above mentioned components: the view helpers. actually they are used to extract view functionality and keep the view templates clean from ruby scriptlets. of course, you can test them indirectly through your functional tests, but rails provides no pure way to test them individually. an obvious approach is to write some unit-tests for each helper class. this works fine as long as you are not using some methods provided by rails, i.e. link_to, url_for, all the input tag methods and so on.

so here is an example of a simple view helper. the method time_link_to returns a link including the current date as parameter in the form http://www.yourhost.com/railscontroller/year/month/day.

# Methods added to this helper will be
# available to all templates in the application.
module ApplicationHelper

  def time_link_to(controller_name, name, date, html_options = nil)
    if html_options
      html_options = html_options.stringify_keys
      convert_options_to_javascript!(html_options)
      tag_options = tag_options(html_options)
    else
      tag_options = nil
    end
    url = url_for(:controller => controller_name) +
           "/#{date.year}/#{date.month}/#{date.day}"
    "<a href=\"#{url}\"#{tag_options}>#{name || url}</a>"
  end

end

since the method url_for is provided by the controller that is executed when the view and therefore the helper is evaluated, you have to fake it for the unit test. this can be done in the setup method of the unit test like this:

class ApplicationHelperTest < Test::Unit::TestCase

  include ActionView::Helpers::AssetTagHelper
  include ActionView::Helpers::UrlHelper
  include ActionView::Helpers::TagHelper
  include ApplicationHelper

  # called before every single test
  def setup
    # creating a dummy controller with the method url_for that
    # returns the url assigned to the controller
    @controller = Class.new do
      attr_accessor :url, :request
      def url_for(options, *parameters_for_method_reference)
        url
      end
    end
    @controller = @controller.new
    # setting the url of the controller
    @controller.url = "http://www.example.com"
  end

  # testing the view method
  def test_time_link_to
    assert_equal "<a href=\"http://www.example.com/testcontroller/" +
      "#{Date.today.year}/#{Date.today.month}/" +
      "#{Date.today.day}\">test</a>",
      time_link_to("testcontroller", "test", Date.today)
    assert_equal "<a href=\"http://www.example.com/testcontroller/" +
      "#{Date.today.year}/#{Date.today.month}/" +
      "#{Date.today.day}\" id=\"test_id\">test</a>",
      time_link_to("testcontroller", "test",
        Date.today, {:id => "test_id"})
  end
end

deutsche post in second life

Thursday, May 3rd, 2007

as you probably know, second life is one of the most famous virtual communities of today. and as i wrote some time ago, there is also an evolving virtual economy which significantly affects real life businesses. therefore many well known companies (i.e. adidas, toyota, sony and ibm) started a virtual counterpart.

but the last thing i expected was that the company i work for gets to second life as well, because i could’t really think of a useful application. but an email, which reached me today, quickly disabused me. now there is also a quite impressing equivalent of the deutsche post in second life :-)

you can send a post card of your avatar’s face or some other theme via second life to a real world address. i don’t know if this is really useful, but it’s a quite cool idea ;)

avatar01.jpg

how to improve your presentation skills

Thursday, April 5th, 2007

on projectmanagement source there is a nice post on how to become a better public speaker. they list up 27 hints in form of best practices which can help to improve one’s presentation performance. i think there are two more important aspects:

28. try to get feedback: once you’ve finished your speech try to get feedback from your audience in form of a standardised questionnaire that you can hand out before. you can ask about

  • the form or quality of your presentation,
  • the innovativeness regarding the topic,
  • the auditors’ gain of experience,
  • the auditors’ readiness to recommend your speech to friends,
  • the auditors’ overall opinion,
  • and suggestions for improvement.

this gives you some important information about the things you still have to work on, and an impression on how successful your presentation really was.

29. be prepared for equipment failure: let’s assume you want to use some state-of-the-art presentation equipment like a mike, a notebook, a beamer, powerpoint and a wireless presenter mouse. the first thing is that you should allow for some extra time before you start your speech in order to get all this stuff working. if you encounter problems, you must be ready for an alternative solution (i.e. slices for an overhead projector).

there’s also a website which deals with “the art of speaking” and has some more nice hints.

five half-truths about teams and teamwork

Sunday, March 11th, 2007

when it comes to teams and teamwork, there is a lot unfounded belief and intuition. some aspects of team building and team performing are commonly accepted, and are therefore not questioned or scrutinised. but there are truths that, when we look closer at them are not really true.

(more…)

managing software development

Wednesday, November 29th, 2006

i came across a nice essay of reg braithwaite on what managing software development really means. he states that it basically consists of three main theories:

  • accountability for results
  • authority over resources
  • making decisions based on judgement

in addition, management has to be accompanied by courage. good judgement means that uncertainties or risks, which are connected to options, have to be evaluated and reduced. sometimes you even cannot get a clear view of the decision basis and you have to cope with the risks bounded to your options. or you might possibly have to accept negative consequences that potentally will arise from any of your options. so you need more or less courage to decide which option to take.

i personally think that you should also add the need of a strategy to the above mentioned aspects. a red thread has to run through all of your decisions. they have to match to each other and should tend to a certain kind of long term goal, which also has to be accepted by your staff.
if your strategy doesn’t fit to the circumstances, i.e. the skills of your staff, the working environment or of course to a business case, you will be blamed for poor management.

aufwandsschätzungen in der software-entwicklung

Wednesday, November 22nd, 2006

als ich vor ein paar tagen auf der bonner runde einen vortrag zum thema “aufwandsschätzungen” präsentiert habe war das interesse groß. für viele schien es sich um ein kritisches und akutes thema zu handeln.
dabei sind einige prinzipien guter schätzungen nicht besonders kompliziert und gut zu erlernen. trotzdem konnten sie sich anscheinend in den letzten jahren nicht besonders gut durchsetzen bzw. verbreiten.

(more…)

criteria for success and failure

Sunday, October 15th, 2006

in the developer.* robert glass has published a nice article on surprises and predictables regarding factors of it-project success or failure. the mentioned findings are the result of a survey by prof. june verner of 400 projects in the u.s., australia, and chile.

(more…)