Showing posts with label Software Design. Show all posts
Showing posts with label Software Design. Show all posts

Monday, May 28, 2012

Enterprise Application Architecture

A few years a go I read two books about how to create architecture for enterprise applications. Now these books are on my work table. One of them is  Microsoft .NET: Architecting Applications for the Enterprise by Dino Esposito and Andrea Saltarello. Another book is Pattern of Enterprise Application Architecture by Martin Fowler.





Wednesday, May 25, 2011

Observer Synchronization

In some applications you have multiple screens available that display presentations of a common area of data. If a change is made to the data through one of these screens, you want all the other screens to update correctly. However you don't want each screen to know about the others, because that would increase the complexity of the screens and make it harder to add new ones.

See also this post in Martin Fowler's website to get more details. Observer pattern is described here.

Saturday, May 21, 2011

Audit Log

A simple log of changes, intended to be easily written and non-intrusive.

See also this post in Martin Fowler's website to get more details.

Saturday, January 15, 2011

Passive view

Passive view is an approach of the Model-View-Presenter (MVP) pattern. In Passive View the view is devised as thin and passive as possible.

In a Passive View approach, the view is a raw sequence of UI elements with no additional data binding or formatting. The presenter acts directly on the UI elements and works simply by loading data into them.

Advantages:
  • You have an inherently more testable system because the logic in the view is reduced to an absolute minimum.
  • You run no risk at all by not testing the view.
  • The Passive View is very explicit mechanism. This makes is much easer to read the code see what is happening - particularly useful if you're trying to debug when things go wrong.
  • It easy to support multiple GUIs. The presenter ignores any UI technology behind the view.
Disadvantages:
  • A really passive view can be quite cumbersome to write  and maintain and can add a lot of complexity to the presenter. 

See also this post in Martin Fowler's website to get more details.

The core of the MVP is interaction between the view and the presenter, why I don't declared any interface or class for the model.

Here is my implementation of Passive View:

IView.cs
using System;

namespace NOrca
{
 public interface IView : IDisposable
 {
  IPresenter Presenter { get; set; }
  event EventHandler<ActionEventArgs> Action;
  void RaiseAction(object sender, string actionName, params object[] arguments); 
 }
}

IPresenter.cs
using System;

namespace NOrca
{
 public interface IPresenter : IDisposable
 {
  IView View { get; set; }
  void Initialize();
 }
}

Saturday, January 8, 2011

Model View Presenter (MVP)

Model View Presenter (MVP) is a user interface design pattern. It's dedicated to isolate domain logic from the user interface and permits independent development, testing and maintenance of each.

A scenario in which you need to support multiple GUIs MVP is the best choice. It allows to write a presenter and reuse it in Windows and ASP.NET.

MVP is not a pattern that can be implemented quickly, because it can be a bit expensive to implement in relatively simple applications. On the other hand, it shines in enterprise applications, where you really need to reuse as much presentation logic as possible, across multiple platforms.

MVP is based on three actors: the view, the model and the presenter.




Model is a business layer with domain model, a table module or any sort of object model that suits you.

View is an interface that displays data and routes user actions to the presenter.

Presenter is a class which receives input from the view and passes commands down to model. When it gets results from the model it updates the view through the contracted view interface. Also presenter responsible for jumping to the new user interface.

MVP can be separated into Supervising Controller and Passive view.