Monday, August 24, 2009

Software design or code design

Software design

Generally high level, a.k.a.
  • architecture
  • infrastructure
    e.g. 3-tiers or client server, ejb or not

Code design

  • domain design
  • flow design
  • good code design means clean, maintainable code
  • code design issues are easier to fix than software design
The following extract from Domain Driven Design applies regardless the type of project (waterfall or agile).
Any technical person contributing to the model must spend some
time touching the code, whatever primary role he or she plays on
the project. Anyone responsible for changing code must learn to
express a model through the code. Every developer must be
involved in some level of discussion about the model and have
contact with domain experts. Those who contribute in different
ways must consciously engage those who touch the code in a
dynamic exchange of model ideas through the Ubiquitous
Language.
A solution consultant should touch the code (or at least know the code if they don't want to touch it).

Rails Rumble after thoughts

Building an application in 48 hrs is hard. Time flies when you are not prepared.


Here are some of the things that you want to touch on before the competition starts.

  • application security / access - who has access to what
  • model / resource routes - what models are required and how are they connected from browser / UI perspective
  • fields & columns in models
  • model validation / mandatory fields

For the initial first few models that you add to the application, the effort to add each one does not increases in linear fashion.

Because with each model, you need CRUD pages / functionality. Each additional page needs to be styled therefore more visual design required, also more thoughts required for workflow / navigation design.


Often we have to just implement some crude pages to test / visualise our app (particular for workflow) while our designer work thru the markup, which means we usually have to go back and cleanup those pages' markup to fit with the design.


Overall, it was exhausting but I learnt heaps of cool tricks this year building TechMeets.com.


Monday, August 17, 2009

Using google_ajax_library when offline.

As I mentioned in How do I automatically revert to local javascript when offline?, I eventually forked google_ajax_library gem and added support for working offline.

I sent a pull request to Ryan Heath, the original author the gem and he liked the feature but implemented it slightly differently to what I have done.

How to use WinMerge as ClearCase compare & merge tool?

WinMerge made ClearCase much more bearable to work with.

When installing WinMerge make sure you tick the 'Integrate with ClearCase' option.
That will make ClearCase use WinMerge as the compare program but ClearCase still uses its own merge program when resolving conflicts.
To change that setting you have to modify ClearCase configuration file manually.
The configuration file is usually in the lib managers' folder of the ClearCase installation.
e.g. C:\Program Files\Rational\ClearCase\lib\mgrs\map

The change to the map file is based on what WinMerge did to the xcompare value
;text_file_delta xmerge ..\..\bin\cleardiffmrg.exe
text_file_delta xmerge C:\work\tools\WinMerge\WinMergeU.exe

Tuesday, August 4, 2009

How to validate money amount in ActiveRecord?

This is how I validate money amount in Romey.
Basically an regex that allows up to 2 decimal points or whole integers.

validates_format_of :amount, :with => /^\d+$|^\d+\.\d\d?$/

Wednesday, April 29, 2009

How I installed ruby and run RoR on QNAP TS-219

Set LD_LIBRARY_PATH to be /opt/lib so libssl.so.0.9.8 and libcrypto.so.0.9.8 can be found. Alternatively symlink them to /usr/lib might work as well.


Install ruby & rubygems from source, using default options.


Then run this to install mysql gem.

gem install mysql -- --with-mysql-dir=/usr/local/mysql

Thursday, February 19, 2009

How do I automatically revert to local javascript when offline?

I work on Rails applications that include jquery javascript files from ajax.googleapis.com. Every now and then I have to work on those apps offline.
e.g. when I commute on trains.

The application has the same jquery javascript files locally so the old way of working offline was to comment out the google jquery include calls and uncomment the local javascript include calls.

I decided I didn't want to have to bother with that so I implemented something that will check if I am connected online or not and make the appropriate javascript include calls.

The code looks like this:
- if Ping.pingecho("ajax.googleapis.com", 10, 80)
  = google_jquery
- else
  = javascript_include_tag 'jquery-1.2.6.min.js'


The added bonus is that if ever ajax.googleapis.com goes down then our apps won't be affected.

p.s. the above code is markup in haml and uses google_ajax_libraries_api plugin and ping.rb which comes with standard ruby installation. Down the track I might modify the plugin to support the offline backup.