Saturday, March 31, 2007

VSLive, Day 4, .NET 3.0 & ASP.NET 2.0

More WPF today and a little bit on ASP.NET

WPF Keynote:

WPF = The best of the Web + The best of the desktop

Powerfull Graphics:

  • Scalable
  • Persisted, you draw something once and it stays on the screen.
  • 2D
  • 3D
  • Media
  • Animation

Next Generation Reading:

  • Pagination
  • Columnization (automatically and dynamically layout for best reader experience, seen new york time, seattle ...)
  • Cleartype
  • Rich content integration

Rich UI Framework

  • Databinding, but not the way we know it from pre-WPF times
  • Layout, trough panels
  • Controls, set of basic controls is available (free grid from XCeed)
  • Templates, The controls don't know what they look like, but ask the parent instead. If nothing specified then a default is being used.

Demo "Allscripts Patient Monitoring" shows WPF in Full power. It can be found at the PDC2005 page of Rob Relyea

"Power of Design, use design for better User Experience."

WPF is targetted to be used by 3 roles:

  • Developer
  • Designer
  • Integrator

http://www.notstatic.com/
http://www.loveyoursoftware.com/

-----------------------------------------------------

What can be animated:

  • Size
  • Position
  • Rotation
  • Color
  • ...

Why do you need animation? Animation fits the way the Human Brain works!

What technology should be chosen?

  • HTML: Online browser based, multiplatform, simple UI
  • WPF/e: Online browser based, multiplatform, (Flash alike) (small download, like Flash, targetted around 2 MB or so)
  • WPF in browser: Online browser, single platform, 3D etc. (requires .NET 3.0)
  • WPF locally: Installed locally with or without online capbilities (requires .NET 3.0)
  • Microsoft Blend (designer for XAML) visual design tool for designing UI.

WPF Examples WPF Application Portofolio

Datatemplate is a piece of XAML (segments) that describes how te represent the data. Switching at runtime of datatemplate is possible!!!

Demo cancer application: www.interknowlogy.com

Demo (from Microsoft site):
ExpenseIT, WPF/e demo, extension is .xbap

Demo
Evolution Media Center

Demo
UniveRSS A cool Reader!

Best reference book at the moment:
WPF Unleashed

Windows forms is at it's end-of-life. It will not being taken very further more.
WPF is in the early stages and will be primarly focussed by Microsoft to improve.

On BIG teams a dedicated developer for creating designs.

Some answers to questions from the audience:

  • XNA for gaming.
  • Deploying WPF is simple, the problem is the integrated video card.
  • XPS is killer for PDF.

-----------------------------------------------------

ASP.Live track: Building a Custom Membership and Role Provider

It's posible to use all the standard ASP.NET controls for login, loginstatus and so forth by implementing your own Custom Membership Provider. By also implementing a Custom Role Provider even the ASP.NET Web Site Administration tool works for managing users and roles.

By default ASPNET.MDF contains the user info. However what to do if you already have a database with user and/or role info. The following figure shows that the Proider Model allows you to replace an existing default provider with your own one in order to accomplish this:


Source: Building a Custom Membership and Role Provider, presented by Chris Franz at VSLive

Override every single method. The following methods are most important:

  • ValidateUser
  • CheckPassword
  • GetUser
  • CreateUser

All "MemberShip Provider Properties" must be overriden.

What about Password protection:

  • Hashed is most secure, other options are Encrypted or Clear.
  • Use Password SALT (this attaches a known string to the password, before encryption and therefore increasing the password length to a fixed length)
  • It requires a Machine Key within the Web.Config. This can not be autogenerated, because of webfarms where each machine needs the same key ...

4GuysFromRolla has a very good book about customizing the Membership with additional information for the user (like address, telephone, ...)

Role Provider Properties and Methods needs to be implemented (more needs to be implemented as with Membership Provider, but not all)

Web.config can exists per directory!

Microsoft provides an example provider: Introduction to the Provider Model on MSDN

Writing a Custom Membership Provider for the Login Control in ASP.NET 2.0, by Dina Fleet Berry

--------------------------------------------------------------

Plain Old Windows Forms tricks:

The tricks being presented by
Billy Hollis were:

  • Tooltips containing custom drawing including images
  • Implementing dynamic resizing without 1 line of code, by using the TableLayoutPanel and FlowLayoutPanel
  • Oval buttons
  • A tutorial form within a grid, trough the controls collection that every control (including grid) has.
  • Field-level security with one line of code.
  • Checking for unsaved data with 2 lines of code, through the DirtyChecker

All examples and sheets will be made available trough www.dotnetmasters.com/VSLifeSF.htm.

Tuesday, March 27, 2007

VSLive, Day 3, .NET 3.0

Some tools that make life easier for editting XML and XSLT
XMLEditor integrated into Visual Studio
  • Create dataschema from example XML
  • Associate schema to XML file enables template insertion of xml fragments

XSLT Debugger

  • Use breakpoints in the XSLT and watch variables.
  • Use breakpoints in the source XML file also.
  • Step into XSLT debugging from a normal code.

