1 / 55

Developing Windows and Web Applications using Visual Studio.NET

Developing Windows and Web Applications using Visual Studio.NET. Drew Robson. Agenda Session 4: Design Patterns and Deployment. Part 1: Design Patterns N-Tier Architecture LINQ to SQL / Entity Framework Considerations Gang of Four Part 2: Deployment of .NET Winforms apps History

rhoda
Download Presentation

Developing Windows and Web Applications using Visual Studio.NET

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Developing Windows and Web Applications using Visual Studio.NET Drew Robson

  2. AgendaSession 4: Design Patterns and Deployment Part 1: Design Patterns • N-Tier Architecture • LINQ to SQL / Entity Framework Considerations • Gang of Four Part 2: Deployment of .NET Winforms apps • History • Deployment & Updates • Security • Issues & Warnings • Configuration and user settings

  3. N-Tier Application Simplified

  4. Why n-tier? • Separate logic and data access from presentation • Easier to maintain code • Low-coupling • Modularity/Re-use business logic • Easily add a different UI • Web UI • Smart Phone UI • Team Development

  5. Keep the users in mind

  6. Keep the users in mind

  7. Where does LINQ to SQL fit in? • The LINQ to SQL DBML consists of two main parts • DataContext – Data Access • e.g. NorthwindDataContext • Entities – objects representing data in your database • e.g. Customer, Order, Employee • The DataContext talks to the database and the Entities just hold the data

  8. 2 Tiered? • By default it is 2 tiered • I can call my data access from my Web • using (var db = new NorthwindDataContext()){ return db.Customers.ToList();}

  9. Data Data Access/Classes Northwind Northwind.Common.Objects DataContext Entities

  10. UI Data Data Access/Classes WebUI WinUI Northwind Northwind.Common.Objects DataContext Entities

  11. UI Data Data Access/Classes WebUI WinUI Northwind Northwind.Common.Objects DataContext Entities

  12. UI Data Data Access/Classes Business WebUI Services WinUI Northwind Northwind.Common.Objects DataContext Entities

  13. Where does LINQ to SQL fit in? • The entities should be shared across all the projects • UI needs to know how to present the customer • Business logic needs to know what to do with a customer • Data access needs to know how to get and update a customer • What about the DataContext? • It’s currently bundled with the entities • Can we split it?

  14. UI Business Data Data Access Common Objects WebUI BL DAL Northwind WinUI LINQ to SQL DBML

  15. Design Patterns • A design pattern is a general repeatable solution to a commonly occurring problem in software design. • Referred to as GoF (Gang of Four, after their authors). • Considered the foundation for all other software patterns. • This concepts are incorporated in the .Net Framework (eg. The Iterator pattern)

  16. Gang of Four Patterns Creational Patterns Abstract Factory Creates an instance of several families of classes Builder Separates object construction from its representation Factory Method Creates an instance of several derived classes Prototype A fully initialized instance to be copied or cloned Singleton A class of which only a single instance can exist

  17. Gang of Four Patterns Memento Capture and restore an object's internal state Observer A way of notifying change to a number of classes State Alter an object's behaviour when its state changes Strategy Encapsulates an algorithm inside a class Template Method Defer the exact steps of an algorithm to a subclass Visitor Defines a new operation to a class without change Behavioral Patterns Chain of Resp. A way of passing a request between a chain of objects Command Encapsulate a command request as an object Interpreter A way to include language elements in a program Iterator Sequentially access the elements of a collection Mediator Defines simplified communication between classes

  18. Gang of Four Patterns Structural Patterns Adapter Match interfaces of different classes Bridge Separates an object’s interface from its implementation Composite A tree structure of simple and composite objects Decorator Add responsibilities to objects dynamically Facade A single class that represents an entire subsystem Flyweight A fine-grained instance used for efficient sharing Proxy An object representing another object

  19. Windows vs Web forms Which side are you on? Why?

  20. z ClickOnce - The Best of both Worlds Click Once Windows Forms Web Forms Rich UserExperience NetworkDependency Tough ToDeploy Easy To Update Offline Capable Tough To Update Easy To Deploy Limited UserExperience High User Productivity Easy To Manage Fragile “DLL Hell” Responsive & Flexible Complex To Develop

  21. History Remember the good old Windows Installer? Let’s compare it to ClickOnce…

  22. z History: Feel the pain… Windows Installer vsClickOnce

  23. SSW Diagnostics - Clickonce SSW Diagnostics install

  24. Demo Let’s create our first ClickOnce application

  25. z ClickOnce Deployment - How it works? 1. Users download either: Setup.exe (~500kb) Bootsraper which checks pre-requisites Recommended OR 2. Application manifestBoo.application(small but does not check prerequisites)

  26. Demo Let’s update our first ClickOnceapplication

  27. ClickOnce DeploymentDeployment Manifests Architecture based on two XML manifest files: • Application manifest • Authored by the developer • Describes the application • Example: which assemblies constitute the application • Deployment manifest • Authored by the administrator • Describes the application deployment • Example: which version clients should use

  28. z ClickOnce Deployment - Deployment Manifests Application Manifest Deployment Manifest 1.0 Web Page Link to Manifest 1.1 1.0  1.1 Application Manifest

  29. Deployed Files

  30. z ClickOnce Deployment - Bootstraper What does the bootstrapper do? Client PC Web Server Setup.exe Setup.exe Dotnetfx.exe Dotnetfx.exe Mdac_typ.exe a Custom.msi Custom.msi Reboot MDAC detected! Bar.application Bar.application a

  31. ClickOnce DeploymentWhich download to provide? Q: Which way? A: Depends on pre-requisites Q: What if the only pre-requisite is .NET 2? A: TIP: use Request.Browser.ClrVersion; dim verHave as Version = Request.Browser.ClrVersion dim verNeed as Version = new Version("2.0.50727") if ( verHave < verNeed ) then Response.Write("<a href=""./Download/Setup.exe"">") else Response.Write("<a href=""./Download/SSWDiagnostics.application"">") end if

  32. z ClickOnce DeploymentPrerequisites  Missing prerequisites must be installed using separate redistributable packages. The deployment tools in Visual Studio let you install the .NET Framework and other redistributables as a part of your installation (bootstrapping). Note: Prerequisites can be downloaded beforehand into a network location to avoid redundant prerequisite downloads on networks

  33. ClickOnce DeploymentPrerequisites  Before installing an application on a client computer, ClickOnce will examine the client to ensure that it has certain requirements specified in the application manifest. These include: • The minimum required version of the CLR • The minimum required version of the Windows OS • The minimum version of any and all assemblies that must be preinstalled in the GAC Note #1: If you specify an alternate prerequisite location, the packages must exist there; these errors are not handled with ClickOnce Note #2: While selecting your prerequisites, keep in mind that prerequisites might need administrator privileges to be installed.

  34. ClickOnce Deployment - Strategies Install from the Web or a Network Share (Default Strategy) (a Setup.exe) Install from a CD (a Setup.exe) Run the Application from the Web or a Network Share

  35. ClickOnce DeploymentStrategies Compared

  36. ClickOnceDeploymentSetup Interface

  37. ClickOnceDeploymentSetup Options Interface

  38. ClickOnceUpdateHow it works?  • ClickOnce uses the file version information specified in an application's deployment manifest to decide whether to update the application's files. • After an update begins, ClickOnce uses a technique called file patching to avoid redundant downloading of application files. But, what is a File Patching? Compares the hash signatures of the files specified in the application manifest for the current application against the signatures in the manifest for the new version. Note 1: If you use Visual Studio to compile your application, it will generate new hash signatures for all files whenever you rebuild the entire project. Note 2: File patching does not work for files that are marked as data and stored in the data directory C:\Documents and Settings\AdamCogan\Local Settings\Apps\2.0

  39. z ClickOnce Update -How it works?  Update Check? Deployment Framework Service Application Store What is a SHIM?It’s a small piece of software that is added to an existing system program or protocol in order to provide some enhancement. Yes No Installed Startup SHIM My Application

  40. ClickOnce Update - Strategies Checking for Updates after Application Startup background thread locate and read the deployment manifest best for low-bandwidth network connectionsor for larger applications

  41. Checking for Updates before Application Startup ClickOnce Update - Strategies

  42. Making Updates Required ClickOnceUpdate - Strategies

  43. ClickOnceUpdateOptional and Required Updates • For optional updates, the user can either accept or skip the update • This dialog will not appear when an update is required • To make an update required in Visual Studio 2010, you need to set the Minimum Required Version field in the Updates dialog box to match the version of the application you’re currently publishing • We recommend just 4 prior versions

  44. z ClickOnce Update -Blocking Want more control over the update? You may block update checking altogether and provide UI for updates using Deployment API in your application

  45. What if you release a bad version?

  46. AdvancedRolling back updates • The latest 2 versions of the application are stored, the rest are removed. • Clients may restore back 1 application update.

  47. User Settings & Configuration

  48. Two types of settings: User and Application User Settings & Configuration

  49. User Settings • Strongly Typed Settings in code • VB.NET • Project Properties > Settings • In code: My.Settings.ExportPath • C# • In code: Properties.Settings.Defaults.ExportPath

  50. User Settings • User editable • Stored in • C:\Documents and Settings\<username>\Local Settings\ApplicationData • C:\users\<username>\Local Settings\ApplicationData

More Related