ASP.NET News from Blogger: K. Scott Allen   Get the feed of: K. Scott Allen

Total News: 540

Trying Out JavaScript v.Next

ECMAScript Harmony is the future of JavaScript, and something you can experiment with using the stable builds of Chrome (my machine is currently running 18.0.1025.152 m, but that is subject to change ...

A Refactoring Experiment

Soon I'll be giving a group of developers some code and asking them to do some refactoring. The bad news is the code is hard to read. Some might say it's intentionally obfuscated, but let's not assu...

Quacks At Work

"The Lords of Finance" includes a story about famous economist John Maynard Keynes, who was diagnosed with a chronic cardiac condition and needed medical help*. In 1939, he fell into the hands ...

What's Wrong With This Code? (#29)

Here is some code similar to other code I've seen that has a severe bug. The Entity Framework model configuration is setup to allow optimistic concurrency checks via a movie's Version property. publ...

A Simpler MapReduce with MongoDB and C#

Continuing from the previous post about MapReduce with MongoDB, we can clean up the code a bit using an extension method that takes a single string parameter. var db = server.GetDatabase("mytest")...

Whiteboard Architecture

It's been my observation that the worst architectural decisions are made when technical people meet by themselves in a room with a whiteboard. I'm not saying the decisions are always bad, or wrong, bu...

Readable DOM Ready Event Handlers

One reason some people don't like JavaScript, I think, is because idiomatic JavaScript favors fewer keystrokes and CPU cycles over readability. There is a large amount of script code that is hard to r...

Yet Another Bundling Approach for MVC 4

ASP.NET MVC 4 allows you to bundle multiple JavaScript or CSS files into a single "bundled" download, and optionally minify the bundle to reduce the download size. John Peterson has a good introduct...

Avoiding NotSupportedException with IQueryable

Most remote LINQ providers can handle simple projections. For example, given a Movie class with lots of properties, and a MovieSummary class with a subset of those Movie properties, you can write a LI...

A Simple MapReduce with MongoDB and C#

If you work with relational databases and someone says "data aggregation", you immediately think of a GROUP BY clause and the standard aggregation operators, like COUNT, MIN, and MAX. MapReduce wi...

Debugging JavaScript with Chrome

The Chrome Developer Tools are a bit quirky, but for script debugging I currently like them the best. Here is a quick brain dump on some areas of interest (these are all in the stable build 17.0.963.7...

Abstractions For MongoDB

I've been working with a base class like the following to dig data out of MongoDB with the 10gen driver (install-package mongocsharpdriver). public class MongoDatastore : IDisposable { protected...

6 Ways To Avoid Mass Assignment in ASP.NET MVC

One of the scenarios that I always demonstrate during an ASP.NET MVC class is how to create a mass assignment vulnerability and then execute an over-posting attack. It is a mass assignment vulnerabili...

Working with MongoDB Conventions

I started working with Mongo again recently and needed to fiddle a bit to retrieve existing data using the official 10gen driver. Let's say you have the following persisted in a Mongo collection: {...

Structure and Organization of CSS

A few people have asked me how to keep their cascading style sheets under control. This isn't a question related to LESS and SASS, although both of them can help build maintainable styles, but more of...

Pretty Code (BYOSP Part 10)

It's always been difficult to have nicely formatted source code in a PowerPoint slide, but with HTML it's fairly easy to paste code into a pre block. <pre> <code> var start = function...

Popcorn.js

Popcorn.js is a JavaScript library for working with HTML 5 video and audio in a web page. It's part of Mozilla's Popcorn project, and it already has a bonanza of plugins available. Part of Popcorn's...

Deferred and Promises (BYOSP Part 8)

When I started thinking about adding animations to the slide presenter I pictured a few different types of animations simple animations to make items appear one by one, but also animations to pan, zo...

Primitive JavaScript (BYOSP Part 7)

When starting into the animations I decided it was time to refactor. One problem was the little "updateState" calls floating around inside conditional logic always a bad sign. A second problem was ...

Plain Old JavaScript

Once upon a time there was a pure JavaScript model. The model sang songs about simplicity in a land full of complexity and confusion. The model's clear and beautiful voice comforted many hearts in the...

What Web Developers Should Know About HTTP

I tried to think of everything a web developer should know about HTTP, then recorded those things into a Pluralsight course: HTTP Fundamentals. In the course you'll look at HTTP messages, message hea...

History and Hash Changes (BYOSP Part 6)

It's happened to everyone. You thought you typed "Use Ruby To Capture Screen Shot" into a slide, but somehow you hit the i key instead of the o key and didn't notice. Now the slide is presenting its...

Media Queries (BYOSP Part 5)

Occasionally it's useful to print a slide deck onto paper, or export a slide deck to PDF using a print driver. Unfortunately, printing the slide show in it's current form will only display the single,...

Modernization (BYOSP Part 4)

What happens if someone using an old web browser wants to view our slides? We can add the following div outside of the section elements containing the slide content. <div id="warning"> Y...

A Tale Of Two Offshorings

Company A I've worked with company A on a number of interesting commercial products over the years. After months of trying to find more good engineers in the local area, they recently decided to star...

Build Your Own Slide Presenter: Part 3

The current presenter will show one slide at a time, but the slides keep moving down the page since all the <section> elements are in the normal flow of the browser. The slides also appear and d...

Build Your Own Slide Presenter: Part 2

The slide show project currently only shows one slide. I know a number of people who can talk for 75 minutes using one slide, but fortunately they've all retired from university life and taken their o...

Build Your Own Slide Presenter : Part 1

In this series of posts we'll iterate on an HTML slide show. When I say "HTML", I mean we'll use all the buzzwords technologies that I kept out of the title of this post to avoid attracting attentio...

Programming Windows 8: The Sublime To The Strange

Microsoft unveiled Windows 8 at the //build/ conference in September. Since then I've spent time seeing how to put together Windows 8 metro applications with HTML and JavaScript. The Sublime The fo...

Getting Intrinsic HTML5 Video Dimensions

The HTML 5 DOM interface for a video element allows you to get the underlying video's width and height in pixels, but, be careful not to ask for the dimensions too early. If you ask as soon as the DOM...

Composing Entity Framework Fluent Configurations

The canonical example for fluent configuration with the Entity Framework is to take a few simple entity definitions: public class Product { public int Id { get; set; } public string Name { ge...

Modernizr.js: Polyfills

In the last post we looked at feature detection with Modernizr. Before moving forward, let me answer a few questions that came up. First, you can build a custom Modernizr download containing only th...

Architectural Tragedy of the Commons

From Wikipedia: The tragedy of the commons is a dilemma arising from the situation in which multiple individuals, acting independently and rationally consulting their own self-interest, will ...

Modernizr.js : Feature Detection

As we saw in a previous post, Modernizr allows you to work with the new HTML 5 elements, like nav, and still support browsers that don't know anything about a nav, or HTML 5. However, HTML 5 is more...

Modernizr.js

Modernizr.js is a little library that will help "modernize" old browsers. As an example, let's say you create a new ASP.NET MVC 3 application with the "Use HTML 5 semantic markup" checkbox selec...

Rise and Fall of Classic OOP

When I was making the switch from C and assembly to C++ I did quite a bit of reading on object oriented programming. It's hard to find material on OOP that doesn't praise the classical pillars of enca...

Execute<T> With IronRuby

Imagine (or dream) that you have some IronRuby code to execute. require 'net/telnet' host = Net::Telnet.new(:Host => 'localhost') #... #... #... return data One way to execute the code and c...

C# Fundamentals Part II & 10 Rules for Better C# Code

The second part of my C# fundamentals course is available for subscribers on Pluralsight.com. Part 2 introduces you to the variety of programming styles supported by the C# language. At its core,...

CSS Tricks and the Alternate Universe of Graphics Primitives

Someone asked about the circular div I used for magnification in an earlier post. There are no primitives in CSS for building arbitrary shapes, but like most things on the web, that doesn't stop anyon...

A Magnifying Lens using Script and CSS

Magno is a something I put together because well, just because. The idea is to provide a magnifying lens effect using a background image and background position animation. The lens tracks the positio...

A Simple 2-Column Layout in Razor

2 column layouts are rather popular on the web, and there are 1,001 ways to make them work. The approach you choose really depends on the type of content you have, and how you want images and backgrou...

A Tale of Backgrounds, Absolutes, mouseleave, and mouseenter

mouseleave is simple to understand: Bind an event handler to be fired when the mouse leaves an element, or trigger that handler on an element. How hard could it be? http://jsfiddle.net/JP6aV/ $...

Underscore.js

Liam told me about Underscore.js some time ago. From the home page: Underscore is a utility-belt library for JavaScript that provides a lot of the functional programming support that you would exp...

Clojure and the CLR

From the Clojure home page: Clojure is a dialect of Lisp, and shares with Lisp the code-as-data philosophy and a powerful macro system. Clojure is predominantly a functional programming language, ...

What's Wrong With This Code? (#28)

Victor Brumble is writing code again, and this time he's writing a jQuery plugin. His plugin makes alert boxes easy, because Victor loves pointless, model dialogs. (function ($) { var settings ...

Disabling jQuery UI Widgets

It's easy to make a DOM element draggable and droppable with jQuery, but it's not as obvious how to make it stop. It turns out every widget includes a set of standard methods, and one of the standard ...

Use a ReSharper Template for Script Files

Using Alt+Ins in the Solution Explorer window is one of those ReSharper shortcuts that probably saves me hours over the course of a year (Alt+Ins is the "Create File From Template" command). There i...

Manual Validation with Data Annotations

Several people have asked me about using data annotations for validation outside of a UI framework, like ASP.NET MVC or Silverlight. The System.ComponentModel.DataAnnotations assembly contains everyth...

A Better Razor IsNullOrEmpty Statement

This post is a play on Phil's "A Better Razor Foreach Loop". If you aren't familiar with templated delegates in Razor, you can follow the links in Phil's post. Something I don't like to see in a v...

The Developer's Workplace

workplace [n] - a place where work is done Over the years I've worked with developers in cubicle farms and private offices, in open spaces and cloistered bureaus. And once there was a basement room a...

View Other bloggers