A Simple start with MVP in Delphi for Win32, Part 2

Some month ago I wrote a simple article about an MVP variant called PassiveView. That example was very simple. Now I’ll present a more “advanced” version of that example. The main problem with first example was the following method: procedure TfrmCalculatorView.FormCreate(Sender: TObject); begin //Link controls with related interface IFirstOperand := TGUIEdit.Create(EditFirstOp); ISecondOperand := TGUIEdit.Create(EditSecondOp); ICalcResult := TGUIEdit.Create(EditResult); IOperators := TGUISelectableList.Create(ComboOperators); IError := TGUIEdit.Create(EditError); //link view and presenter FPresenter := TCalculatorPresenter.Create(Self); //<<– THIS IS THE BAD LINE end; The “BAD” line links the View with the Presenter but it’s in the view code, so this is meaning that View KNOWS the…
Continua a leggere →

A simple Dependency Injection Container for Delphi

As wikipedia says: “Dependency injection (DI) in computer programming refers to the process of supplying an external dependency to a software component. It is a specific form of inversion of control where the concern being inverted is the process of obtaining the needed dependency. The term was first coined by Martin Fowler to describe the mechanism more clearly.” Many of us have already read this historical article from Martin Fowler about dependency injection pattern, but actually there isn’t a real framework for implement dependency injection in Delphi. There are already the following implementation for DI in Delphi Emballo (work with…
Continua a leggere →