[aosd-discuss] Re: AOP for MVC

Juri Memmert memmert at jpmdesign.de
Thu Apr 21 05:44:17 EST 2005


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Nicolas M. Paez wrote:

Hi Nicolas,


> I 'm coursing a subject about design patterns, last week we analize the
> MVC pattern. After that class I came home and make myself the following
> question:
> could it be possible to implement the controller's logic using aspects?
> I mean,  you have the views and the model and to implement the
> comunication between them you define certain aspects that replace the
> classic controllers of MVC.
> I don't know if this is too crazy but I'm working on an article about
> this, when I finish will share my conclusion.
> This recent thread about MVC has gave me some new ideas,  thanks,

of course, this is possible... and depending on how you approach the
problem, you can end up with all three entities, model, view and
controller as one object at runtime but three entities at development
time (not in AspectJ, though).
That construct finally allows a decent level of access control to the
MVC, which in the traditional OO way is one of the most open constructs
I have seen.

You could, of course, define the controller tasks (business rules,
control flow, etc.) as aspects to be applied to all suitable places in
the model and view. You would have to deal with the communication
between the different entities though.
With that I mean that the following call graphs would have to be realized:

	View -> Controller aspect to the view -> Model
	View -> Controller aspect to the view -> Controller aspect of the model
- -> Model
	Model -> Controller aspect to the model -> View
	Model -> Controller aspect to the model -> Controller aspect of the
view -> View

Two of the cases require aspect-aspect communication, which, depending
on the approach, is straight-forward or a bit trickier.

Another issue you need to deal with is stateful controllers, i.e.
controllers that retain information about earlier decisions since both
the aspects connected to the Model and the View need to have access to
this data in a thread-safe manner. But that is possible, too... it just
needs some work...

Hope that helps,

	Juri

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCZ4QAdlXiXRccbPMRArIjAKDaC8Lt+ZL7PdePRs+oWZeXlcJiegCg2c2c
7u81zpmcxtfBsGRX7b9NaUE=
=m3Cm
-----END PGP SIGNATURE-----



More information about the discuss mailing list