Thursday, November 4, 2010

Code Correctness and Smart Tools for .Net developers

Code Correctness and Smart Tools for .Net developers - Dino Esposito

    Testability is the capability of a system to be tested (especially in an automated way)  Created a Design-for-Testability. Three things that define testability: Visibility, Control, Simplicity.  .Net 4 instantiates Code Contracts to try and meet this,  And some tool to help check Rewriter, and Static Checker.  Rewriter, rewrites your code, adding checks into it.  Three basic types of code contracts are: PreConditions, Postconditions, Invariants.  Contracts must be specified in the body of methods.  Can have different code contract per build type. Contracts are plain code, playing a declarative role, like attribute, but more expressive.
    These Contract codes asserts are disabled in release builds. Use Requires method to check for PreConditions.  Contract.Requires statements are run in order listed, and must be run before any other code is run.  Use Contract.ContractFailed method to customize messages.  Use Ensures or EnsuresOnThrow Method for post condition checks. Use Invariants method to check invariants, these must all be defined for a class in one place. Will use the contractInvariantMethod attribute on any method you want to check for invariants.
    These seem like they could add a bit more code writing to implement,  and should be researched more before we would think about implementing it.

.Net 4.0 New Features in the Language and Framework

.Net 4.0 New Features in the Language and Framework - Kathleen Dollard
Kathleen@mvps.org

       It is backwards compatible, but must specifically target 4.0 libraries for all projects.
       There has been about 300 deprecated classes.
       These include old security, dropped oracle support (must get providers from oracle to connect to it)  Improved garbage collection.
       Code Contracts are new, the need the diagnostics.contracts imported.  A Way to protect your quality of code. (was mentioned briefly)
       Can  label code for Security - Transparent, Critical, Security Safe Critical.  By default old code was SecuritySafeCritcal, almost all code can be Transparent.
       Optional and named parameters can now be nullable
       No line continuation characters needed
       Don’t need to add get/set when doing properties unless you need to do something non standard
       Lambda expressions can contain multiple lines, and return voids (by calling subs)
       There are new data types bigInterger(7.8 e56), Complex, Tuple (has  multiple values (3-7)) , SortedSets, Lazy<T> encapsulate type that can be created later), Task (takes some thing to do)(will be used by async calls in .net 5.00)   
       File system enumerations, gets files and directories as you need them
       Flag attribute is used bitwise enumerations. Added HasFlag to check flag values.

Using Silverlight Animations to Improve User Experience in LOB Applications

Joel Neubeck (joel@neubeck.net)

Visual State Manager and Visual States are the key points to understand.  Microsoft toolkit (Transitioning Content Content).   Example he is showing is creating a control template in his Styles.xaml.

Using easing for your movements.  Edit the existing design template.  In Sl4, there are some provided behaviors such as the fluidmovement behavior.  Use the powereasing function.  Use the state manager to change the beforeloaded state. 

Create our own states, or skin another control’s states (such as a checkbox’s checked or unchecked state) to triger our custom defined states.

Textboxes highlight on focus.Go to the expression gallery to find some examples.  This example shows using a custom tooltip to highlight the borders. 

Question I have is how much should I be concerned about upward compatibility of my customizations? 

Silverlight Data Integration Options and Usage Scenarios

Dan Wahlin http://www.TheWahinGroup.com (@danwahlin)

He makes use of the Silverlight Enabled – WCF service).  Simpler.  Class decorations are no longer required.  Deprecated. 

Simpler version of fiddler.  Trick to get fiddler to recognize localhost is to append a period (http://localhost.).  Will throw an issue if you don’t have a client access policy file.

WCF binary inspector – a plugin for fiddler adds a WCF tab, allows you to decode your binary encoded message.

Another option for faster performance is to use TCP ports (faster, but limited ports).

WCF Duplex Service – Have server push data to your client app. 

Demo of sending video 10 fps via WCF and using TCP bindings.  Not as fasy using HTTP bindings.

Discussed with him after session to confirm that nothing has improved with WCF 4.0 and SL 4 in terms of solving the issue of duplicating classes if you share classes across services.  IE, we are doing the correct approach when we share class libraries between WCF and SL apps.  He couldn’t believe that Proliance was still using WSE, FWIW.

Write your own Xaml Framework

Write your own Xaml Framework - Billy Hollis
www.billyhollis.com

Visual and Logical Trees
Logical tree is the tree you see with elements composed inside other elements.  Visual tree contains everything that effects rendering.  SilverLight has Visualtreehelp, WPF has logicalTree helper too.  He has written a findResouce extension, that can be used to programmatically have code search for resource.

Dependency Properties
Properties elements are usually dependency properties, thes properties depend on factors.  Get/set methods will cll get value/set value in what is called a dependency property store.  Example of these data context, fonts.  These are based on looking up the tree. Have optional callbacks that can be used for validation. Can create them from snippets.

Control template tricks
Can dependency propertis which can be bound to others objestsnproperties.  Can build wrappers for objects to give various objects the same new property

Attached properties
These are type of dependency properties. AttachedPropertytBrowsableForType attribute makes attached property settable in designer. Create in code by using RegisterAttached instead of register. Your setters/Getter properties need to be shared.  When setting up set PrpertyMetaData in default types the same. (error many folks miss) Spellcheck is an attached property for textbox

Behaviors
Give Items behaviors that they normally don’t have.  Mostly useful when it is an extension on that a control, like adding masks to textbox

Pre-Session Talk with Sl Designer

I walked in on the end of David Kelley’s discussion on getting designers and developers to work together.  (LDS302).  I had a chance to talk to him about how to bridge the gap for our folks with Mario in getting better  graphics from them.  He showed how Illustrator (Adobe – Apple Product) is how we want to have Mario work in and how Expression Blend can easily import and translate the images.  Since they are both vector based graphics products.  Maybe if someone reads this by COB Friday, they could ask him if he is familiar with Illustrator.

SilverLight Develpers Guide to Entity Framework

SilverLight Develpers  Guide to Entity Framework - Ward Bell
Askward@ideablade.com

Used to Shape data to our object oriented development needs.  The “database backend” for our SilverLight business apps.  No direct road gtom EF to SL.  EDM is Entity Data Model.  Edmx isxml version of entity model.  Use T4 templates to bring data forward.  Connection string needs to be same as app.config for model (in web.config). Deals with complex types (select multiple fields from model and say generate complex type).  Cant Name type same name as field in type.  Supports Inheritance, but be wary of using it can be a performance killer,(table per type and table per content) Table per hierarchy is ok. Need to make a partial class to call inherited classes.

He was a much better speaker than his last talk I was at