Using Ruby Naming Conventions in C# code? Is that madness?
During my journey in learning Ruby / IronRuby, I have caught myself often naming things in C# with a Ruby convention or BDD test naming regime. To be extreme here’s an example:
var customer_to_make_preferred = Get_Customer_By_Id<ICustomerMakePrefered>(); //OR METHODS LIKE THIS public void Group_By_Orders_And_Print_To_Console_Window() { //…..etc }
I really find a benefit in greater understanding when reading code when I take this approach. Now it’s true I have been programming in C# for some 10 years and I don’t know if this kind of behaviour will see me excommunicated from the circle of brethren or not but I would like to know what others think.
Opinions please! And yes I know this is gonna be like waving a red flag in front of a raging bull :). And for the Ruby people, I am only proposing the extended underscored naming convention and nothing else – it’s all about naming and that’s it – ya basta!
6 Comments so far
Leave a reply









Looks like two functions needed:
Group_By_Orders
Print_To_Console_Window
I think naming conventions should be “universal” and not based on just a particular language
[Reply]
Hi Steve
Yep agree on the functions of course. If naming conventions were indeed universal which ones would you prefer? My colleague Mark happily accepts naming tests (whether they be BDD / TDD or plain old unit tests) with this scheme but warned me that he despised the idea for method scoped variables. Moments later he noted that it was something that he probably objected to simply out of established habits and not for any practical reason.
[Reply]
I should probably add that I have found this naming convention useful when doing proof of concept work on internal DSL’s with C#. For example:
NorthwindLangQuery .BeginQuery() .Customers() .With_An_Id_Equal_To(“ALFKI”) .With_Orders_Shipped_From(“Germany”) .That() .Are() .Older_In_Years_By(2) .EndCustomerQuery() .Flatten_And_Print_To_Console_Window();[Reply]
Simon,
“despised” is rather a harsh word. I guess that if naming is something that was universal then this would not be something to debate.
IMHO it comes down to readablitiy and how well the name of the variable/method etc give the people who will be charged with understanding what i have done.
I know can read
public void Group_By_Orders_And_Print_To_Console_Window()
{}
just as easily as i read
public void GroupByOrdersAndPrintToConsoleWindow()
{}
and to me there is no difference in my understanding of the intent of the method.
[Reply]
Mark
I think my brain finds the underscore somewhat like a whitespace in this regard and hence my preference.
[Reply]
I’m fine with that naming scheme for tests - I use that as well
[Reply]