| Jorge's profileJorge's SpaceBlogListsSkyDrive | Help |
Jorge's Space"Any intelligent fool can make things bigger and more complex... It takes a touch of genius - and a lot of courage to move in the opposite direction."... - Albert Einstein |
||||
|
Public folders
|
March 06 Vista, Windows Update and Error 8024402CMy windows update hasn't been working for the last 3 months. I'm running Windows Vista Ultimate and Every time I tried to get an update I’d get an error code: 8024402C. My windows update log file mentions that it tried to use a proxy but it fails. With the help of MS Support I’ve finally got it working again. I thought I’d share the solution that worked for me. Step 1: Reset proxy (for LAN connection)
Step 2: Reset Proxy Cache
March 04 Model View Presenter Design PatternThe Model View Presenter (MVP) pattern provides a separation of concerns within the user interface layer of an application. The primary purpose for the pattern is to factor out most of the processing or business logic out of the form or web page (View) into another class (the Presenter), in order to simplify the view and increase the test coverage. The more code there is in the view (or user interface), the harder it is to get automated test coverage for it. The Presenter will talk to (or orchestrate) services or business components (collectively known as the Model). The View becomes very simple and does not have any business logic in it at all. This variation of the MVP pattern is known as the “Passive View” pattern. Another variation of MVP “Supervising Controller” allows the advantage of data binding. The “Passive View” is favored by most agile programmers due to the increased testability it provides. ResponsibilitiesView: Handles all controls, provide public properties and methods so that the Presenter can retrieve data from the View or pass data to the View. The View can call Presenter methods in response to user actions such as a button click, but the View should never pass data directly to the Presenter. The View should implement an interface that the Presenter can use to communicate with the View. The Presenter should not know the true identity of the View, only the interface. That allows the Presenter to be platform agnostic, it can be re-used for Windows, Web or a smart devices.
Presenter: Exposes public void methods that the View can call to ask the Presenter to do something. The presenter talks to the View via an interface. The presenter can ask the View for information, call methods on the view or pass data to the view. The Presenter should also talk to services or business components via interfaces.
Model: Services or business components that can be used by a Presenter to perform a task. The Model must implement an interface that the Presenter can use for communication. Diagram and sample codeThis sample code retrieves a Blog post for display. Notice how the View (Form1) implements an interface called IPostView. This interface only exposes what the Presenter needs to get from the view. The View also exposes methods or properties that the Presenter can call on the View. Notice the Presenter has 2 constructors that follow the Constructor Dependency pattern, which allows you to test the Presenter by mocking out the dependencies (in this case Form1 and PostService). The Model in this case is the PostService class which implements the IPostService interface. Notice the use of the new C# 3.0 feature of “Auto-Implemented Properties” for the Title and Body properties. The interfaces used by the View and Model. I find that this design pattern works very well in simplifying the code that might normally be embedded in the user interface layer. The less code in the UI layer the better. This reduces the temptation a developer might have to write business logic in the user interface code. The ability to increase your code coverage is also a nice benefit of this pattern. The Presenter can be tested in isolation with the View and the Model mocked out with stub objects that implement the same interface or with a mocking framework such as RhinoMocks.
ReferencesMartin Fowler http://www.martinfowler.com/eaaDev/uiArchs.html http://www.martinfowler.com/eaaDev/PassiveScreen.html http://www.martinfowler.com/eaaDev/SupervisingPresenter.html Humble Dialog Box http://www.objectmentor.com/resources/articles/TheHumbleDialogBox.pdf http://jeremydmiller.blogspot.com/2005/06/simple-example-of-humble-dialog-box.html MVP for WinForms http://www.timrayburn.net/2006/10/12/Model+View+Presenter.aspx http://codebetter.com/blogs/jeffrey.palermo/archive/2005/04/02/128598.aspx http://danbunea.blogspot.com/2005/11/model-view-presenter-is-testing_27.html MVP for ASP.NET http://codebetter.com/blogs/jeremy.miller/archive/2006/02/01/137457.aspx http://codebetter.com/blogs/jeremy.miller/archive/2006/02/16/138382.aspx http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/default.aspx Presentations Jean Paul Boodhoo on Model/View/Presenter February 20 Switched from Google BlogsI've decided to give Windows Live Spaces a try, look for new blog posts soon!
My old blog is still at http://jorgelmatos.blogspot.com but I won't blogging there! |
|||
|
|