Skip to main content


Showing posts from 2012

Learning a New Language

Today I'm going to share something about myself that most developers probably don't want to admit about themselves, but I suspect I'm not alone.  If I'm not alone, this might be able to help someone, so here it is.
I find that the hardest part of learning a new language is starting.  I find that my competence in most languages follows a curve along time that looks like this. This demonstrates that the really challenging parts of the language are early on.  When first starting out with a language, it usually takes me a crapload of time just to get to the point of a working "Hello World".  Now there are exceptions to that rule (Ruby comes to mind), but I find that this early time is important to my understanding of the language.  I am learning compiler/parser tricks and understanding little nuances like the need for semicolons, or that every method must be in a class (C# but not C++) even if namespaces aren't necessary to get the application to compile.

CTW - Black Hole Ripples

First, some background.  Wednesday is "Conspiracy Theory Wednesday" around my house.  We pick a conspiracy theory and research it.  If there's documentaries, we watch it.  If there's articles online, we dig them up.  The idea of CTW is simple.  Treat the conspiracy theory as though it were fact for one day.  Try to find every way to make it fit reality.  By doing this we can get a better understanding of the angles people will try to defend it from, and then it also makes it easier to debunk the conspiracies on any other day.
So I'm going to try to start putting up my Wednesday posts as CTW posts.  It's representative of something I do 1 day every week, that's 52 days a year.  So it's a big part of who I am.  It's not exactly programming related, but it's a little bit of fun and a decent break.
Today's conspiracy is Black Hole Ripples.
Calling it a "conspiracy" isn't exactly accurate given that the link I just posted is from …

Know What You're Working With

When teaching programming, every teacher has his or her own custom style.  The difficulty is that, when learning about programming, you need to understand the teacher's style, and that's the bit their less likely to explain, sometimes because they can't and other times just to avoid arguments about how they should change.
So I'm going to go over a stylistic trick that a lot of teachers use.  When learning to program, some teachers tend to live in the IDE.  They don't discuss the background stuff that's going on, which can leave you in the dark when you try to understand how everything attaches to the computer as it exists.  So the teacher will be discussing programs inside the IDE but may never even show you the output directory.
I'm using Visual Studio in this walkthrough, but the purpose here is to show you that you should look at the output directories of your own programs, even your toy apps.  Here's the output directory of a tiny hello world app. N…

Source Control Branching and Merging

It is something that is so common that it's unsaid most of the time, but the entire professional software world relies on Source Control.  When I was a young newbie developer, I didn't even know what Source Control was.  It's easy for us to forget those old days and look at new developers when they ask us questions and not mention anything about how they should be using some form of Source Control aka version control.

There are a lot of different version control systems out there these days.  There's even heated debates about which is best.  The point of this article is not to tout one or the other, but I will anyway.  Git is awesome, but their Visual Studio plugin sucks!  Team Foundation Server integrates perfectly with VS, but tries to do to much, having an entire Agile system built in and fails as a version control system.  Everything else is not as good at Git and also has crappy VS integration.

Seriously though, this article is about Branching and Merging.  Do you…

Document it!

Anyone who's been in software development for any amount of time will know that a common issue in any team is a lack of documentation.  If you've been in the industry for more than a year, it starts to feel like "beating a dead horse" when talking about how we need more documentation.
You can try to appeal to people's emotions expressing frustration and a need for sympathy and empathy in the process, but that's just not how Software Developers work.  If you want to appeal to people like me, you need facts, and lots of them.
That's not enough though.  If you can convince your programmers to write the documentation, then you still have to convince management that it's worth the money.  The truth is, no one is on your side here.  What's worse, the guy who's touting documentation now, probably was against it last week.  It's a really hard sell.
This is my generous gift to you.  I'm going to give you the selling points that I've used ri…

Javascript - First Class

It may or may not surprise you to know that I have a heavy Javascript background. While my first language was VB6, I don't think I've ever delved into any language quite as deeply as I have with Javascript. I used to use a gnome back-end to build very complex projects in Javascript. Therefore, you might know how cool of a concept it is to me to use Javascript as a First Class Language.

Much more exciting however, is that Microsoft is doing just that, and in Visual Studio no less!  This means that we not only get intellisense and other features.  But now we can code entire applications in Javascript as if it were .NET at its core.

It may not seem like much, but it means that you could theoretically code pure Javascript from Logger to Server to Front End and it could seriously simplify programming in the future.  This is something I'd like to see available in more languages, but if Javascript is the start, then so be it.  Hoorah for JS!

yield return in C# 4

OK, so I've been watching pluralsight videos lately and you would not believe how much they seem to love this "yield return" in C# 4.0.  Let's take a look at it in a small implementation.
using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace ConsoleApplication2 { class Program { static void Main(string[] args) { var numbers = new List<int>() { 1, 5, 10, 15, 20, 25 }; foreach (var number in GetLargeNumbers(numbers)) { Console.WriteLine(number); } Console.Read(); } static IEnumerable<int> GetLargeNumbers(IEnumerable<int> numbers) { foreach (var number in numbers) { if (number > 10) { yield …

Useful Links

As an apology for not keeping up with posting this week, I provide you with cool & useful links.

Console Emulator, good one!

Crapload of Free E-Books from Microsoft

Temporary Phone Number App

New Network Security tool I found

View the source code you're using in these obscure libraries from Microsoft et al

Tabbed Remote Desktop

Programming Jokes, in code

Node.js is cool, but stack Meteor on top and you can do other cool stuff

How I set up blogger syntax highlighting

Trello, agile/scrum…

Uploading a File in ASP.NET MVC3

I've done my research on this.  I've seen the literally hundreds of tutorials on how to upload a file in Microsoft's MVC platform.  So, let's do the bit that all of them show first.

@using (Html.BeginForm("Upload", "Home", FormMethod.Post, new { enctype = "multipart/form-data" })) {     @Html.Hidden("id", Model.Id)     <input type="file" name="file" />     <input type="submit" value="Upload" /> } 
So the first thing to note here is that this is Razor.  There isn't an HtmlHelper for a file input, so we have to add one manually.  Same for the submit button.  Then we notice that I'm using Html.BeginForm, not Ajax.BeginForm.  Everyone loves AJAX right?  Well, AJAX doesn't allow file uploads by default, so if you want to do uploads via AJAX you'll need a plugin for jquery.  I'm submitting via POST for obvious reasons, you do not want your file's byte array in y…

What Kind of Web Host Do I Need?

Let's call this the newbie guide to starting a website.  I've always hosted my own sites, so the reason I'm doing this research is because I'm considering a move to hosting off-site.  There are probably hundreds of tutorials out there, so for those of you browsing, this is purely about hosting, not about actually making a website.
This post was also inspired by a question.  First thing's first, you should decide on a hosting provider based on your needs.  So this tutorial will be broken up based on the levels of need.
Minimal Need - $5/month
So the first level of need is minimal.  This type of site is something your mom is using to present photos of her ebay sales.  It's probably something Wordpress can handle.  If you think it's going to need to handle traffic, many providers also allow for PHPBB on these.  All of this is called Content Management System, and you can use any host that will allow you to FTP and upload documents for your website for this.  Mo…

Managing Programmers

Working with other programmers is tricky.  That said, it's nothing compared to the job of managing programmers.  One of my favorite quotes about Perl is that (paraphrased) "a Perl developer is like a rockstar.  Now imaging having a bunch of rockstars in one room together and you will understand why you don't want an entire team of Perl developers."  It's not about Perl here though. What's important to understand is that any developer worth his salt is going to be like a rockstar.  And yes, there are a lot of professional developers out there who aren't worth their salt, but that's for another post another day.  Rockstar may not be the right term here, but think of it this way.  These guys are smart.  They may not be geniuses, but there's going to be things that they know that you don't and probably never will.

I've seen it more than once and it's not going to make some Product Managers happy, but I'm going to state a fact, an eleph…

More Books and Code Fun

Make a regex for this...

I started this blog as more of a generic overall view of coding, more perspective on higher level ideas rather than line by line code (though I suspect I'll post some of that too) mostly because of how much time I spend on StackOverflow.  I figure, if you need an example of some bit of code, you can find it there, or other places on the net.
This post is inspired by about 50% of the questions I see on StackOverflow which are extremely easy to answer, because they start with "How do I make a regular expression for" and then some random bit of text. I have some decent scoring answers on these because I can answer them in just a couple of minutes with my trusty internet.  So here's a couple of my favorite resources.
First, get a bit of the basics of Regular Expressions down, use, it's a great site with the best detail in explaining Regular Expressions I've ever seen.  Then, make sure you have a decent test client.  For almost all example…

Why use KnockoutJS

I put together a bit of a proposal for my team and thought I'd post it today.
THE GOAL As far as I know, we’re all in favor of decoupling.
Decoupling code has the purpose of separating code into pieces so that changes are easy.  MVC is an example, in that its purpose is to separate the logic layer (controller) from the view, and pull the objects out into their own little place (the model) so they can pass between the two.
We do this with N-Tier applications as well, as we’ve started pulling our model and logic out into separate projects in visual studio, creating a logic dll and a model dll that is used by the web application (or other application) front end, and separating the database from the webservice from the front end.
THE PROBLEM In decoupling, some people get a bit too gung ho and try to decouple everywhere.   In fact, you’ll see this on Stack Overflow a lot.  The problem I see is that we’re decoupling at the wrong place much of the time.  If you think of decoupling like m…

So you want to code for the house?

Another question inspired this blog post.  When you're a developer, the toughest part of learning new things is finding a project that's both interesting enough to want to do, and simple enough that you won't get frustrated and quit half-way through.  While every early developer probably wants to code the next first person shooter and make millions, most give up and settle for pong, or a text based game.

Finding that niche, that interesting bit of code to write can be challenging, so here's my advice.  Automate.  Code for things that you find tedious.  Code for things that you see other people finding tedious.  Not only are you able to create a time-saver in the process, but you're also creating a valuable product that may later sell.

One of the replies to the question named a few good ones.  Why not host a database to enter your monthly bills?  Then you could calculate power usage, and figure out whether the AC in the summer or the heater in the winter is costing …

Breaking Changes? Don't!

Sometimes other developers give me a funny look when I spend extra time decoupling code, or adding some extra configuration.  I explain to them that it allows for future changes to be easier, and they agree, but sometimes I get push-back and it just doesn't seem worth it to them.  So here's some perspective.

I have a confession to make: I hate python.  I can't stand it.  I haven't always been this way about it though, particularly, the things I hear about it on XKCD consistently make me take another look at it time and again.  The problem is, every time I go to look up some basic tutorials, I plug them into the interpreter and they break.  Even Hello World!

Why?  Because the makers of Python accepted a major breaking change into their code base after the language started to get popular.  In my personal opinion, if you make changes to your language that break a hello world tutorial, then your language can't be trusted long enough for me to spend time learning it.


Dependency Injection for Dummies

In the OOP world, everyone is all the rage about this Dependency Injection stuff.  So what is it?  In order to explain DI, I have to use the term Inversion of Control, so perhaps we should start there?  Well, the truth is, the whole thing is purely about *drumroll please* Decoupling.

When decoupling code, you have to identify the links between pieces of code.  For example, when attaching an arm to a robot, you would have to plug it into a slot in the shoulder.  The decoupled part has to plug into the rest of the code somehow.  However, as with robots, this would get really complicated.  Each piece plugs in uniquely, so if we're plugging in a leg down at the bottom, but it's not working right, we have to check the connection there.

IoC is like having all of the plugs in the robot's head.  The parts might be shaped differently in order to plug into the head, but they're the same parts.  In programming, IoC is the concept of selecting the decoupled parts at the beginning o…

Debugging? Write more tests!

I see alotofpeople on the internet talking about writing unit tests.  While they can provide tons of advice on when you need unit tests, I don't see a lot of people talking about how to start.  I mean, you're not suddenly unit testing on a brand new project.  You're going to likely start with a few thousand lines of spaghetti code.

So where do you start with that?  How do you test the untestable, extremely tightly coupled code that throws errors on every page?  Do you even bother?  Shouldn't you fix it, refactor it, then test it? ABSOLUTELY NOT!*

Unit Test First!
I cannot emphasize enough how important it is to test the code before you change it.  How are you supposed to ensure that existing functionality is kept if you don't find out what the existing functionality is?  Sure, it threw a bug on every page, but they were expected bugs.  They might be accounted for elsewhere in the code, and your change could break everything.

OK, that's out of the way.  You can r…

Prepare for a Programming Career

This post is a result of a question asked on one of my favorite tech forums.

As a programmer I spend a lot of time making sure I'm current.  I like to know what the industry thinks of my choices of languages and I try to make sure I'm learning the most profitable ones.

When I'm looking to keep current, it's important to know how skilled my potential future interviewer will be when I go to sit down for a programming interview.  Sometimes there is a great deal of variance, but overall, this site is a great reference for what types of questions you might get in an interview.  I can't count the times I've been asked about the differences between a class and a struct.

It's important to prepare for fizzbuzz questions.  If you can't answer a fizzbuzz question in the language, then you shouldn't be listing it on your resume.

I thrive on the internet and the massive information that streams about.  That's why I keep up so closely with Stack Overflow and

Decouple that Decoupled Code

Decoupling code is the process of separating concerns. In programming, it refers to separating the code into pieces and ensuring that each piece works on its own. Kind of like a robot might have a robotic arm that can work independently of the rest of the robot.

While not the first, Ruby on Rails has made decoupling popular in Web applications.  Everyone decided to get on the bandwagon here, so even Microsoft came out with an MVC Framework, now in it's 3rd edition.  Developers seem to love MVC.  It's simple, elegant, and most importantly, it's decoupled.

If you ever do Enterprise development, you'll quickly learn that MVC isn't the only way that apps are decoupled.  In many applications, particularly on the .NET side of things, you'll find that code is compartmentalized into components that plug into each other.  It's because of this that I am starting to perceive decoupling as happening in layers.

Let me try to map this out.  In a very very very broad vi…

Starting a Programming Blog

I'm not a big fan of blogging.  I have severalfailedattempts in the past, mostly because I don't have the time for it.  I had pretty much sworn off blogging for good pretty recently.  I had mostly stopped reading my RSS feeds from Google Reader.  The only evidence on the internet that I existed was starting to be my site and my Stack Overflow reputation.

But then, SO is kind of a blog isn't it?  I've been posting quite a bit, on multiple Stack Exchange sites.

I do it, in part because of Eric Lippert's comments,
answering the questions I didn't know the answers to, because those are the ones I would learn from. Mostly though, I prefer Albert Einstein's reason.
If you can't explain it simply, you don't understand it well enough. I got a new a Senior Developer, and I wanted to be good at it.  I started researching concepts like User Stories in SCRUM and Agile.  I started to monitor things like ISC and DZone much more closely than I h…