Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Smalltalk and IoC

I see a lot of IoC frameworks for .Net and Java. Does anyone know why there are no equivalent frameworks for Smalltalk. This is more a philosophy question than anything else. I'm wondering if there is something in the Smalltalk way of doing things that precludes the necessity of having an IoC framework.

like image 616
mchean Avatar asked Oct 28 '08 16:10

mchean


People also ask

How do IoC containers work?

IoC Container It manages object creation and it's life-time, and also injects dependencies to the class. The IoC container creates an object of the specified class and also injects all the dependency objects through a constructor, a property or a method at run time and disposes it at the appropriate time.

What is an inversion of control container?

Inversion of Control is a principle in software engineering which transfers the control of objects or portions of a program to a container or framework. We most often use it in the context of object-oriented programming.

What is IoC and dependency injection and explain in a way to highlight how each are different?

IoC is a design principle where the control flow of the program is inverted. Dependency Injection is one of the subtypes of the IOC principle. Aspect-Oriented Programing is one way to implement Inversion of Control. In case of any changes in business requirements, no code change is required.

What application factor does inversion of control help lessen?

Inversion of control is a practical way to reduce code duplication, and if you find yourself copying an entire method and only changing a small piece of the code, you can consider tackling it with inversion of control.


3 Answers

MVC was invented on Smalltalk and is arguably the original Inversion of Control framework. While somewhat more lightweight than its java counterparts, it has the basic concepts of a model holding the data, a view rendering the data in response to events propogated from a controller.

Less flippantly, Java is actually needs a lot of framework support to do a web application without excessive quantities of boilerplate code. Smalltalk supports programming idioms such as continuations, which allow an author to pretend they are not really writing event driven code. Seaside works like this, giving the benefits of IoC with a somewhat more flexible development paradigm.

EDIT: MVC is a framework for UI's in Smalltalk (arguably it's not really a framework as such, but the class library has built in support for it). It has the inversion of control property in that the view and model respond to events dispatched by the controller - the don't call us, we'll call you property. Inversion of Control is a design pattern within frameworks that's used to reduce the need for extensive boilerplate in java applications. In some definitions of an application framework, Inversion of Control is the main property that is viewed as distinguishing a framework from a library.

like image 193
ConcernedOfTunbridgeWells Avatar answered Oct 15 '22 15:10

ConcernedOfTunbridgeWells


Functions are first class citizens in smalltalk, so it is easy to have IoC without a framework.

like image 38
Null303 Avatar answered Oct 15 '22 17:10

Null303


I think that IOC or the Dependency Injection pattern solves a problem that doesn't really exist in the Smalltalk environment. Smalltalk is an untyped dynamic language and uses message passing to communicate. This makes for objects that are loosely coupled by nature at the language level. Any object can send a message to another object without regard to the type as long as it can process the message. So, as you might guess changing dependencies at any given time is relatively easy and natural. Just have to decide where, when, and how you want to change the dependency.

like image 4
daduffer Avatar answered Oct 15 '22 17:10

daduffer