Lazycoder

17Aug/040

Amen Mikhail

Naming conventions: I don’t like camel and I do like Hungarian

Mikhail says he’s not really in love with camelCasing. I use it all the time and I did before I started coding against the .NET Framework. His example makes sense, although anyone who’s naming their vars “a”,”b” and “c” should be shot. ;)

My favorite example when I’m arguing for the use of pseudo Hungarian (or full Hungarian) is DateTime vars. I work in the web world so I’m always using the ToShortDate or ToLongDate methods on DateTime variables. If I’m passing around a DateTime string what should the var be called? shortDateTimeString? or just shortDateTime? That’s not really descriptive, lets use startDate. Does startDate return a DateTime or a String? Should I name the var startDateShortDateString? Wouldn’t strStartDate be better than startDateShortDateString? The “hover over the variable in the IDE” trick only works if you are in the IDE and if the IDE is working (I’ve had to restart Visual Studio more than once to get intellisense working again).

Filed under: .NET, C#, General, VB.NET No Comments
28Jul/041

What’s all the hub-bub, bub?

Julia Lerman Blog – Don’t Be Iffy… – Holy Canoli They’ve DONE IT! Drill all the way into data objects in the debugger

I’ve always drilled down into my objects in the Locals and Auto windows in the debugger. Am I missing something overly dramatic here?

updateLooks like Ian Griffth had the same question. Julia explains that the VB debugger and the C# debugger are apparently horses of different colors.

Filed under: .NET, C#, VB.NET 1 Comment
12Jul/041

C# AND VB.NET suck

A well-deserved smack back to some C# zealotry

“When are these C# zealots going to stop telling us VB.NET programmers that we suck, our language sucks, and that we don’t know how to use our own language.”

About the same time the softie suck-ups quit telling Java, Perl, and PHP programmers and Linux users that their language sucks and their software sucks. In other words, never.

BTW I program in C# 90% of the time in my job and I’ve never had to use unsafe code even when writing interop code. Why use unsafe code when you can write safe code eh? Generics seem to me like delegates in that they seem to solve one specific problem (typed collections) and really don’t have any other uses. I haven’t written any high-performance apps in .NET yet so the whole boxing vs. non-boxing code performance hit hasn’t affected me yet. Maybe that’s a bigger deal than I think?

I “grew up” on VB 4.0 (32-bit thank, no 16-bit for me. I looked forward and never looked back!). I did the majority of my professional programming using VB 5.0 and 6.0. Why did I choose C#? The simplicity of the language. I had just spent about a year doing some Java programming. I didn’t have a lot of extra syntax and functions to learn along with all the namspaces. Does that mean that VB.NET sucks? No. Now that I’m more familiar with the .NET framework, I’m thinking about using VB.NET more often. I’m using it exclusively at home to build little shortcut applications for my wife and I. When I saw Jeff Greene demo the new “my” syntax for VB I praised his name. Finally they are putting the VB back in VB.NET. The only thing I don’t like about VB in general after programming in C# and Java is how much TYPING you have to do in VB. Ye Gods, I’d never noticed it before. Eh, it gives my fingers a good workout anyway.

Arguing over programming languages or operating systems is like running in the special olympics. Even if you win, you’re still retarded.

P.S.And “hear hear” on the death of case sensitive languages! We’re not in the 80′s anymore!

Filed under: C#, VB.NET 1 Comment
11Jul/040

Wesley might have made a few mistakes…

The Code Project – C# Performance: Mistakes My Friend Makes – C# Programming

But Ellery makes a couple of his own.

Prefixing your variables with the type (i.e. sName), is not very .NET. Reason for this being that your variables are suppose to have meaningful names which allow their type to be identify without the need for a prefix. Itís pretty easy to see the variable types of firstName and dateOfBirth. I believe most people who do this are/were VB programmers who canít get rid of the habit.

So what’s the type of dateOfBirth? Does it return a string? Is the date it returns a DateTime short date string or long date string? Does it return a DateTime type? Do you have to hover over the var name to find out? How much time does that take our of your day, trying to find the right hover spot in Visual Studio?

In Wesleyís code, the SqlParameter does nothing but introduce unnecessary overhead and code complexity. You can provide parameters to a stored procedure by simply executing it in the SQL code (i.e. ìEXEC usp_GetUserDataByID 257;î).

Yes, that’s a great idea provided that Wesley doesn’t care about SQL injection attacks? Concatinating together an “EXEC” statement to execute a stored procedure is almost as bad as concatinating the SQL string together.

Although not seen in this code example, he ALWAYS sets the CommandType property of the SqlCommand objects, even when he needs CommandType.Text. Text is the default value for that field. No need to set it.

You should never rely on the default properties of classes and methods. What happens to your code if the default property or the underlying enum is changed? Ellery has some learning to do to.

Filed under: .NET, C#, Database, VB.NET No Comments
26May/040

Nullable types in C#

Making it stick.: “Nullable Types”

I don’t know about the nullable type syntax. It looks a little hackey to me. It doesn’t seem very elegant.

Filed under: C#, VB.NET No Comments
26Mar/048

I give up on VB.NET

Google Search: DefaultValue Attribute VB.NET

It really IS the bastard stepchild of .NET. It’s just so much easier to code in C# than it is in VB.NET.

I’m writing a custom web control. I have a property called “TabItems” which is an ArrayList holding, TabItem classes. I want to set a Default Value. How do I do that? The only example I can find in the MSDN docs uses a boolean property and sets it like so.

<defaultvalue (False)> _
Public Property MyProperty() As Boolean

yeah, duh no kidding. The only other examples I can find use string properties and set the DefaultValue to “”. DUH. What about an actual type?

I’m going back to C# now, let somebody else play in the shallow muddy end of the .NET pool with VB.
edited because I forgot that WordPress doesn’t URLencode the posts

Filed under: C#, VB.NET 8 Comments