• Fristo (unregistered)

    First!

  • McRuffin (unregistered)

    Well... It's not a bug, it's a Feature

  • ApoY2k (unregistered)

    Every time I see hungarian notation, I die a little on the inside...

  • TheCPUWizard (unregistered) in reply to ApoY2k

    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].

  • akozakie (unregistered)

    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...

  • bvs23bkv33 (unregistered)

    collection, connection, who cares?

  • subes (unregistered)

    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!

  • (nodebb)

    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)

  • Hasse de Great, (unregistered)

    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.

  • ThaHax0r (unregistered)

    Lets build a wall to keep those Hungarians out!

  • Brian Boorman (google)

    Wait - is the set function wrong?

    value = strConn

    value is passed in by value, but is being assigned. I would think those should be swapped.

  • (nodebb) in reply to Brian Boorman

    @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.

  • MZH (unregistered) in reply to Hasse de Great,

    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.

  • Matt Smucker (google)

    I think this is the referenced article/blog

    https://blogs.msdn.microsoft.com/dotnet/2017/02/01/the-net-language-strategy/

  • MZH (unregistered) in reply to MZH

    Fixing formatting:

    std::string uInput = getInput(); // u for unsafe

    std::string sInput = sanitize(uInput); // s for safe

    =====

    std::string input = getInput();

    SanitizedText sane(input);

  • SG (unregistered)

    OT: Unicorns?!?

    DailyWTF-WTF: Every time I double click on "collection property" (under the code) I got unicorns?!?

  • (nodebb) in reply to SG

    Without going back to the article, from your comment, I can tell it was posted by Remy Porter. He does that (redacted).

  • (nodebb) in reply to SG

    Habit of Remy Porter (he always hides that somewhere in his articles)

  • Brad Wood (google)

    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.

  • EatenByAGrue (unregistered) in reply to akozakie

    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.

  • (nodebb)

    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

  • Jeremy Hannon (google)

    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.

  • (nodebb) in reply to Jeremy Hannon

    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?).

  • Paul Neumann (unregistered)

    Because this could never be done in C#:

    	private OleDb.OleDbConnection moConnection;
    	[IndexerNameAttribute("DBConnection")]
    	public string this[string strConn]
    	{
    		get { return strConn; }
    		set {
    			value = strConn;
    			if (moConnection != null || moConnection.st	 != ConnectionState.Closed)
    				moConnection.Close()
    			moConnection = new OleDb.OleDbConnection(strConn);
    			moConnection.Open();
    		}
    	}
    
  • (nodebb) in reply to Hasse de Great,

    His reasoning was pure bullshit in any sane language with competent people.

  • Mr. M (unregistered) in reply to slavdude

    When taking over VB.net projects some of our guys prefer to decompile them as C# and go from there.

  • JimTonic (unregistered)

    The trick is that by calling the setter, the global moConnection (obviously a reference to the holy prophet) is initialized:

    connections.DBConnection("DataSource=…") = "Initialize the day-ter-base";
    Assert.True(connections.DBConntection("DataSource=...") == "DataSource=..."); // Yay, it works!
    connections.moConnection.DoDayTerBaseStuff(Request.Params["sql"]);
    
  • FuuzyFoo (unregistered) in reply to Brian Boorman

    I think I could write this just as badly in c#

  • Scrabblez (unregistered)

    But...But...Why?

Leave a comment on “Strung Out Properties”

Log In or post as a guest

Replying to comment #472215:

« Return to Article