Skip to main content

Must Have Tool: NDepend

Code quality tooling has become a bigger, and bigger industry. Tools like Resharper, and stylecop have been telling us how bad us human beings are at developing code.

The one problem I have always had with these tools is they dont go above and beyond to help you understand your code at a higher level.

Continue Reading

Watching the Watchers: Monitorama PDX 2014 Day One

I am here in lovely Portland Oregon attending Monitorama. Monitorama is a 3 day open source monitoring convention.

Monitorama had catered food, and drink. The food was plentiful and delicious, and the drinks were amazing.

There were 10 talks, I have made a quick summarization below. I don't have time to write in detail about each one, but I am sure you will get the gist from the basic summary.

Continue Reading

ChromeOS: Gateway to portable productivity

Up until the last few years the only devices on the market were all full operating system work horses. However the majority of us would easily sacrifice functionality for portability. This statement has been backed up by the increase of market demand for tablets and ultrabooks over the years.

Continue Reading

Value types vs Reference Types in C#

In C# there are two kinds of types...Value and reference...

What are Reference Types?

Reference types in C# are mostly objects and strings. These are types when placed on a stack refer to a memory address in the heap.

What are Value Types?

Value types make up the bulk of types in c#. These include int, float, double, long, bool, etc. These types values are only stored in the stack.

Stack? Heap? What's the difference?

To put it short, the stack is a series of memory blocks (like a scratch pad) that is used for the current thread. The stack is used for basic property data access. Accessing the stack is very rapid, as its only used for trivial data. The heap is an area of memory for dynamic memory allocation. The heap is used to store things in data that are not value types, usually objects and strings. The heap is slower to access, but larger in size.

Reference type tripping points

Reference types are basically pointers. These pointers can trip you up in interesting ways. For example suppose you have an object called MyObjectName:

var MyObjectName = new SomeClass();

and you decide to make someone else's object name the same as you're name


var OtherObjectName = MyName;

When you change MyName to be something else, you will also change OtherName.

This is because objects are a reference type. On the stack the object is a pointer reference to the heap. When you make OtherName equal you are pointing it to the same memory address as MyName. You can see this in action here

var MyName = new SomeClass();
var OtherName = MyName;
MyName = MyName.Name = "Joe";
//OtherName will now equal Joe

This is also the same for array's if you make 1 array equal another, you will not have 2 array's with the same value. You will have 2 variables that point to the same array.

So the same must work for value types right?

No

If you have 2 ints and assign one int to equal the other. The value on the stack will be copied to that int, and since the stack value is the actual value they will be independent of each other.

Boxing and Un-Boxing

When you have a value type and you want it on the heap you must convert it to an object. This is called boxing

var val = 3;
var x = (object)val;

However once you do this, the two variables will be independent from each other. So if you change x you won't change val and vice-versa.

To get the object back on the stack you must cast it back into an int. This is called un-boxing


var y = (int)x;

Continue Reading

Custom error pages in Nancyfx (C# Web Framework)

To do custom error pages in Nancy you must implement an IStatusCodeHandler. This class must provide 2 methods. HandlesStatusCode is a bool that basically should tell Nancy if this class will handle the status code. If this returns true then this class will be responsible for handling the request.

Continue Reading

Capturing Client Side JavaScript Errors

Capturing client side errors in my opinion is really good. For starters you can troubleshoot your client side implementation, but you can also make sure a js change did not break certain pages.

Below is a really simple, yet effective way to capture errors. Eventually you may want to implement something more advanced, but this will get you out of the gate.

Continue Reading

You hired adults, not children

One of the things that I often see in our industry is the culture of access control. Security measures are put into place, because you wish to restrict access to a certain thing. Systems like HRIS need such restrictions, as private information should not be publicly available to the company. However often systems that don't need security controls put into place end up having them.

Most people understand where they fall in the business, and the authority delegated to them.

Continue Reading