Jorge's profileJorge's SpaceBlogListsSkyDrive Tools 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

Jorge Matos

Occupation
  View Jorge Matos's profile on LinkedIn
March 06

Vista, Windows Update and Error 8024402C

My 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)

  1. Open Internet Explorer.
  2. In the "Tools" menu, select "Internet Options".
  3. Click on the "Connections" tab.
  4. Click on the "LAN Settings".
  5. Clear the entries in "Use automatic configuration script" and uncheck "Automatically detect settings."
  6. Click on the "Advanced" button.
  7. Please delete any entry in the Exceptions section,
  8. Click "OK", and return to the previous window. Uncheck "Use Proxy Server for your LAN", and click "OK" to accept the changes.
  9. Quit Internet Explorer.

Step 2: Reset Proxy Cache

  1. Click the "Start" Button, click "All programs", and click "Accessories".
  2. Right-click "Command Prompt", and click "Run as administrator". If you are prompted for an administrator password or confirmation, type the password or provide confirmation.
  3. Type "netsh winhttp reset proxy" (without quotes) at the command prompt, and press Enter.
March 04

Model View Presenter Design Pattern

The 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.

Responsibilities

View:  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 code

clip_image002

This sample code retrieves a Blog post for display.

clip_image001

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.

clip_image001[4]

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).

clip_image001[15]

The Model in this case is the PostService class  which implements the IPostService interface.

clip_image001[17]

Notice the use of the new C# 3.0 feature of “Auto-Implemented Properties” for the Title and Body properties.

clip_image001[19]

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.

 

References

Martin 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

http://www.dnrtv.com/default.aspx?showID=14

February 20

Switched from Google Blogs

 
I'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! Smile