- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
First!
Admin
Well... It's not a bug, it's a Feature
Admin
Every time I see hungarian notation, I die a little on the inside...
Admin
Hungarian style naming conventions can be useful. Not so much for the type, but for many other things, such as scope, accessibility, mutability - all of which can not be seen directly in the context [though they can be navigated to].
Admin
I have to disagree - you CAN write good code with VB6. Or any other language, including PHP (even PHP4, if we're talking legacy). It's just hard. A great programmer will do it, but the language just doesn't help at all. Also, I'm only referring to the language, not the whole environment. If the language practically promotes bad quality, you can expect most of third-party libraries and even some of the standard ones to be completely braindead to the point where you cannot use them in good code and have to roll your own, or at least hide them behind well-written but ugly wrappers in order to keep the main application code clean. Waste of time and money.
So - possible, difficult, time consuming and just not worth it.
Just like you don't need an OO language to write OO code. It's just a lot harder and difficult to read lacking the syntactic sugar. Which means it's usually not worth it - just pick a language that suits your needs or adapt to the language paradigm. E.g. don't use VB6, ever. Or, if forced - adapt! Just give up trying to make the code good. And probably freshen your resume, time to leave...
Admin
collection, connection, who cares?
Admin
At least this solution suffices as security by obscurity against evil developers. Lots of bad things could happen if everyone could access the connection string easily!
Admin
Where was that Microsoft thing about .NET posted? I'm curious to read that article or whatever where they say that. I've never particularly cared for VB.NET but I have nothing against it, I just prefer C# for how it looks. But I've seen well-written OO VB.NET and spaghetti C#, so it's not the language (even if VB.NET is a bit ugly)
Admin
There was a reference at Joel on software how Hungarian notation should be used. Read it, it is good!
Fortran-4 (F-66) did have If but no else. You simulated ELSE with GOTO's and negated conditions.
There are a few syntactig sugar I do like in WB. Getters and Setters are more locigal than many other languages.
Admin
Lets build a wall to keep those Hungarians out!
Admin
Wait - is the set function wrong?
value is passed in by value, but is being assigned. I would think those should be swapped.
Admin
@Brian Boorman Yes, that's right. Maybe. Or, at least, that's the point: these functions are so terrifyingly bad that there's no way to tell what they are supposed to be doing.
Admin
I used to think this, then it was pointed out by others on this forum that a better location for that notation was in the type system (should one be available, like C++ and unlike C). Instead of putting the type of the variable in the name, put it in the type.
Instead of
std::string uInput = getInput(); // u for unsafe std::string sInput = sanitize(uInput); // s for safe
create a class SanitizedText that takes a string as an argument for its constructor.
std::string input = getInput(); SanitizedText sane(input);
Then define functions like
void writeToDatabase(SanitizedText str);
That way, writeToDatabase(getInput()) is either a compiler error or an automatic sanitizing before passing to the database. This way, wrong code is actually an error, rather than just looking like an error.
Admin
I think this is the referenced article/blog
https://blogs.msdn.microsoft.com/dotnet/2017/02/01/the-net-language-strategy/
Admin
Fixing formatting:
std::string uInput = getInput(); // u for unsafe
std::string sInput = sanitize(uInput); // s for safe
=====
std::string input = getInput();
SanitizedText sane(input);
Admin
OT: Unicorns?!?
DailyWTF-WTF: Every time I double click on "collection property" (under the code) I got unicorns?!?
Admin
Without going back to the article, from your comment, I can tell it was posted by Remy Porter. He does that (redacted).
Admin
Habit of Remy Porter (he always hides that somewhere in his articles)
Admin
Seems a bit unfair to characterize F# as a language for use by "people who have to use .NET." I'm quite sure F# is capable of attracting folks who are not merely "stuck" in the .Net ecosphere and compares favorably with any other functional language.
Admin
As somebody who has had to try to write good code in PHP, both v4 and v5, no, it's not really possible.
The reason you can't is: A. The PHP libraries force you to do brain-dead things. The only way you could possibly get around that is to basically write an entire new library for PHP, in C, and compile your own version of PHP. These range from little stupidities (like using both under_score and camelCase in the standard library), to annoyances (not throwing exceptions when they should), to really serious problems (e.g. mysql_query(), otherwise known as how to have your language practically encourage SQL injection attacks). B. The PHP language is wildly inconsistent. For example, there are many different things that can happen in case of a problem, ranging from "nothing obvious" to "interpreter seg-faults with no error message", when what should happen is "you get an exception and a call stack".
Frameworks like Zend that exist now make it not totally terrible for your own code by wrapping all the gnarliness behind a somewhat-less-gnarly chunk of sorta-library code. I say "sorta-library" because there's no real way to have library code outside of your code base like most other languages (C, Java, C++, Perl, Python, Ruby, etc) do.
Admin
That "if OrElse" bugs me...
If moConnection is set (not Nothing), it short circuits the check the state of moConnection and closes moConnection, even if it's already closed.
If moConnection is not set (Nothing), it goes on to check the state of moConnection and that should throw a NullReferenceException.
Either they wanted something more like: If Not ((moConnection Is Nothing) OrElse (moConnection.State <> ConnectionState.Closed)) Then or If Not (moConnection Is Nothing) AndAlso (moConnection.State <> ConnectionState.Closed) Then
Addendum 2017-02-06 11:43: That last part didn't break where I thought it would...
If Not ((moConnection Is Nothing) OrElse (moConnection.State <> ConnectionState.Closed)) Then
or
If Not (moConnection Is Nothing) AndAlso (moConnection.State <> ConnectionState.Closed) Then
Admin
We use VB.Net at work, primarily because all of the old code was originally written in VB6. It was ported to VB.Net maintaining the horrible globals. I have been replacing it slowly with newer "clean" object oriented code, so I am kind of disappointed to see the split in direction. VB.net is powerful and handles a few things better than C#, though not too much. We will have to see what happens in the future.
Admin
VB.NET does, as you say, handle a very few things better than C# (string casing for example).
If I ever have to work with VB6, I try to rewrite it in C#, keeping in mind that the latter language is much less forgiving (e.g., VB6 swallows DBNull values; and who can forget On Error Resume Next?).
Admin
Because this could never be done in C#:
Admin
His reasoning was pure bullshit in any sane language with competent people.
Admin
When taking over VB.net projects some of our guys prefer to decompile them as C# and go from there.
Admin
The trick is that by calling the setter, the global moConnection (obviously a reference to the holy prophet) is initialized:
Admin
I think I could write this just as badly in c#
Admin
But...But...Why?