Showing posts with label .net 40. Show all posts
Showing posts with label .net 40. Show all posts

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.