CODODN Notes

I spent Saturday (Dec 8) over in Columbus, OH attending the Central Ohio Day of .NET conference. As with any multi-track conference there were plenty of good sessions to choose from but of course, I could only attend five. What follows are my raw, nearly unedited notes from the sessions I selected.

Underestimated C# Language Features

John Michael Hauck (@john_hauck | http://w8isms.blogspot.com)

Delegation

  • Anonymous functions
  • Closures
  • Automatic closures compile to classes

Yay!  ANOTHER discussion about using var or type name for declaring variables

Enumeration

  • IEnumerable<T>
  • yield return
  • IEnumerable of delegates

Deep Dive into Garbage Collection

Patrick Delancy (@patrickdelancy | http://patrickdelancy.com/)

Automatic Memory Management

  • Reference counting
  • Track & mark

Allocating

  • Application virtual memory
  • Heap is automatically reserved
  • New declarations are allocated into segments in the heap
  • Ephemeral segments
  • Clean-up tries to move longer lasting objects into other dedicated ephemeral segments
  • Longer-lasting objects are collected less frequently

GC Timing

  • When an ephemeral segment is full
  • GC.Collect() method call
  • Low memory notifications from the OS (physical memory)

Only finalization is non-deterministic

GC Process

  • Marking – Identifying objects for removal
  • Relocating – Relocating surviving pointers to older segments
  • Compacting – Moving actual object memory

Dead or Alive

Starting points:

  • Static Data is rooted in garbage collector (never out of scope)
  • Stack Root (call stack) has variable references
  • GC Handles – special cases that can be created and freed

Collector walks the tree from each point

GC Handles

Struct that has a reference to a managed object and can be passed off to unmanaged/native code

Marshalling

GCHandle.Alloc() and .Free()

Handle Types:

  • Weak – tracks the object but allows collection; Zeroed when collected; Zeroed before finalizer
  • WeakTrackResurrection – Weak but is not zeroed when collected; Can resurrect in finalizer
  • Normal – Opaque address via the handle (can’t get the address); not collected by GC; Managed object w/o managed references
  • Pinned – Normal with accessible address. Not collected or moved by GC; free quickly if needed

Generations

  • Generation 0 – newly allocated objects
  • Generation 1 – objects that survived gen 0; infrequent collection
  • Generation 2 – Long-lived objects; things allocated as large objects too; infrequent collection

Anything larger than 85K in memory is considered large and automatically placed on the large object heap.

Threshold checks consider machine resources including bitness and is always in flux (except gen 0 which is based on segment size)

Configuration

Workstation & server mode:

  • Default behavior is workstation
  • Workstation
    • Single-processor machines
    • Collection happens on triggering thread
    • Normal thread priority
  • Server
    • Multi-processor
    • Separate GC per thread processor
    • Parallel on all threads
    • Collection at highest thread priority
    • Intended to maximize GC throughput and scalability

Concurrency:

  • Foreground
    • Non-concurrent
    • All other threads are suspended until collection finishes
  • Concurrent & Background
    • Collect concurrently while app is running
    • Background (v4) is the replacement for concurrent
    • Collects concurrently while the app is running
    • Only applies to Gen 2 collection
    • Prevents Gen 0 & 1 collections while running

Latency modes

Time the user knows the system is busy

Useful especially when users will notice the collection – graphics rendering

  • Batch
    • Default when concurrency is disabled
    • Most intrusive when running
  • Interactive
    • Default when concurrency is enabled
    • Less intrusive but still accommodates the GC
  • LowLatency
    • For short-term use – impedes the GC process
    • Suppresses Gen 2 collection
    • Workstation mode only
    • Still collects under low host memory
    • Allows manual collection
  • SustainedLowLatency
    • Added in 4.5
    • Contained but longer
    • Suppresses foreground gen 2 collection
    • Only available with concurrency
    • Does not compact managed heap

Finalization

Non-deterministic

Only used with native resources (IntPtr handles)

  • To release unmanaged resources ONLY
  • Objects with a finalizer get promoted to the next generation and the next time the collector hits that generation it calls the finalizer; added to finalizaton queue
  • Finalizer runs on another thread after collection has finished and runs at the highest thread priority
  • Managed objects may already be freed
  • Flagged for finalization upon allocation
  • When troubleshooting performance check the size of the finalizer queue and look for hung finalizer threads

Disposable

Objects using managed resources that need to be released

Debug Build

  • Does some artificial rooting due to CLR optimizations

Unleashing the Power: A Lap around PowerShell

Sarah Dutkiewicz (@sadukie | http://codinggeekette.com/)

Covering PowerShell 3.0

Some Cmdlets:

  • Clear – clears the screen
  • Get-verb
  • Get-unique

Console

  • Part of Windows Management Framework 3.0 suite
    • 32/64 bit available
    • Windows 8 & Server 2012 have it installed
  • Built on CLR 4
  • Adds support for
    • Networking
    • Parallelism
    • MEF
    • Compatibility/Deployment
    • WWF
    • WCF
  • show-command cmdlet
    • allows searching for commands and executing in the console
    • often easier than get-command | more
  • Updatable help
    • Not installed by default on Win8/Server 2012
    • Update-Help cmdlet
    • Must run as administrator
    • No restart required
    • Can store to a network share
  • Language improvements
    • Simplified foreach (automatic/implicit)
      • PS C:\windows\system32> $verbs = get-verb
      • PS C:\windows\system32> $verbs.Group | Get-Unique
    • Simplified where
      • PS C:\windows\system32> $verbs | where group -eq “Data”
    • Enhanced tab completion
  • Unblock files with Unblock-File cmdlet
  • JSON, REST, & HTML Parsing support
  • Session improvements
    • Disconnected sessions on remote computers can be reconnected later w/o losing state
    • Both ends need 3.0

Integrated Scripting Environment

  • IntelliSense
  • Show-Command window
  • Unified console pane
  • Rich copy
  • Block copy
  • Snippets
  • Brace Matching

Scheduled Jobs

  • PowerShell jobs can now be integrated with task scheduler
    • Register-ScheduledJob
    • Found under Microsoft / Windows / PowerShell / ScheduledJobs

Autoloading Modules

  • PowerShell 3 automatically loads a module when one of its cmdlet is invoked

PowerShell Web Access

  • PowerShell in a browser
  • Mostly 3.0 w/ some limitations due to remotin
  • Prereqs:
    • Server 2012
  • Setup is difficult
    • Install web access
    • Authorization configuration
    • PowerShell remoting must be enabled to connect
  • Limitations:
    • Some function keys aren’t supportd
    • Only top-level progress is shown
    • Input color cannot be changed
    • Writing to console doesn’t work

Management OData IIS Extension

  • Allows RESTful OData access
  • Requires Server 2012, not Server Core

MS Script Explorer for Windows PowerShell

  • 32/64-bit platforms
  • PowerShell ISE is required
  • Downloadable (Non-standard)

Building Large Maintainable JavaScript Applications w/o a Framework

Steve Horn (@stevehorn | http://blog.stevehorn.cc/blog)

Quote from Kahn about complaining about status quo and theorizing about how things should be

(I tried to find the actual quote but couldn’t – if anyone knows where I can find it I’ll be happy to update these notes)

Assumptions for JavaScript Applications

  • Not progressive enhancement
  • JavaScript is enabled
  • Rendering of HTML templates is done on the client
  • Server side is for querying or performing work
  • The UI is the most important part of the app

Each framework is giving its own world view of how you should build an app

Code Organization

Book: JavaScript Patterns (Stoyan Stefanov)

  • How can I create modules and namespaces?

window.nmap = window.nmap || {};

Let JavaScript be JavaScript; don’t worry about public/private/etc…    

Constructor members are recreated every time the constructor is invoked

jQuery Tiny Pub/Sub http://benalman.com

Designing for Windows 8 Apps

Dan Shultz (@dshultz)

Metro/Windows 8 Style Design

  • Modern Design – Bauhaus
  • International Typographic Style – Swiss design
  • Motion Design – Cinematography

Windows 8 grid

  • Grid units
  • 20×20 pixel grids
  • Title size: 42pt
  • Title line height: 48pt
  • Page header is 5 units from the top

Responsive Design

…is the approach that suggests that design and development should respond to the user’s behavior and environment based on screen size, platform, and orientation

Techniques

  • A flexible grid
  • Media queries

Media Query Ranges

  • Mobile portrait < 479 px wide
  • Mobile landscape 480 – 767 px
  • Tablet portrait 768 – 1023 px
  • Tablet Landscape >= 1024 px

Certification Tips

  • Apps need to work in snap view to pass certification
  • Keep functionality off of the margins to prevent interference with charms and app switching
  • Use charms contracts where applicable
    • Share
    • Search
    • Picker
  • Need to include a privacy statement within settings
  • Weight functionality toward edges for higher usability
    • Center screen requires a posture change
  • Sharing & Ages
    • Limit < age 12
  • Reserved Space
  • Asset sizes
    • 100%
    • 140%
    • 180%
  • Invest in a great live tile
    • Consider different sizes
About these ads

About Dave Fancher

Dave Fancher is a Software Engineer at Performance Assessment Network in Carmel, Indiana, a Microsoft MVP for Visual F#, and author of The Book of F# from No Starch Press. He has been building software with the .NET Framework since version 1.1. Dave is active within the Indiana software development community as a member of IndySA, a speaker at user groups throughout the state, and a two-time contributor to Indy GiveCamp. When not writing code he enjoys spending time with his family, watching movies, photography, and gaming on on his Xbox One.

Posted on December 9, 2012, in .NET, CODODN, Community, Conferences, Software Development and tagged , , . Bookmark the permalink. Comments Off.

Comments are closed.

Follow

Get every new post delivered to your Inbox.

Join 685 other followers

%d bloggers like this: