All posts by Will

About Will

CGFWB. Director of Software Development & Delivery at HealthEquity. My opinions are my own.

C# Little Wonders: An Introduction

csharplogoI’ve mentioned C# Little Wonders to engineers on various teams in recent years and several had expressed interest in the URL (when I successfully remembered/found it). I thought I would share it here and save some time.

James Micheal Hare (the series author) has added multiple posts to his blog over the past 3-4 years after switching from being a C++ engineer to C#. Given his background, Mr. Hare is very focused on efficiency. His concise approach and thoughts on why to use certain language features (or not) are very valuable.

If you are new to writing C# or have been doing so for many years, you’ll agree that it is a complex language. I have found and continue to find in C# Little Wonders much that I either didn’t know, had forgotten, or didn’t realize the value of.

C# Little Wonders
http://blackrabbitcoder.net/archive/2011/09/26/c.net-little-wonders-the-complete-collection.aspx

I hope you enjoy it as I do!

Movies: Physical Or Digital Media (Legally?)

The Problem: Physical Versus Digital Media

Let me begin by saying I’m a programmer and we are, by definition, lazy. I despise physical media for its inefficiency and general in-the-way-ness. DVDs, CDs, cassette tapes, VHS, etc. The only real exception here is books. Something about holding a dead tree… but I digress.

digital media

I’ve gone out of my way to digitize everything possible for many, many years and it hasn’t always been easy. Recently, laws have been passed that say you can’t even make a copy of your own physical media for backup or viewing on your computer or media device. I’m certainly as willing to pay for digital content as the next guy. You just have to make the value proposition worthwhile. That’s all I ask.

Why Is Getting A Copy Of Digital Media So Hard?

