Understanding IoC : What exactly is the code written in ruby doing?

by Vivek_Shukla   Last Updated August 13, 2019 20:05 PM

I was trying to read the difference between a library and a Framework. And from one of the post, it became clear that the biggest difference is the inversion of control, i.e. where Framework calls your code.

Martin Fowler's article about IoC seems pretty good except It is in Ruby Language which I don't know, what exactly is the following code doing?

  require 'tk'
  root = TkRoot.new()
  name_label = TkLabel.new() {text "What is Your Name?"}
  name = TkEntry.new(root).pack
  name.bind("FocusOut") {process_name(name)}
  quest_label = TkLabel.new() {text "What is Your Quest?"}
  quest = TkEntry.new(root).pack
  quest.bind("FocusOut") {process_quest(quest)}

My Understanding is that when code flow is more event-driven or generally speaking whenever any .Net features like Anonymous Types, Extension Methods, Lambda Expressions etc. are used then Inversion of Control can be percieved

Related Questions

Difference of how Spring and EJB use IOC

Updated November 29, 2016 08:02 AM

How much time/work does Rails save?

Updated May 28, 2015 09:02 AM