Future XSD Designer (availble within "Orcas")
Features including:

  • XML Schema Explorer
  • Entity Data Model (EDM) Wizard:
    Generates class model from existing database
    Drag and drop fields onto a windows form
  • Future EDM Designer:
    This is really cool stuff!!!
    Drag and drop database table onto the Entity Modeler.
    Drag another table over the first and the object combines the related tables into one object.
    Refactor database, while the objectmodel stays intact.
    Is going to work with ADO.NET
    New query language (Entity SQL)
    New Provider (Entity Client)

Data Interaction - LINQ to Entities

  • Query is an database language independent part of the code syntax instead of a database dependent string. It is being checked at compiletime.

Service Oriented Architectur (SOA) Design Patterns with Windows Communication Foundation (WCF)
When metadata is turned on then the WSDL. The URL of WSDL ends typically with <
url>?WSDL. This returns the top document that has a hierarchy of other WSDL documents describing each method or property on the interface. These can be viewed trough url?WSDL=, where reference can be found within the root WSDL.

Next to the WSDL an XSD schema is available also.

It's possible to extend (not change) the contract with an amendent. When a client uses an older proxy then the current service implements the response object has a filled ExtensionData element where the amendent can be found.

Breaking changes should be created within a new namespace. Nothing new here ...

Windows Presentation Foundation (WPF)
All possibilities from gaming engines made available within the .NET Framework.

WPF can call on GPU tools:

  • Transforms
  • Rotate
  • Scale
  • Gradients

Handles for windows nog longer exists. WPF renders controls within the main WPF window, which is the only window.

Since I have some experience with OpenSceneGraph, which is an excellent engine for 3D visualisation, I automatically compare WPF with the OSG. XAML is a declarative way of describing a scene, in some way this can be compared to a "scene graph" stored in an .OSG file. XAML however has the advantage that it can be verified against a scheme. I do not know whether both can be fully compared and hope to find that out within the next couple of days.

WPF uses style (wich can be compared to stateset in OSG???). Templates are more powerfull styles.

WPF uses scRGB values. -scRGB(0.5, 0.75,1.0).

Windows Communication Foundation (WCF)
Use Patterns & Practices for setting up Windows Communication Foundation. Visual Studio integrated CTP does a bad job for any more complex than very simple configurations.

WCF can be used for any layer (or better tier) that you want to implement for your solution. WCF can be scaled up (network boundary) or down (appdomain cross) later on, i.e. by implementing another protocol.

WCF Gives you:

  • Hosting
  • Instance Management
  • Asynchronious calls
  • Reliability
  • Transaction Management
  • Disconnected Queued Calls (i.e. trough MSMQ)
  • Security
  • An extensibility model for customizing nearly every aspect of its behavior.
  • Easy Interoperability (i.e. with Java by using basicHttpBinding, and JAX see ...)

Directly addresses .ASMX (and general Web Service) deficiencies:

  • Performance
  • Security
  • Transactions

So use WCF instead of .NET Remoting or .ASMX Web Services. These last 2 are deprecated. WCF fully replaces them, and offers a lot of other options more.

VSLive, Day 2, .NET Day

Today various speakers held several presentations and demos. This post summarizes the interesting things I heard today over all these presentations.

Visual Studio next generations
Codename "Orcas". CTP has been launched in March 2007. RTM is scheduled for late 2007.
Codename "Rosario". Will build further upon Orcas, featuring even more Team productivity trough their Team System.

WPF Demos that Rocks
Fabrikam. A virtual webseller of clothing, an example that uses SharePoint Server and WPF. Can not find it on the internet.
Family explorer by Vertigo. Will be made public by the end of this week.
WPFWonderland is all about WPF and WPFe

Vista compatibillity
User Account Control (UAC) is a new feature (note that a feature is not always an improvement) that influence applications running on Windows Vista. UAC is responsible for blocking access to functionality that requires admin priviliges.


When a user (even with local admin rights) starts an application, it will normally start without the admin privilige.

There are two ways to deal with admin tasks within an application:

  • Use a manifest that specifies that an application needs the admin privilige.
    This results in an application that upon starting notifies the user that the priviliges are being elevated to the admin level.
  • Elevate privilige "just in time" to the admin privilige within a running application, that started with normal privilige.
VSTO Rocks!
Visual Studio Tools for Office is an SDK that enables you to write fully blown Add-Ins for all office applications. This enables you to combine the power of .NET custom applications that are fully integrated into i.e. Excel or Powerpoint. With a few lines of code it's possible to add items to a custom ribbon. These add-ins can be document based or application based.

The document and Add-In can exist locally on the PC or somewhere remotely on the network.
3 scenario's for these customizations exist:

  • Local document, local Add-In
  • Local document, remote Add-In
  • Remote document, remote Add-In

One remark must be made that the full functionality of VSTO only works under VS 2005 Team System Edition. Some functionality will not work under VS 2005 Pro.

Database
Schema can be placed under source control trough the use of scripts. Every obejct within the database gets it's own script, like table, index and so on.

