Simplicity is beautiful

I saw a great post yesterday from CodeBetter that had a great quote…

in general, the .NET crowd overthinks and over-engineers just about everything

No matter how bad that sounds – you have to admit it’s probably true (though, im sure its not just a .net thing – it’s a developer thing). Over thinking and overdoing isn’t always wrong – that extra step may be ‘the next big thing’ or pushing the boundaries of what’s already been done. But in most day to day work, sometimes we could just be wasting our time.

His post actually references a post made before it – about jumping the 20% fence. While I didn’t feel that this was pushed in the article, I feel that a good chunk of the ‘bugs’ every developer faces can be from over thinking the actual problem. The more complex your project (as a programer, or any other profession really), the more complex the bugs can be, and the more difficult it can be to get to the root of the problem.

That’s not saying you have complex problems to solve. When solving thee problems, its amazing to look back and say ‘wow, I really did that, and it works!’. But one thing that has always helped me is to break everything down and look at it piece by piece. Develop each piece, and link everything together. Then This not only helps simplify the problem, but helps you to refractor your code as well. Once you know each of these pieces, refactoring is much easier, and helps you see the problem solved as a whole in the end. Finally, if even a ‘little piece’ is to complicated, theres a chance that it can be broken down even more.

I have found that focusing on each of these pieces, getting them done, and moving on – it really adds up. Taking a break isnt bad either – plenty of times I have felt ‘stuck’ on a problem, got up to get something to drink, and came back to easily solve something I thought was near impossible just moments before.

Personally though, I think this may be one of my favorite quotes:

Simplicity is beautiful.


Freelancing, work, and life!

Life’s been pretty busy for the last few weeks as I get adjusted to a new job (and new schedule), the holidays are fast approaching, and making changes on this site! I have a few drafts that I started putting together to post in the next week or so from things I have learned, and some of my new projects!

  • The new job is amazing. I get to work on cool software with a cool language, and have a fun time doing it. Im still getting up to speed on quite a few things, but already making progress on quite a few of my tasks.
  • My work on is coming along nicely, especially thanks to Deborah, for working on some hotels in her free time. I plan on spending some time this weekend on it, and creating a plan of execution in the short term. Im hoping we can launch around the first of next year!
  • I have a new personal project im starting up ( a forum ) but haven’t had much time to invest into it – more on that later.
  • I’m freelancing to make some extra money. I actually didn’t expect it to be this easy. I already have clients coming to me by word of mouth, and I haven’t even advertised myself yet. Im mostly doing development, SEO work, and just helping people find a web presence,  so if you are interested, PLEASE contact me! I just finished my first large project!
  • This should be the last weekend with Toby. We actually have 2 more people interested in him, and he also goes and meets with the SPCA on Monday.
  • While I wanted to start really learning PHP and Perl, it looks like Cocoa/Objective-C may be first. I went to my first Richmond Cocoaheads meetup last night, which was awesome. While im VERY new to cocoa (the last time I really programed on a Mac that wasnt BASH scripts was with MPW and C++ console apps.
  • Many parties and other events going on this weekend and next week, all the way through the holidays. I hope to take tons of pictures, this time of year is always so beautiful.

Listening To: ‘Since I’ve Been Loving You’ by Led Zeppelin

Getting around lack of ItemBound on a ListView in WPF

I recently was working on a project where I needed to bind some data to a ListView in WPF. This is pretty easy, and using my Dataset, took really no work at all. But when trying to figure out some simple ways to update my ListView on each item being bound (where you would usually use a OnItemBound event in other controls), this (and nothing like it) really exists in a WPF ListView control.

There were a few workarounds for this. I could update how my DataSet was being generated, and just bind those ‘special’ controls in the ListView in these new fields, or use a List that I found in this post. While updating the DataSet would be nice, using a List may let me knock out two birds with one stone (due to some other requirements).

So I set forth mapping the DataSet to my List. This is as simple as doing something like…

List theItems = new List();

foreach(DataRow dr in ds.Tables[0].Rows)
MyItem tmpItem = new MyItem();
tmpItem.Value1 = dr["value1"].tostring();
tmpItem.Value2 = dr["value2"].tostring();


I can then map this collection to my ListView, rather than the DataSource itself. All I have to do in my XAML then is just update my ‘DisplayMemberBinding=”{Binding value1}‘ to point to the new item in the list ‘DisplayMemberBinding=”{Binding Value1}‘. If one of those is a bool, and I have that mapped to a Checkbox or RadioButton, its a little easier for me to manage (being so used to having the option to do an OnItemBound method to handle some of the same stuff). My bigger concern of needing this was to convert values on the fly. For example, if something is returning any value (int or null), id like to map that to True or False instead. This is a really simple example, but just an idea of something you could do if you needed this extra functionality!


Listening To: ’15 Step’ by Radiohead

Setting a character limit on a multi line text box in 2.0

I looked all around to find this code when looking for it the other day. There were plenty of places that explained how to do this, but I couldn’t easily find something that JUST worked in the case I needed it to.

We had a site we were developing at work, written in ASP.Net 2.0 (C#). The user the software was targeted to is famous for ‘not following directions’, and we needed to restrict the number of characters they could type into the field. You see this in many places online, and quite honestly, it can even help the user experience. In Visual Studio 2005, you can do this easily on a text box by setting the ‘Max Length’ property. But if its a multiline text box, that wont work. It has to do with how multiline text boxes are rendered versus other text boxes. As I said before, many sites explained how to do this, but nothing actually JUST worked in our situation, so I have placed here code that DOES work, and in most browsers.

To start, one would place the following code in the ASPX page.

function textboxMultilineMaxNumber(txt,maxLen){
if(txt.value.length > (maxLen-1))return false;
// --></script>

The code above is basically a javascript that checks the length of the text in the textbox, and compares it against your maximum length. As long as this is true, you would be able to insert text into the box, then once it hits false, you can no longer enter text.

In your code behind, you need to then need to add an attribute to the text box, to link this JS to the text box.

txtNotes.Attributes.Add("onkeydown", "return textboxMultilineMaxNumber(this,250)");

This of course assumes that your textbox is called txtNotes. This particular line limits the text to 250 characters.

We have found this to work in most browsers. There are ‘gotchas’ of course, including users having javascript turned off and that if you copy and paste code into the box, it will still allow that. Therefore, follow general good practices and still check that your user is only entering the amount of text they can!