MVP: Comunicazione tra Presenter e View

In questo periodo sto dedicando un po' di tempo all'approfondimento del pattern MVP e delle sue sfumature. Spesso quando devo scrivere il presenter mi chiedo in che modo questo debba dialogare con una view: ovvero se tramite metodi pubblici sul presenter chiamati dalla view oppure eventi sulla view sottoscritti dal presenter.

Gli autori di questo articolo a cui sono giunto grazie a questo post di Antonio suggerisco questo approccio:

Communication with the presenter is made possible by the use of an event subsystem to loosely couple the model and view to the presenter. The most common case is for the view to fire events that the presenter consumes, though model triggered events are also possible. Using events to communicate with the presenter allows for separate packaging of components, reduces compilation dependencies, and allows for the same view to be connected to presenters with different behaviors.

Soprattutto l'ultima frase mi sembra un buon motivo per seguire questo approccio. Ridurre l'accoppiametro tra view e presenter ed in caso di necessità poter riutilizzare le view agganciandole a presenter differenti.

posted @ venerdì 9 marzo 2007 16.26

Print

Comments on this entry:

# re: MVP: Comunicazione tra Presenter e View

Left by Tommaso Caldarola at 09/03/2007 16.43
Gravatar

# re: MVP: Comunicazione tra Presenter e View

Left by Antonio Ganci at 09/03/2007 17.19
Gravatar
In realtà nella mia esperienza mi sono trovato raramente a intercambiare view, presenter o model. Il vero vantaggio di questo approccio è la ui testata; gli altri vantaggi illustrati non giustificano secondo me lo sforzo nell'implementare l'MVP.
Inoltre il presenter first come descritto nell'articolo ti obbliga a pensare alle interazioni tra la view e utente in questo modo poni più attenzione a creare una ui usabile.

# re: MVP: Comunicazione tra Presenter e View

Left by Maccari Claudio at 09/03/2007 18.06
Gravatar
@Tommaso
Grazie per il suggerimento. Guarderò anche quello

@Antonio
Sicuramente il vantaggio più grande,come dici tu, sta nell'avere unit test anche sulla UI.

# Comunicazione tra View e Presenter

Left by Pingback/TrackBack at 09/03/2007 19.23
Gravatar
Comunicazione tra View e Presenter

# Re: MVP: Comunicazione tra Presenter e View

Left by Michele Bersani at 09/03/2007 23.50
Gravatar
Mah... basta un'interfaccia e un Service Locator per disaccoppiare totalmente Presenter e View.
E cosi' si puo' beneficiare anche di DI e cambiare il tipo della View solamente modificando un file di config.
Personalmente tento di evitare eventi se possibile...specialmente in VB con tutti quegli Handles che se non rimossi propriamente ti generano dei memory leaks da paura...

# Zoloft generic.

Left by Generic zoloft. at 19/08/2007 7.45
Gravatar
Generic zoloft. Zoloft generic. Zoloft generic brand. Depsert generic zoloft mg tablets. Date zoloft became generic.

# Pink pornstars.

Left by Pornstars. at 05/01/2010 5.49
Gravatar
Famous pornstars. Pornstars. Nude pornstars. Pink pornstars.

# Topamax side effects.

Left by Topamax. at 30/06/2011 20.45
Gravatar
Topamax disscussion board. Topamax.

# What is aleve made of.

Left by Prescription strength aleve. at 02/07/2011 23.54
Gravatar
Can i take aleve with amytriptyline. Can i take ibuprofen with aleve. Drug aleve. Diabetics taking aleve. Directiopns on taking aleve.

# Denver mobic attorney.

Left by Mobic medicine. at 03/07/2011 9.22
Gravatar
Buy mobic. How does mobic interact with lithium. Mobic meloxicam. Mobic. Mobic side effect.

# Cephalexin 500 with out a prescription.

Left by Cephalexin. at 05/07/2011 8.53
Gravatar
Cephalexin cold symptoms. Scalded skin syndrome cephalexin. Cephalexin. Cephalexin for pets.

# Aciphex.

Left by Aciphex. at 06/07/2011 20.09
Gravatar
Aciphex side effects. Aciphex weight gain. Aciphex 30 rebate.

# Effexor.

Left by Effexor side effects. at 07/07/2011 2.09
Gravatar
Drug detox for effexor. Effexor.

# Azithromycin uses.

Left by Azithromycin. at 07/07/2011 11.46
Gravatar
Drug interaction levoflaxin azithromycin. Alcohol and azithromycin. Azithromycin. Azithromycin buy.

# Fatal dose of soma carisopradol.

Left by Pictures of soma 750 mg.. at 07/07/2011 14.18
Gravatar
Soma drug testing. Buy soma online. Drug soma. Soma prescription medicine. Soma cube. Soma triathlon.

# Plavix.

Left by Plavix swelling breathing difficulties. at 08/07/2011 9.21
Gravatar
Plavix. Plavix stemi. Plavix drug_monograph.

# Harmful effects of caffeine.

Left by Caffeine side effects. at 08/07/2011 23.05
Gravatar
What is in caffeine.

# Buy levothyroxine.

Left by Side effects of levothyroxine. at 09/07/2011 5.11
Gravatar
Side effects of levothyroxine. Is levothyroxine vegetarian. Soloxine conversion to levothyroxine. Kelp to replace levothyroxine. Can levothyroxine affect anti-tpo test. Taking kelp as levothyroxine replacement.

# Sertraline.

Left by Sertraline. at 09/07/2011 8.28
Gravatar
Sertraline.

# Switching from effexor xr to lexapro.

Left by Will chantix react with lexapro. at 09/07/2011 18.24
Gravatar
When will lexapro generic be available. Medication lexapro. Prescription only medice lexapro 10mg. Weight gain lexapro. Buspar with lexapro. Side effects of lexapro.

# Side effects of actos.

Left by Dangers of actos. at 09/07/2011 19.46
Gravatar
Actos actos. Actos. Anemia and actos. Dangers of actos.

# Amitriptyline.

Left by Amitriptyline. at 10/07/2011 6.31
Gravatar
Headache amitriptyline. Amitriptyline. Amitriptyline zoloft interaction. Amitriptyline for migraines.

# Prilosec vs nexium.

Left by Price of nexium. at 10/07/2011 19.17
Gravatar
Generic nexium. Nexium sideeffects. Nexium. Nexium reactions.

# Levaquin.

Left by Levaquin. at 14/07/2011 0.28
Gravatar
Levaquin. Levaquin and metronidazole.
Comments have been closed on this topic.