Developing a database project with Visual Studio looks very similar to devloping source code within a project. A live database can be imported and brought under source control. Check in and check out is very similar as with code. DBA Developers can change the database offline. When ready the DBA can review and update the live database.

Just renaming a field or so leads to "compile errors", because the field could be referenced. "Rename Refactoring" is capable of updating a field and all the places where it is referenced. This is very powerfull. This comes (optionally) with a "preview changes" dialog and it's also possible to use undo.

Database build, deployment and data generation can be integrated into MSBuild. Two types of deployments exist:

  • Full
  • Incremental
    This only deploys the difference between the target and the project.

Unit testing is now available, so you're existing code does not break upon changes.

PowerTools will be distrubuted trough the web. These include:

  • Move Schema Refactoring
  • Disambiguate Schema Refactoring
  • sp_rename Generation
  • Data & Schema Compare Build Tasks
  • SQL Script Pre-Processor
  • Dependency Tree Viewer
  • API Access to Schema View

ASP.NET
Brian Randall from MCWTech

"There is NO MAGIC to make your applications run faster"

Tools:

  • Process Explorer by Sysinternals, can be dragged over the application.
  • Process Monitor by Sysinternals.
  • Performance Monitor
  • Visual Web Developer 2005 Express Edition

    $$$
  • VS 2005 TE for Software Testers

    $$$$$
  • VS 2005 Team Test Load Agent

Tips:

  • Use Release Builds! If the release item is unavailable it could be that this option can be found in the web.config under the compilation tag.
  • Minimize Exceptions, because they are expensive.
  • Optimize Data Access.
    Avoid using unmanaged classic ADO. Use
    stored procedures for complex functionalities.
  • Design for Caching
    Output caching (caching a whole page hat has been requested)
    Fragment Caching (caching regions of a page)
    Cache API

Visual Studio Team Test lets you easily create repeatable tests, that can be adjusted to generate random requests to the ASP.NET page under test. These tests can be used within a load-test scenario. Performance counters help in determining where bottlenecks can be found.

Monday, March 26, 2007

VSLive, Day 1, Pre-Conference workshop (CSLA)

Build Distributed OO Apps in .NET 3.0

Speaker: Rockford Lhotka

Most important things heard today:


N-Tier is not the same as N-Layer.
N-Layer is always good, especially to structure your code, which makes it maitainable.
N-Tier involves a process-boundary, or even a network boundary. Therefore a tradeoff must be evaluated from the following:

  • Performance
  • Scalability
  • Fault tolerance
  • Security

Formula to calculate the Concurrent Transactions Per Second (ctps):
ctps = (NrOfUsers / UserThinkTime) * TransactionDuration

Split up Business Logic Layer in Client and Server.
In order to use business logic close to the UI for a rich UI feeling and close to the data layer for multi-object logic, one could split the business layer.

The splitted layer could be conneced using a DataPortal, which encapsulates the underlying mechanism (Remoting, WCF, Webservice, etc) of transfering the business objects from the client to the server and back. The DataPortal is an implementation of the Channel Adapter Design Pattern.

Using event and (binary) serialization.
Be careful with events and serialization, because you might serialize more than expected, depending on the serializer being used. Serializers that serialize (private) fields will also try to serialize the class that has an event subscription on the class, because it's referenced in the list of subscribers. 3 possibilities from here:

  • This is planned to happen.
  • This is not planned, but the subscriber class is serializable. This results in a larger performance and/or memory footprint hit, then expected.
  • This is not planned and the subscriver class is not serializable. This will result in an exception being thrown.

Solution for preventing the subscriber class from being serialized is to implement your own implementation of AddHandler, RemoveHandler and RaiseHandler.

The CSLA Framework.

"Rockford Lhotka’s CSLA .NET framework is an application development framework that reduces the cost of building and maintaining applications.

The framework enables the use of object-oriented design as the basis for creating powerful applications. Business objects based on the framework support many advanced features to simplify the creation of Windows Forms, Web Forms and Web Services interfaces." (copied from CSLA website)

The CSLA Framework combines (when needed) the best of object orientation and databinding, by providing a set of base-classes for objects that already common functionality for implementing IBindable.

Als it provides a method for defining Validation and Authorization rules. One can add (static) methods that add rules to a rules collection. For Authhorization each getter, setter and method must start with an additional call to a generic validation method to determine whether the current user may access the getter/setter/method in question. For Validation the setter must add an additional call to a generic validation method. Important here is that a "bad value" must be accepted and no exception may be thrown. The databindable components or errorprovider must examine an object to determine whether it has valid values for each property.

This framework could really enforce a jumpstart when implementing an object oriented design, that needs to be coupled preferably by standard .NET databinding.

LINQ, Language Integrated Query.

LINQ is a Microsoft Project that adds a native quering syntax to .NET Framework programming languages, therfore reducing the roughly 20 lines of code needed to fetch data back to 3 lines.

Additional CSLA resources:

Friday, March 23, 2007

Hello world!

These are the famous words for an application written with a new technology (at least for the developer in question). And blogging is new to me.

So here's my blog.

I don't know whether I'm going to feed this a lot, but at least it gives me some space on the internet, where I can leave my toughts about software development.