Wednesday, October 7, 2009

Afternoon Session 1: Caching in ASP.NET with Memcached

My last session of the conference. From some talks with Ted during the alliance project, Memcached may be a better solution for session synchronization between PHP and .NET. I'll only get to attend about 45 minutes (out of 75) for this talk because the airport shuttle is picking me up.

Afternoon Session 1: Caching in ASP.NET with Memcached
Jeffery McManus
Platform Associates

Used by Facebook, Yahoo, Flickr (so well-tested in terms of scalability)
Presenter sees himself as "The Johnny Appleseed of Open Source" at VSLive.
Decouples caching from platform/dev environment (key of course to using across PHP/.NET
Distributed cache = better scalability
Preallocates memory - nonfragmented, does not need to allocate/deallocate small bits in real time like .NET would
Everything stored in key value pairs (can get around by applying an MD5 hash to a key)
Can store an object -- just gets serialized
Lots of .NET libs...he recommends BEit.Memcached (on Google code)

Have to run, but some really good stuff we should be using for shared cache.

Morning Session 2: Odd Bedfellows - Making Sense of PHP on Windows with MySQL and SQL Server

Rarely is it quite so apropos to use the word "apropos" to describe something, but this session definitely fits our situation.

Morning Session 2: Odd Bedfellows - Making Sense of PHP on Windows with MySQL and SQL Server
Andrew Brust

PHP is popular, cheaper, easier than .NET. Runs on anything.
Argues that platforms like Drupal and Joomla are actually the biggest drivers.
Can coexist, though...works on IIS (esp IIS7 and PHP 5.3) and can work well w/ SQL Server. PHP 5.3 first version that is highly optimized for Windows, but not yet ready for SQL Server.
Want to have FastCGI on server (built in on IIS7, extension on 5 and 6).

Extensions are easy to add and use, although it's sorta that debate over whether or not the fact that you CAN get an extension makes up for the fact that you HAVE TO get an extension. I flip flop on this argument I know -- I love Firefox.

MySQL engines: MyISAM or InnoDB. MyISAM is faster but does not support transactions...flip flop for InnoDB
As expected, SQL drivers very similar to MySQL ones. Note that MS's MSSQL driver only works with PHP5 and on Windows.

OK, so this presentation was not really what I thought it was going to be. It was definitely more focused on showing the good parts about PHP rather than the challenges of running it alongside .NET or communication between the two. This is not a bad thing -- there's a lot good about PHP. I will say that I at least found out a little for myself -- stuff Milhko probably knew -- about the challenges and requirements for getting PHP up on Windows.

Morning Session 1: Windows Azure - A New Era of Cloud Computing

Missed some yesterday afternoon, but back with a vengeance! I don't know if Windows Azure is the way we would go, but I do want to find out a bit more about cloud computing in general. A lot of this is stuff I think many already know very well and I just want to keep up.

Morning Session 1: Windows Azure - A New Era of Cloud Computing
Aaron Skonnard
Pluralsight

Plans to focus on the business and financial benefits. Says developers won't like it.
Amazon (S3) still the leaders, MS catching up quickly.
Low total cost, "provision" servers quickly (in minutes!)
No necessity to over-provision to handle spikes
At Google, 1 admin may manage >1000 servers.
Azure is generally have to develop differently since platform is abstracted from the infrastructure (so can't do things like access file system in the same way) [Note: Really curious about the impacts here for us...]

Economies of Scale:
Medium data center: $95/Mbps/month, Storage $2.20/GB/month
Large data center: $13/Mbps/month, Storage $0.40/GB/month

Choosing Amazon, Google, MS....argues MS is well positioned since they are in the business of selling OS while Google sells ads and Amazon sells books [Note: not a fair comment at all...]
Amazon/Google - how do you connect back to your internal servers? According to him, Azure is the only one that provides a solid solution for this.
Amazon provides a solution for transferring enormous amounts of data - ship it to em on a USB stick. Cheaper and potentially faster.

Azure today supports web role (web sites), worker role (windows service) and communicate between the two using Azure Storage (tables, blobs, queues)

Cloud computing in general -- definitely interesting and useful in our environment. Azure -- not so sure. It seems like there are a lot of new things we would have to do to switch our applications to Azure apps (using their API for accessing config or something), whereas certainly for Amazon, we can get going much sooner.

Tuesday, October 6, 2009

Afternoon Session 1: Maintaining State in ASP.NET Applications

A replacement speaker on this one. The original guy had a fall on his yacht. Now given by Miguel Castro, the same guy who gave the presentations I went to yesterday morning, which were both very good.

Afternoon Session 1: Maintaining State in ASP.NET Applications
Miguel Castro

"Everything in the web is a giant hack." The perception of "state" on a web page is just an illusion!

Cache less dependable than application, but scalable. Things will drop out of cache if it gets to large.
GridView is responsible for growing ViewState in a big way! Performance!
What to do?
1. Don't enable in-line editing. It's confusing and grows ViewState.
2. Disable ViewState.
3. Make the db call again. It's faster than you think.
Sliding cache lets things auto renew in cache.
Potential to make a user specific cache by appending a uniquifying key (like session id) to the key name of the cache.
By default, session id is sent in memory cookie to user browser.
Max timeout for session is 24 hours!
Anything in session has to be serializable.
To clear var from session, use Session.Remove(), not setting to blank.
To avoid sticky sessions, can have .NET use a single server for ALL session storage

Can create a class to wrap session vars - which solves some of the problem of loosely typed values and need for mistyping session name - the session var pull is in the getter/setter for the class instead, and the getter/setter can do the casting.
So something like:
AppSession.CurrentEmployeeId = 10;
Getter/Setter for static CurrentEmployeesId prop actually does the push to\pull from session.
^^ This is good stuff. Yet another thing to do...

Can do cookieless sessions in web.config - set cookieless="true" in sessionState section. Note that data goes in the url...which is ugly.
WebFarm session storage - use mode="StateService" and turn on ASP.NET State Service in Services (off by def).

Pretty simple stuff in this session, but a couple nice tips and tricks here and there.

Morning Session 2: Getting Started with .NET 4.0 and C# 4.0

Going to sit and learn a bit about what's happening in 4.0. This is supposed to be targeted at mid- to high- level .NET developers and focuses a lot more on the framework, not the IDE. I'll try to keep up.

Get his slides (later) from RichardHaleShawGroup.com/downloads.aspx, access code VSLiveOrlando2009

Morning Session 2: Getting Started with .NET 4.0 and C# 4.0
Richard Hale Shaw
Code with Confidence

Wow, this guy HATES Vista. Finally got done with a long rant about it. [My Note: He wasn't done.]
Not talking about F#, and I probably won't go to that session later.
Advances always around producing problem solving code with fewer lines. [My Note: sometimes at the expense of readabilty. Looking at you, lambda functions]
First change to CLR since 2.5

Can now cast generics better...so List of strings can be cast to List of objects just like string can be cast to object - he describes this as a bug fix. Has not come up for me yet, but can see where it would be useful.
Have not worked with LINQ, but some new capabilities to pull data using parallel processes using a simple AsParallel() method. Added stuff to System.Threading.

Dynamic language programming bundled in. C# not dynamic, but can USE objects built by dynamic languages. Basically, any object declared using dynamic (which is...weirdly...a static type) will not throw any compiler errors no matter what methods you call. They turn into runtime errors). I'm very wary about dynamic languages from a code maintainability standpoint, and I hate turning compile errors into runtime ones. But I think the idea of being able to leverage Ruby and Python libraries that build dynamic objects is a good one. I can just see this being abused to write screwy, unreadable, hard-to-maintain code. End rant.

Optional parameters with default values. Woo hoo!
Named parameters so user can pass parameters in any point...and increase readability.
CalculateBMI(weight:123, height:64);

New Tuple object that lets you put any number of objects together on the fly without building a class.
New thread-safe collection class.
Code Access Security is now obsolete. Recommends now OS-level solutions like Windows Software Restriction Policies. Can/should use Transparency Model from Silverlight.

"The biggest mistake we make is assuming that it's more expensive to take the time to do the rewrite than to live with our old junky code."

Presentation was fine, but VERY rushed. Spun through tons of slides really fast, skipping tons of them. Focused on some interesting stuff, but there was just more data than the time slot allowed.

Morning Session 1 - Intro to Silverlight

My indulgent session. I don't know that the lack of adoption will allow us to use Silverlight on the website, but I hear so many good things about it.

Morning Session 1 - Intro to Silverlight
Brian Peek

Dev and deployment easier than .NET
Problems with Silverlight:
1. No native printing support
2. No webcam/mic support
3. Popping outside of the sandbox is still limited
4. Linux support is very weak
5. Adoption is low (by FAR the biggest problem in our environment)

Couple optional tools: Expression Blend (for design) and XAMLPad (quick prototyping)

Very Flex-feeling at first glance. Compiles to xap instead of swf. Uses c# instead of ActionScript. Only thing is that I like that is different is the organization of the codebehind - Flex puts scripts pretty much wherever you want.
Silverlight 3 turned off the designer for performance reasons, or at least hid and disabled by default. That sucks.

Embedding media is REALLY easy. One tag, one prop. Amazing how simple that was.
Style definition billed as "like CSS", but looks really clunky in my opinion. But at least you don't have to worry about cross browser crap.

Can pull app out of browser window and even install to Start menu - Cool! Can't run disconnected like Adobe Air, but WAY easier to do. Basically just a config change to enable.

Nothing in this session that distinguishes Silverlight in any HUGE way from Flex, but carries all the same advantages of Flex for developers. Just have to watch adoption rates.

Keynote - SQL Server 2008 R2:The Data Platform for Software Plus Services

Day 2 begins...

Keynote - SQL Server 2008 R2:The Data Platform for Software Plus Services
Roger Doherty
Senior Technical Evangelist

Couple Silverlight nods given. No real mention of adoption rate...
IIS7 Smooth streaming ability - stream vid a different qualities depending on bandwidth, etc.

Ability to create .NET classes and persist in DB. Even he doesn't see it as that big.
XML as first class citizen. Nice, but did not think that was new.
HierarchyId data type - potentially cool for storing hierarchical data.
Sparse columns - up to 30K columns since columns with NULL are not allocated space. Cool! "SELECT *" only returns non-null cols. Interesting...
Datetimeoffset type supports time zone. Once in a while useful.
Can now persist blobs to NTFS. WAY better performance. Nice, but he's giving the impression that it's very raw still. To quote, "Give it a try maybe in SQL2011."

Indexing better. Filtered index to do something like not indexing null values. Awesome for sparse tables (like FacetEntityValue).
Integrated fulltext search - 2 people in the room had ever used it. He seems disappointed.

Talked specifically about improving/developing JDBC and PHP access APIs.
Fancy talk to say they are working on integrating .NET ORM type capabilities.
Microsoft Synchronization Framework as alternative to replication (more fine grained control)

VS Team Database Edition
Integrated change management code, including source code integration. Nice.
Db refactoring support. Scary powerful.

Some interesting stuff in here. It seems like some of the functionality could be used in place of NHibernate. Don't know which is better. It feels to me (and I could be wrong) that the VS/SQL Server capabilities are really good for a clean model -- all of your stuff coming from SQL Server, classes that look just like your db tables. NHibernate has stuff we use extensively for connecting to other dbs and building a clean object model from twisted data models. Feels like we blow a lot of the MS advantages out of the water when we do that.

Monday, October 5, 2009

Afternoon Session 2 - 'Real World' ASP.NET MVC in 75 Minutes!

Same guy as last time. Not the best presenter, but here we are.

Afternoon Session 2 - 'Real World' ASP.NET MVC in 75 Minutes!
Gus Emery

Custom Routing
Customization to urls
Keeps site secure (no exposure of real url)
MVC is type smart
Easily addable to global.asax. Miguel told us not to do that...
Default controller: {controller}/{action}/{index}

Never a good sign when he warns us to bear with him with all the issues he's expecting. Or it shows he's learning from last session.

Can also create partial views as ascx.

Form Validation
Use AddModelError to add an error to the model, then check ModelState.IsValid(). Note, requires a roundtrip to check, but 2.0 apparently has a better way (using jQuery I think).
Provides easy way to display errors (HtmlValidationSummary) and uses standard validators on fields.

Custom Filters
Allows custom functionality (logging, tracing)
Very flexible
Actually filtering on actions to let you log them.
Didn't really work (at all) in his demo, so not really sure....

Caching
Less DB hits
Faster
Basically tag any method with a cache. Things go faster. Can do a varyByParam to specify individual parameters that should be used to specify how to index your cache.

Afternoon Session 1: Intro to ASP.NET MVC

Alright, been way too wordy. This session I think is going to go a lot into a generic intro of ASP.NET MVC. I figured that out all by myself JUST from looking at the title. Seriously. So I'm not going to post much about the specifics here. All part of my fewer-words initiative. Go!

Afternoon Session 1: Intro to ASP.NET MVC
Gus Emery

MVC was originally called "Thing-Model-View-Editor." Awesome. That's better than the Entity table.
Claims it's not for every project, but also says he hasn't ever seen an app for which MVC is not a good fit.

2.0 Updates:
Addition of jQuery validation lib
Areas - multiple projects
Model Validation Providers
Metadata Providers
Exteded Editable flags

URL rewriting more secure since users can't see what your physical pages are.

My biggest problem -- and Al and I have talked about this -- is that it's very developer friendly, but we have the unique goal of exposing the view layer to Marketing. There's a lot of code in the View, and it's not easy (for a non-developer) to just add a view -- you have to build the corresponding controller, etc. With a standard web form, on the other hand...very possible.

Integrated security = nice. I can see using this for backend stuff for sure.
Cookie based authentication - with cookies that last a LOOOOONG time.

Not my favorite presentation of the day. This guy is going a bit fast and seems a bit disorganized (crashes on examples, things like that), which makes some of his examples a bit tough to follow. Wish it wasn't done in VB, too. Stupid no semicolons.

Morning Session 2: Advanced Web Forms Practices – Part II

OK, so this actually started a bit last session, but want to keep everything together, so here we go with Part 2! May try to make this stuff less wordy, but it's a good session.

Morning Session 2: Advanced Web Forms Practices – Part II
Miguel Castro
Solutions Architect

2. Swappable State Storage

Can store data in Session, Application, Cache, Cookies, etc. So what if you want to swap storage of a var from one to the other? Have to find all instances and change them -- a bit tedious.
ASP.NET Provider Model has a solution.
Separation of concerns! Woohoo!

Static factory class for entry point to all storage methods
Provider base class defines public interface
One provider implementation class for each type of storage
Configuration section listing available and default provider.

Side note: He was doing an example and just manually added a namespace. I Heart Resharper.

Goal is to be able to do something like this:

StateStorage.Store("MyKey", "Hello World");
-- Is it using Session? Application? Cookies? Who cares?

So define a config section that defines several state storage providers, defining a class for each one. One of the providers is flagged as the default provider. Have to write configuration classes of course very similar to the last SSL example. ASP actually provides a class (ProviderSettingsCollection) for defining a basic provider using only a provider and type.

Single static factory class (StateStorage above) will read all the config information and get all the providers and assign a default provider.

Each provider extends a single base class that provides the Store method -- storing however you want. (Note .NET provides a ProviderBase class that your base class should extend) Also has abstract methods for things like Store that you want your provider to support. Individual providers extend that base class and implement the abstract methods as needed. Note can use the providers to uniquify the keys used for storage, or even uniquify a key in the application state for a single user. Don't know why you would do the second one - storing user specific data in application instead of session. But whatever.

And can target a specific provider in code by creating a physical provider from the list of providers in the StateStorage class.

I like it, but not as much as the SSL stuff. Lot of code to solve a not-that-hard problem. More cool code than useful code, but the concept of using the ASP provider model is a good one.

3. Nav Flow

Wizard-like scenario for multiple pages.
Includes nav buttons
Prevents step-skipping
Ability to manage pages and their order
Minimal code from page
Leverages Swappable State Storage above.
Even includes a custom control for dropping nav onto any page in process.

Define a configuration section with a group of pages. He likes his config files. I'm still a little out on how much I love the idea of doing so much stuff in config files.
Allows for defining which state storage provider (from above) to use for storing things like where you are in the process (for validating and preventing skipping).

Static NavigationManager has methods for:
1. Marking current step
2. Navigating forward and backward.
3. Validate if current page is a valid place to be.

Big warning about the Back Button here. May screw around with the validation. He says in eCommerce you should just threaten to double charge people if they use the back button. Haha.

My thoughts: Nice in that it's easy to insert pages or reorder them. Not sure how often that stuff changes drastically, but still a much easier way to handle this than doing all of this info right in the page itself. Could probably also do something like create a couple alternate NavFlows to A/B test some different alternatives (i.e. does fewer steps in the checkout increase conversion?) or provide a different navigation for an express checkout.

Could definitely see using this or something like it for checkout, although I'm (like I said) still not sure if it's maybe better to put the "configuration" inside of code instead. Little more work and requires a compile, but you gain some valuable things like better debugging.

4. Mobile Page Routing

Really quick section on routing mobile users to a mobile version of the site...and potentially vice versa.
Good design allows for forcing normal version even from mobile browser (i.e. full internet on iPhone) and keeps user there via a cookie or something.

More config settings to define the default mobile page. State storage provider again to store cookie (or whatever) for forcing full version browsing.

Another HttpModule that checks if mobile browser is accessing site.
Provides a class called BrowserInfo that has IsMobile property (see cd).

This section was very rushed, but worth checking out later. This has potential to be a key initiative going forward.

Great couple of sessions. Lots of really good and really useful info.

Morning Session 1: Advanced Web Forms Practices – Part I

A bit of a long one here heavy on technical details. There's a cd we got that has solutions rolling in all of this stuff, so let me know and I can share all that when I get back.

Morning Session 1: Advanced Web Forms Practices – Part I
Miguel Castro
Solutions Architect

Excited about this one. Billed as a session for the seasoned .NET developer interested in out-of-the-box problem solving.
Interesting – he asked for MVC junkies to raise their hands. Out of about 200 people, one hand went up.

1. Handling SSL Pages
Should not be used for all pages (performance hit, etc)
Should be able to easily mark a page for SSL use – including the ability to switch them back and forth easily and even the ability potentially to do it without a recompile. I like it.

Technique 1: Class Interception

One base class for SSL pages and another for Non-SSL
Hard coded into code-behind, secure against change. Good because it’s more secure, but bad because you have to recompile.
So create two different classes that extend System.Web.Ui.Page - PageBase and SecurePageBase. (Note: We're doing something similar in FrontEnd using a class called GCCPage. Very useful for overriding anything in Page for every single page, as well as providing convenience methods across all pages. The only thing we have not done is branch into the SSL and Non-SSL versions of the page)
SecurePageBase just extends the regular page base - with the only difference being that a member variable (RequireSSL) is set to true instead of false.
From there - simple. Just provide a simple method called in On_Init to check to see if you (1) require SSL (using member var) and (2) are not already in a secure connection, and do a Response.Redirect to the SSL version if needed!

if(!RequireSSL and !IsSecure())
{
Response.Redirect(...)
}

Also a nice approach since you can add a check for localhost and NOT do SSL. Now you don't need to config a cert locally.

Technique 2: Custom Module to check config info

Put SSL pages into config file.
Good approach because no recompile is required. But the downside is that anyone with access to web.config can do a little more damage now. Security not THAT big of a deal since web.config is not publicly accessible.

So a config section called pageRouting and configuration element collection called securePages - with elements for all url's that need to be secured. Can also have attributes in config to do things like disable for local host or blanket disable ssl entirely -- all quickly and easily.

Note: I put some xml here - which blogspot does not let me display. Do a view source to see it I guess...






So have to create a few classes to define both the ConfigurationElementCollection and ConfigurationElement...and of course a class for the ConfigurationSection for "pageRouting." I'm looking at how easy it is to decorate classes and properties with Attributes using the .NET 2.0+ tags...and wondering why I don't do it more often.

Now it's easy to read the config section using the ConfigurationManager class and see what urls need to be SSL'd, redirecting if needed.

So he's getting into tapping the Http pipeline events (as opposed to page events) to do the redirects. He is talking about NOT using Global.asax (which, by the way, we do heavily) and instead using a class that implements IHttpModule. Lets you tap into the exact same events, but it's reusable! Gonna have to remember this.

Just implement a single event (Init(HttpApplication context)) and then you can wire into any event:

i.e. context.PostAcquireRequestState += context_PostAcquireRequestState;

Then register a new HttpModule using this class in web.config and your events get fired.

My thoughts - I like the approach for its flexibility, but I don't see the lack of a recompile as a massive advantage in our environment. It's good code and I like it better than the first approach. Longer to implement, but easy to do once it's set up. And the module created is completely reusable. More I think about it, more I'm convinced I'm totally stealing his code. I HAVE to remember this about moving stuff out of global.asax. Even if we don't use the rest, this at least is good stuff.

Random conference thoughts

1. The store in this place is ridiculously expensive. Dinner last night: small tuna salad wrap, bag of chips, 20 oz Coke. Cost: $15.18. And the tuna salad was terrible.

2. This is a conference for developers. Laptops everywhere. In the main hall, I have counted a total of about 10 outlets. At least I got one of em.

Keynote: Visual Studio 2010 - Get Ready for the Next Wave

So the first session of VSLive Orlando. I'm going to post some stream of consciousness sort of thoughts on each of the sessions here. Enjoy!

Keynote: Visual Studio 2010 – Get Ready for the Next Wave
Matt Carter

State of dev – failure high!
68% of proj never make it to production
VS2010 around reducing failure
“Over 50% of projects will cost almost 200% of their original budget.” – Forrester. P&C was ok!
Focus on capacity planning and PM-ish features (in Team Foundation) – Does this integrate with Project?
SketchFlow in Expression Studio 3 for prototyping. Looks like an intereting tool worth considering.
Claim: “Regression errors are a thing of the past.” Big words, Matt. Big words.
They have a new light version of TFS coming out. Not sure if it will be cheaper or what. But promising.
Showed off some of the manual testing stuff in TFS. Nothing special, but integration is nice. Really turns VS into your hub for everything.
Performance of VS2010 pretty slow – promises better by release!
And the first crash occurs 34 minutes in while connecting to TFS. Mark it!
One cool part about manual testing – it automatically captures video of the steps.
I like that the testing/bug tracking/development are all integrated.
Ah, kinda cool. Automatically creates a test for the developer after bug is generated, and will walk through and replay the EXACT steps the QA tester used to generate the bug. Less sending the bug back?
Better Visual Studio Gallery integration…never used it, but maybe I will now.
Undock individual tabs – nice.
Trying to improve start page. Looks like ability to add widgets. He’s trying to show off some sort of Twitter feedback mechanism. Not really working and I don’t understand it. I’m gonna go out on a limb and say I can safely continue to ignore this stuff.