Here's a simple explanation of Inversion of Control, without referring to Dependency Injection (borrowed from Fowler):

When you write a command-line Java app, say taking input using
System.in.readln() and all that, your main thread is in control. You can determine exactly what happens when and in what order.

With a Swing application, the Swing framework of course calls your event handlers. The Swing thread is clearly in control. To get anything done outside event handlers you have to work through
javax.swing.Timer or SwingUtilities.invokeLater() etc. And even then you are not really in control because your cannot deterministically determine when or in what order (with respect to other events) your code will get called.

Yes, it's really that simple. Frameworks (GUI or otherwise) generally invert control of what happens next from your code to themselves. Why it is a good idea for a specific framework to follow IoC is a domain-specific matter, though it basically comes down to the framework having the best knowledge of what needs to happen next (because of encapsulation, issues of responsibility etc).

-- 
Ben van der Merwe
[EMAIL PROTECTED]

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CTJUG Forum" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/CTJUG-Forum
-~----------~----~----~----~------~----~------~--~---




Reply via email to