Recently I stumled upon a blog post which asked if design patterns are useless. Are they useless? In fact the classic GOF design patterns (COMPOSITE, STRATEGY, MEMEMTO, etc) seem to be useless for developing Ruby on Rails web applications. I haven’t seem them in many Ruby on Rails application so far, and I haven’t use them either, although I used them frequently in windows applications.

In RoR apps there is typically only one overarching design pattern, the MVC pattern of the framework, and of course the ActiveRecord pattern realized by the ActiveRecord class of the same name. From the object-oriented point of view, the main difference between development of windows and web applications is that objects represent GUI objects in windows (with all the power traditional OOP has to offer), whereas they often represent database tables in web applications (at least if they use Javascript and HTML elements for the UI and the ActiveRecord pattern as in Ruby on Rails)

  • win applications: objects represent GUI objects
  • web applications: objects represent database tables

In the first case, if objects represent GUI objects, then the GOF patterns are more useful than the eaa patterns. In the second case, if objects represent database tables, then the eaa patterns of Martin Fowler are much more useful than the classic GOF patterns, esp. the object-relational patterns. Objects representing database tables are often “flat” and use inheritance only in exceptional cases, due to the common Object-Relational impedance mismatch problems: essential OOP concepts as inheritance are not supported by relational database systems.

Advertisements