preload
Mar 31

I am very fond of using patterns when developing and I have seen the importance of patterns in several projects. When it comes to Windows Phone 7 development I guess the most popular pattern to use is the Model-View-ViewModel (MVVM) pattern. I have successfully used a different (but still quite similar) pattern for several mobile app projects. In this post I will show you how to use the Model-View-Presenter (MVP) pattern when developing Windows Phone 7 applications.

I will not go into details describing the MVP-pattern since I covered that pretty well in another post I wrote a while back: Using Model-View-Presenter (MVP) pattern in Compact Framework. What I will do is to show an example on how you can design your Windows Phone 7 app architecture to use MVP-pattern. I will use the same login example as I used in the Compact Framework post. You can see that the biggest difference between how you do this for CF and WP7 is the data binding capability in WP7.

Before we go to the code a short summary on the essence of the MVP-pattern: The View is only responsible for displaying output to the user and receiving input from the user. The View will always ask the Presenter what to do with the data and the Presenter will pass the data on to the View. The Model consists of business objects and can be used both by the Presenter and the View. The figure below explains the MVP-pattern.

Now it’s time to have a look at the code. For this example I have created a solution called MvpDemo. To this solution I have added two projects. One Silverlight for Windows Phone – Windows Phone Application project called MvpDemo and one Silverlight for Windows Phone – Windows Phone Class Library called MvpDemo.MVP.

Continue reading »

Tagged with:
May 27

I have just completed reading Agile Principles, Patterns and Practices in C# by Robert C. Martin and Micah Martin. I learned a lot while reading this book, particularly about patterns. This book contains a lot of information with its’ 38 chapters and 700 pages, but it is written in a easy to read language and have plenty of figures and code examples. I think that everyone involved in software development will benefit from reading this book, particularly developers and solution architects.

Section 1 in this book focuses on agile development covering practices, Extreme programming, planning, testing, refactoring and a case study.

Section 2 is about agile design with principles and UML diagrams. Principles taught: The Single Responsibility Principle, The Open/Closed Principle, The Liskov Substitution Principle, The Dependency-Inversion Principle and the Interface Segregation Principle.

Section 3 is a case study where patterns are taught through a Payroll case. Patterns: Command, Template method, Strategy, Facade, Mediator, Singleton, Monostate and Null Object. This section also explains how create simple use cases from user stories, find underlying abstractions and implement the use cases.

Continue reading »

Tagged with:
Mar 06

This post will first explain the advantages you get from separating language and hard coded text from your application code and then show code examples in C# helping you getting started implementing language and text separating.

Lets have a look at the advantages:

Multi language support

When you separate the language from your application code it takes little effort to implement multi language support for your application. The only thing you need to do is to translate your original language file into the languages your application shall support and select on start up what language file to parse.

Continue reading »

Tagged with:
Jan 08

We have entered 2010 and I am now actually enjoying (a lot of people are complaining) the cold and nice winter weather in Oslo (20 degrees Celsius below freezing). I have had a hectic start on this year preparing the start up of a large national project. This is very exciting and I find this a promising start on 2010.

2009 was the year that I started this blog. It has been interesting writing the posts and communicating with my readers. I have also learned a lot in 2009 and I will for sure continue writing posts on topics I find interesting.

To summarize 2009 I will list my top ten posts in 2009. This list is created based on visitors stats and my own rating of the posts (there are always some posts that you are more proud of and have spent more time writing than others).

Creating gradient background with transparent labels in .NET Compact Framework

Continue reading »

Tagged with:
Jul 02

I have been involved developing a C#.Net Compact Framework project were we are using Model-View-Presenter(MVP) pattern for quite a while now and I would like to share my experiences learned during this project with you.

First of all, using MVP in a Compact Framework project is done exactly the same way as you would do it for standard C#.Net (or any other programming language). For some reason (unknown to me) developers tend to skip using patterns in mobility projects. I guess they think that good architecture is not necessary in smaller projects, like mobility projects often are. Wrong! As a developer you should strive to achieve good architecture in your projects no matter what size or complexity they have. What pattern to choose is of course another discussion. We chose to base the project architecture on the MVP-pattern and succeeded doing so. Let me walk you through how we ended up using it.

The figure below shows how the MVP components interact with each other. The View are implemented in the screens (forms) and the Presenter presents the data to be displayed to the View. The Presenter is responsible for the business logic and retrieve/save data to the Model. The Model will often interact with a Data Access layer (left out in this example for simplicity). The Model will also have business specific objects that both the Presenter and View can use, but the View will never ask the Model for data or save data to the Model.

MVP

Continue reading »

Tagged with:
Apr 13

pnp_logoI recently downloaded and read the Mobile Architecture Pocket Guide by Microsoft patterns & practices. The purpose of this guide is to improve the effectiveness when building mobile applications on the Microsoft Platform. The primary audience for this guide is solution architects and development leads.

Chapter overview (quoted from the book)

• Chapter 1, “Mobile Application Architecture,” provides general design guidelines for a mobile application, explains the key attributes, discusses the use of layers, provides guidelines for performance, security, and deployment, and lists the key patterns and technology considerations.
• Chapter 2, “Architecture and Design Guidelines,” helps you to understand the concepts of software architecture, learn the key design principles for software architecture, and provides the guidelines for the key attributes of software architecture.
• Chapter 3, “Presentation Layer Guidelines,” helps you to understand how the presentation layer fits into the typical application architecture, learn about the components of the presentation layer, learn how to design these components, and understand the common issues faced when designing a presentation layer. It also contains key guidelines for designing a presentation layer, and lists the key patterns and technology considerations.
• Chapter 4, “Business Layers Guidelines,” helps you to understand how the business layer fits into the typical application architecture, learn about the components of the business layer, learn how to design these components, and understand common issues faced when designing a business layer. It also contains key guidelines for designing the business layer, and lists the key patterns and technology considerations.
• Chapter 5, “Data Access Layer Guidelines,” helps you top understand how the data layer fits into the typical application architecture, learn about the components of the data layer, learn how to design these components, and understand the common issues faced when designing a data layer. It also contains key guidelines for designing a data layer, and lists the key patterns and technology considerations.
• Chapter 6, “Service Layer Guidelines,” helps you to understand how the service layer fits into the typical application architecture, learn about the components of the service layer, learn how to design these components, and understand common issues faced when designing a service layer. It also contains key guidelines for designing a service layer, and lists the key patterns and technology considerations.
• Chapter 7, “Communication Guidelines,” helps you to learn the guidelines for designing a communication approach, and understand the ways in which components communicate with each other. It will also help you to learn the interoperability, performance, and security considerations for choosing a communication approach, and the communication technology choices available.
• Chapter 8, “Deployment Patterns,” helps you to learn the key factors that influence deployment choices, and contains recommendations for choosing a deployment pattern. It also helps you to understand the effect of deployment strategy on performance, security, and other quality attributes, and learn common deployment patterns.

Continue reading »

Tagged with:
Subscribe to my feeds Follow me on Twitter
DZone MVB