Category Archives: Ruby

Why are Non-microsoft conferences so much better?

I am a .Net coder. I like it, I really like C#. Not kidding at all – I really do.

But DAMN man! I went to Ruby Midwest this last weekend and it was so much better than any Microsoft technology based conference I have ever been to.

Two things were different

The first thing

Probably the most important is so simple. I do not need someone show me where menu items are in the tools. How many times have you been to a Microsoft conference to spend 45 minutes at a time listening to this:

Go to Tools –> SubItem –> SubSubItem and click this to increase the font…

Jeesh man, that is what Google is for, manuals are for, or in new Visual Studio, they added the quick launch box. Holy cheese batman, that thing is gonna KILL all the Microsoft conferences. what will they ever talk about now? (Maybe 15 min on how to use the quick launch box?)

If I want to learn how to use an IDE or other visual tool, I can do that without paying a conference fee and giving up time with my family. I also realize that this is not the only thing that goes on at Microsoft conferences – there is a lot of good at these conferences too. Seem like though, the MS conferences weigh a lot heavier on the Black And Decker how to manual side of things.

Second Thing

One track conference. I am sorry all you nerds, but you need the soft skills talks if you want to max out the possibilities in your life (and coding). The best code writer in the world is probably hiding somewhere and typing this beautiful, pristine code out by him/herself somewhere right now. It is code so tight and so clean that it could squeeze a tear out of a rock. But,we will never see this beautiful code. Indiana Jones couldn’t find this code with three bullwhips and six trained monkeys. Ever. It takes talking to people, to humans, to get your code out in the wild; either through open source or your job. Sorry.

One track conferences like Ruby Midwest force you to sit through soft skills talks as well as straight on nerd fare. Unless you leave (one entire company I know did…) the conference altogether, you are going to learn something about how to work with other folks. This is crucial stuff my friends. Really crucial.

Write code better and get that code to other people!

Unless the Microsoft community starts to teach about how to write code better, and how to get that code to other people at their conferences, we will not move forward as a community.

Don’t get me wrong. I really value the work, thought, and sacrifice that Microsoft based conference organizers put in. Organizers like Lee Brandt work a TON to put on conferences like KCDC. The folks in Iowa do an amazing job with Iowa Code camp. They can’t offer talks that aren’t proposed though.

I am not sure of the exact next step to get this better but would like to throw this volley out to start the conversation.

Thanks for hanging in this long,

Happy coding,

Jim

Extension Method Bliss

In the last six months, I have dabbled a little bit in Ruby. What I found was that I didn’t really want to work in Ruby but I wanted some of the beautiful syntax. I use extension methods to bring some of that goodness back to C#.

Here are a few favorites:

public static bool IsANumber(this string value)
{
float output;
return float.TryParse(value, out output);
}

public static bool IsNotANumber(this string value)
{
float output;
return !float.TryParse(value, out output);
}

public static string FormattedAsAPhoneNumberWithDashes(this string s)
{
if(s.IsNotANumber() || s.Length != 10)
{
return string.Empty;
}

StringBuilder formattedPhone = new StringBuilder();
formattedPhone.Append(s.Substring(0, 3));
formattedPhone.Append("-");
formattedPhone.Append(s.Substring(3, 3));
formattedPhone.Append("-");
formattedPhone.Append(s.Substring(6, 4));
return formattedPhone.ToString();
}

public static string XmlEncode(this string s)
{

return string.IsNullOrWhiteSpace(s) ? string.Empty : System.Security.SecurityElement.Escape(s);
}

public static bool IsNullOrWhiteSpace(this string value)
{
return string.IsNullOrWhiteSpace(value);
}

public static string SafeTrim(this string value)
{
return value == null ? string.Empty : value.Trim();
}

public static string SafeParseStringToDate(this string dateToParse)
{
DateTime dtTemp;
return DateTime.TryParse(dateToParse, out dtTemp) ? dtTemp.ToString() : string.Empty;

}

public static string TrimmedAndLowered(this string value)
{
return value.SafeTrim().ToLower();
}

public static string AddAProperCommaToAName(this string lastname, string firstname)
{
if (!string.IsNullOrWhiteSpace(lastname) && !string.IsNullOrWhiteSpace(firstname))
return lastname + ", " + firstname;

return !string.IsNullOrWhiteSpace(lastname) ? lastname : firstname;
}

public static bool IsNotNull(this object obj)
{
return obj != null;
}

public static bool IsNull(this object obj)
{
return obj == null;
}

public static bool In(this string value, params string[] paramArray)
{
	return value.IsNotNull() && paramArray.Any(param => param.TrimmedAndLowered() == value.TrimmedAndLowered());
}

public static bool In(this int? value, params int[] paramArray)
{
	return value.IsNotNull() && paramArray.Any(param => param == value);
}

public static bool In(this int value, params int[] paramArray)
{
	return paramArray.Any(param => param == value);
}

public static string RemoveNumericCharacters(this string value)
{
	Regex regex = new Regex("[0-9]");
	value = regex.Replace(value, "");
	return value;
}


public static string RemoveNonNumericCharacters(this string value)
{
	if (value == null)
		return string.Empty;
	Regex onlyNumeric = new Regex(@"[^\d]");
	var result =  onlyNumeric.Replace(value, string.Empty);
	
	return result;
}