The first time I tried to redeem a copy of a Blu-ray in digital media format via UltraViolet (http://www.uvvu.com/) was a couple years ago. It was some movie we had bought and I’m not sure I even remember why… probably just because we wanted so badly to support the people who made it. I get that way sometimes. Great work should be encouraged with cold hard cash.

Frankly, the UltraViolet process was TERRIBAD. Account creation was a joke and once I finally made it through that travesty, I couldn’t get the movie to register in the system. I tried again at some point not too far in the future (due to an unrealistic sense of optimism) and was again devastated by the total lack of anything resembling working software from UV. I downloaded a copy of the movie through alternative means at this point and forgot about the whole thing.

A New Experiment

Fast forward to last week… I am in the unique position of having my electronics infrastructure spread around the United States and I find myself buying DVDs/Blu-Rays more frequently than I normally would given the lack of available alternatives. Couple that with the fact that the missus had a flight to California scheduled and wanted to watch the copy of The Hobbit we just purchased on her Kindle Fire. Staring down the possibility of shelling out cash for a digital copy direct from Amazon, and paying AGAIN, I found myself gazing upon the UltraViolet sticker on the dragon-hoard pilferer’s Blu-ray and thinking to myself:

There is no possible way this will work, but I have to try.

The digital rights for the movies are kept by UltraViolet but it turns out that I can actually redeem them through Vudu (http://www.vudu.com). Vudu also works on iOS, Android, PC, and a ton of other devices as well. I’m vaguely familiar with Vudu because there is an app for it on my PS3 so I figure, “cool, I’ll be able to watch it there as well if by some freak chance it actually happens to work”.

I begin the registration process on Vudu and… it. is. surprisingly. simple. It asks me to link my UltraViolet account OR it will go ahead and create one for me if I don’t have one. I choose life:

It lets Vudu do the work so it doesn’t get the hose again.

This seems to be going okay but I’ve yet to enter the code for the movie. I search for the movie regarding the adventures of the esteemed Mr. Bilbo Baggins, click the button to redeem my UV copy, and presto-chango! I now have a digital copy of the movie that I can either download or stream through Vudu… apparently at will! I click play and the movie queues up as fast as anything on Netflix. No complaints there.

Next I navigate to “My Collection” on Vudu and find that they have gifted me with 10 other random movies that are now synced to my  UltraViolet account as well. Some of them are even good!

Now, some of you may see the problem that I ran into next… there doesn’t appear to be a Vudu app on the Kindle Fire.

Facepalm.

Some quick Googling reveals that I could sideload the Vudu app from Google Play but that doesn’t seem to be confirmation that this will actually work. The alternative is to create a Flixster (http://www.flixster.com/) account, attach the UltraViolet account to it, and watch the movie through that app which IS available on the Kindle. My sense of foreboding returns as I can only imagine that using the UV account with more than one movie vendor is going to cause a giant charlie foxtrot… if you take my meaning.

Strangely the process is pretty smooth. To my delight, the Flixster account now has access to not only the short, round, furry-footed fellow from The Shire, but also all of the free movies I received from the Vudu signup process. IT’S LIKE MAGIC THAT ACTUALLY WORKS WHERE IS THAT WIZARD HIDING AND WHAT IS HE UP TO?!

digital media

Now my wife has plenty of entertainment for her trip and I’m kinda stoked about this whole thing. I grab the few other movies I have laying around my temporary residence and find that they are added to both Vudu and Flixster with ease as well.

This is giving me warm feelings because I’m generally happy to pay for media that I love as long as it isn’t more trouble than the alternative. I’ve long since traded in my mp3 collection for a Spotify Premium membership and generally watch anything and everything available on Netflix before looking for another source. It seems I may actually have a viable way to own the movies I really enjoy without the hassle of living on the edge of the law. If only the Television industry would make shows instantly available and do something about the prices of their series I could get behind that as well.

One final thing: Vudu and Flixster are both offering another tempting option. You can purchase digital media copies of every physical movie you own for 2-5 dollars each. This is making me pretty glad I still have that considerable DVD collection!

Guide To Developer Training For Managers

Developer training often neither begins or ends in the classroom.
Developer training often neither begins or ends in the classroom.

First things first, why on earth would you want to train developers? Isn’t that just an added expense? This is a fallacy for a several reasons including the fact that:

DEVELOPER TRAINING DOESN’T HAVE TO COST ANYTHING

More on that part later!

Development training and continuing education is vital to companies that want to maintain a healthy and satisfied development group. When we opt to invest in training, we are choosing to ­­retain valuable specialist employees and to teach them to be more effective at what they do. This has multiple benefits for the company and the employee:

Efficiency/Simplicity – Employees become faster, more efficient, and make fewer mistakes when they have hands-on training in best practices. This also results in a simpler and more easily maintained code-base.

Hiring – A great training program for development is an excellent selling point when looking to attract new development talent. Top tier developers want to surround themselves with others who are as good or better than themselves. A great training program is a good way to develop that talent and is something top talent looks for.

Preparation – Developers with training in upcoming technologies are quicker to see how they can implement them in their organization to the good of the company. These developers are better able to see industry and social trends which can give your company an ongoing competitive advantage. Also, they will be able to point to reasons why a new technology choice may not be right for the company. When the company’s bottom line is healthier, everyone wins.

Teamwork – Developers who train together work well together. They tend to develop camaraderie and work more effectively at solving problems as a team. Training together also helps expose developers to each other’s strengths.

Job Satisfaction – Well trained developers are are learning developers and let’s face it… if we didn’t like learning we wouldn’t be in this profession. When developers begin to feel stagnant they may start looking for work where they can grow or they may also become careless and write poorly thought-out code.   A good training program will help to keep developers satisfied and satisfied developers don’t go out of their way to look for other employment. This allows the company to retain their existing workforce longer and save the money and overhead involved in hiring (training, recruiting fees, bonuses).

——-

Potential Technology Training Topics

Topics should be chosen based on their applicability to the needs of the business. No responsible developer would expect otherwise. Also, real business problems should be given to help teach theoretical concepts through workshops (more on this below).

Methods of Training

Technology training can be very expensive if allowed to be. Hiring outside training companies, attending seminars, and certifications should be supplemented with sessions presented by internal experts, videos freely available online, and book discussions.

Valuable employees should be encouraged to train on their own time in addition to being given training on company time. This give and take approach will help your company realize the best gains by encouraging a knowledgeable and proactive culture among developers.

Online Videos
1-2 Hours – Daily/Weekly/Monthly
Free
These can be held during lunch or outside normal work hours. If a developer misses the presentation they can catch up on their own. A great resource for Microsoft related videos is http://channel9.msdn.com/

Developer Presentations
1-2 Hours – Weekly/Monthly
Free
Could be held any time. Presenters should be by volunteer only. Topics should be in line with the current curriculum.

Workshops
2-4 Hours – Monthly
Free
A workshop should follow a series of videos and/or developer presentations that cover the same or similar topics. No specific homework but the implementation should be something of value to the company at least as a prototype. Sessions held during business.

Workshop Follow-up
30 Minutes – Monthly
Free
Developers present their solutions to the workshop problems. Should take place a few days after the initial workshop.

Book Discussions/Club
1 Hour – Weekly
Cost of Books (Free-$80 per participant)
Developers vote on and read a technical book each month and discuss it for an hour during lunch or work hours. Books could be purchased by the company or by the developers. There is a lot of great free material for discussions available online as well.

Onsite Training Seminars
1-N Days – As Needed
Varies: $1000-5000 for up to 25 attendees
An inexpensive, onsite training. The internet is your friend… do a little research and you can find many companies offering this type of service.

On-Demand Video Training
1 Year – Annually
$100-500 per user
This type of training can be handy because is is available at any time and the people who produce/present are professionals who are not only experts in the field but can also give great presentations. There are several providers of this kind of content including Tekpub, PluralSight, and Peepcode. **
http://pluralsite.com/
http://tekpub.com/
https://peepcode.com/ 

**Tekpub and Peepcode have been purchased by Pluralsight since this was written. Looks like we’re going with Pluralsight!

Safari Books Online
1 Year – Annually
$199 or $460 per user
Safari Books offers hundreds of titles on technical subjects related to the development profession and Microsoft specific technologies.
http://www.safaribooksonline.com

Offsite Development Conferences
2-5 Days – Annually
$500-5000 per attendee
These are the conferences that really get the creative juices flowing in developers. Most major tech companies have at least one developer conference per year (Google, Apple, Facebook, Microsoft). Most companies with a decent training budget send their developers to one per year (almost never 2+). Estimated cost includes hotel and transportation.

developer training
Offsite Developer Training

Certifications
Varies – Varies
Varies
Some companies pay for developers to train for and take development certification tests.

Graduate Degrees/Tuition Reimbursement
Varies – Varies
Varies
Many companies offer to reimburse employees engaged in higher learning. This is another great opportunity. Encourage your employees/coworkers to take advantage of this benefit if it already exists!

——-

As you can see, the options for training developers run the full gamut of price, time, and commitment. The great news is, even if your company has little or no budget for training, all you need is a couple committed developers to get started with the less expensive (free) types of training. Now is the time to start training so that your company will attract, retain, and benefit from more highly trained and competent developers!

SassAndCoffee Is Not A Smutty Romance Novel

SassAndCoffee !=

 Not SassAndCoffee

So what IS SassAndCoffee? From the author’s (Paul Betts) blog post:

SassAndCoffee is a library for ASP.NET (both MVC and old-school WebForms) that adds drop-in support for two new languages: Sass and SCSS, a language that allows you to write reusable, more structured CSS, as well as CoffeeScript, which is a JavaScript dialect that is much more syntactically elegant, but still preserving 100% compatibility with regular JavaScript.

I’ll go into more detail about the features of SassAndCoffee momentarily, but lets start with getting it into your project in Visual Studio.

You could grab the project form GitHub and compile it yourself but the simplest way to include the assemblies needed is through NuGet

SassAndCoffee’s NuGet project also adds some entries in your web.config:

 <system.web>  
     <httpModules>
       <add name="CompilableFileModule" type="SassAndCoffee.AspNet.CompilableFileModule" />
     </httpModules>
 </system.web>

 

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <remove name="CompilableFileModule" />
      <add name="CompilableFileModule" type="SassAndCoffee.AspNet.CompilableFileModule" />
    </modules>
</system.webServer>

 

Once this is complete, just create a .scss or .coffee extension file in your project and reference it from your HTML as if it were already interpreted as .css or .js respectively. We’ll go into more detail on this.

The main features you get from SassAndCoffee are as follows:

  • Easy setup: No need to install Ruby or node.js or anything else. Everything that is required is included in the NuGet project.
  • Automated compilation: simply add .scss or .coffee files to your project and reference them in HTML as you normally would (as .css or .js files) and SassAndCoffee handles the compilation and output linking at runtime.
  • Automated minification: minify your output files as well as other .js and .css files in your application with a simple naming convention.

Now let’s check out an example with Sass using the file SassAndCoffeeDemo.scss:

@mixin customDivText($size){
    font: {
        weight: bold;
        size: $size;
    }
    text-align: right;
}
 
div.big{
    @include customDivText(70px);
}

div.bigger{
    @include customDivText(150px);
}

Index.cshtml:

<div class="big">Big</div>
<div class="bigger">BIGGER</div>

_Layout.cshtml:

<link href="@Url.Content("~/Content/Site.css")" rel="stylesheet" 
type="text/css" />

Now our output looks this in the browser:

And SassAndCoffeeDemo.css contains:

 

div.big {
  font-weight: bold;
  font-size: 70px;
  text-align: right; }

div.bigger {
  font-weight: bold;
  font-size: 150px;
  text-align: right; }

Let’s try a “Hello World” in Coffeescipt. I’ll add the following code to a file named SassAndCoffeeDemo.coffee.

helloCoffeeScripters = (name) -> 
alert("Welcome to Coffeescript, "+ name)
 
$ ->
	helloCoffeeScripters ("World")

And refrence it in my _Layout.cshtml master page:

<script src="@Url.Content("~/Scripts/SassAndCoffeeDemo.js")" 
                        type="text/javascript"></script>

When we run our app we should see the following:

When we view the source of our .js file we see that the Coffeescript compiler has emitter the following javascript:

var helloCoffeeScripters;
helloCoffeeScripters = function(name) {
  return alert("Welcome to Coffeescript, " + name);
};
$(function() {
  return helloCoffeeScripters("World");
});

Now lets consider the other SassAndCoffee feature that tends to get overlooked, Minification. If we change the Coffeescript file name in our _Layout.cshtml file to include “.min” like so:

<script src="@Url.Content("~/Scripts/SassAndCoffeeDemo.min.js")" 
type="text/javascript"></script>

Then when we compile and view the source of our file we will see:

var helloCoffeeScripters;helloCoffeeScripters=function(a){return alert("Welcome to Coffeescript, "+a)},$(function(){return helloCoffeeScripters("World")})

The beauty of SassAndCoffee is in the amount of attention that you DON’T have to pay to it. It just works! Import the NuGet project and you can get to the business of learning how to use Sass and Coffeescript right away.

Refrences:
https://github.com/xpaulbettsx/SassAndCoffee
http://nuget.org/List/Packages/SassAndCoffee
http://sass-lang.com/
http://jashkenas.github.com/coffee-script/

Thanks to @alamocoders for letting me present this topic at their last .NET meeting. I had a blast. Here are the materials from the presentation if anyone is interested. It includes the source code and my slide deck.
http://dubmun.com/projects/SassAndCoffeeDemo.zip