• JD (unregistered) in reply to protected static

    I believe the MoveLast / MoveFirst thing was in order to get the right recordcount

  • (cs) in reply to picker du nit
    picker du nit:
    My point was: is there a scenario in which wq wouldn't work, but wq! would?
    If a file is read only, :wq will fail and vi will not exit, whereas :wq! will exit anyway (even though the file isn't saved). It's really two commands, and the ! modifies the q from quit-if-write-succeeds to quit-regardless.
  • (cs) in reply to Edward Royce
    Edward Royce:
    Hmmm.

    This makes baby Jesus cry.

    And me seriously consider giving up programming.

    Perhaps I'm a bit behind the curve here but isn't the process of an application actively modifying code during execution a serious liability in debugging?

    Jeez. And I thought the angst over excessive pointer manipulation in C applications was a pain.

    Well, that's a huge topic of discussion, and you're already ahead of the curve on it.

    I used to try self-modifying code in Z80 -- bad idea, although the three bits that affected the rotation instruction were just about manageable.

    For "sensible" self-modifying code I think you need something like Lisp macros (or Scheme sanitised macros, which are mildly controversial).

    For self-modifying code a la reflection, properly implemented, well ... I think it depends upon the scope.

    What I think is a theoretically good model would be some construct that takes an object (or, I suppose, even a class, or for that matter a closed function) and does the necessary transforms for whatever reason appears to be useful within the current scope. And then discards the modifications.

    This would imply idempotency; thus the reference to the Lisp family.

    For mongrel dynamic languages like Perl, Python, Ruby (and for that matter C# and VB.Net), I'm not convinced that it's a good idea -- at least outside libraries.

    The reason? 95% of the idiots using reflection in these languages are not aware of the dangers involved.

    Thus the J2** Enterprisey WTFs that appear all over the place.

  • (cs) in reply to JD
    JD:
    I believe the MoveLast / MoveFirst thing was in order to get the right recordcount
    Oh yeah, I remember that, but I thought there was another gotcha buried in there... It's been a while - I haven't written 'spreadsheet'-style data access code in ages.
  • (cs) in reply to snoofle
    snoofle:
    picker du nit:
    My point was: is there a scenario in which wq wouldn't work, but wq! would?
    If a file is read only, :wq will fail and vi will not exit, whereas :wq! will exit anyway (even though the file isn't saved). It's really two commands, and the ! modifies the q from quit-if-write-succeeds to quit-regardless.
    And from here on in, consult your friendly local google page ...

    I was wrong. Using a spling in this case would be wrong. Short of an actual code exorcism ("Begone, foul VB!"), I would definitely prefer to have vi complain that I can't write the result out.

    Of course, using the ColtMagnum editor on the original developer would be even more appropriate:

    DYFLPunk?.357

  • picker du nit (unregistered) in reply to real_aardvark
    real_aardvark:
    I was wrong.

    That's what I wanted to hear ;) I was expecting To end the sentence! as an answer to my first question though :)

    I must confess that I'm feeling a little embarrassed with my childish pedantic posts. Thank heavens for an internet in which you don't have to reveal your true identity.

  • insertwittyscreennamehere (unregistered) in reply to picker du nit
    picker du nit:
    real_aardvark:
    I was wrong.

    That's what I wanted to hear ;) I was expecting To end the sentence! as an answer to my first question though :)

    I must confess that I'm feeling a little embarrassed with my childish pedantic posts. Thank heavens for an internet in which you don't have to reveal your true identity.

    If you never reveal your identity, then how will you get your money from the nice Nigerian prince?

  • (cs) in reply to picker du nit
    picker du nit:
    real_aardvark:
    I was wrong.

    That's what I wanted to hear ;) I was expecting To end the sentence! as an answer to my first question though :)

    I must confess that I'm feeling a little embarrassed with my childish pedantic posts. Thank heavens for an internet in which you don't have to reveal your true identity.

    You're welcome.

    However, I think you're still completely missing the point.

  • frustrati (unregistered) in reply to webrunner
    webrunner:
    JonC:
    Reflection isn't Microsoft specific, though it is used quite a bit in .NET http://en.wikipedia.org/wiki/Reflection_(computer_science)

    Wow that is.. a special article. Notice how the 'example' section just seems to be an argument between two editors on how to instantiate an object in Actionscript.

    I also noticed that the Java code snippet (the seventh in the Example section) is the only sample that is not introduced by "Here is an equivalent example in..." Leading me to believe it was once at the top, but somebody decided to reorder the code by erhm... decreasing usefulness?

    I am too lazy to back this up by looking at the article's history. But not too lazy to post about this on DailyWTF.

    Oh, and what is up with "a trigger-like system" in the OP? Isn't this called the observer pattern?

  • David (unregistered) in reply to TV John

    I'm pretty sure the poster said extremely clearly that GetRecordCount RETURNS a boolean, not that it gets automatically cast to one. There is nothing ambiguous about that.

  • (cs) in reply to frustrati
    frustrati:
    Oh, and what is up with "a trigger-like system" in the OP? Isn't this called the observer pattern?

    You expect people to have books on design patterns? Like the one by the gang of four?

  • Spastic Weasel (unregistered) in reply to Sunday Ironfoot

    Reflection more or less == java introspection

  • Harrow (unregistered) in reply to Edward Royce
    Edward Royce:
    Perhaps I'm a bit behind the curve here but isn't the process of an application actively modifying code during execution a serious liability in debugging?
    Not only for debugging, but it's also a serious security liability. No trusted program should have the authority to modify its behavior without constraint, based on data recieved from outside its trust boundary. That's why you are hearing about "implementing security by monitoring the call stack programmatically" -- this is a Rube-Goldberg attempt to heal a fundamentally broken security model.

    Every application must execute a subset of its repretoire for each input it encounters, but if the input data is not trusted, then the repretoire must be. Otherwise you have written an obscure, opaque, untested interpreter.

    -Harrow.

  • AdT (unregistered) in reply to real_aardvark
    real_aardvark:
    In what way is this reflection? It's just run-time type identification as far as I can see. If this be reflection, then C++ "does" reflection via dynamic_cast<> and/or typeid.

    "So if a record is deleted from any view, data about this deletion is passed to an object invoked via reflection."

    It's BeforeDelete that gets called via reflection. The post doesn't say that BeforeDelete uses reflection itself.

    real_aardvark:
    Is this a case of Microsoft misappropriating a perfectly legitimate and widely used term, as per usual, or is it a case of various posters getting thoroughly confused, as per usual?

    Neither... unless by "various posters" you mean a set including yourself. :)

  • AdT (unregistered) in reply to CoderHero
    CoderHero:
    yes, c++ allows you to convert an int to bool without a cast. And granted, it will work until the day that (value % std::numeric_limits<bool>::max == 0). When that happens you scratch your head and try to understand why the computer isn't working correctly.

    I'm not sure what you wanted to say, but what you did say (read: write) makes no sense. Converting a number to bool does not involve truncation but a test for non-zeroness (<- is that a real noun??). Even if it was a truncating conversion, it would be something more like std::numeric_limits<bool>::max() + 1. Note the function call parentheses as well, kludgy as they might be they are required here.

  • AdT (unregistered) in reply to snoofle
    snoofle:
    picker du nit:
    My point was: is there a scenario in which wq wouldn't work, but wq! would?
    If a file is read only, :wq will fail and vi will not exit, whereas :wq! will exit anyway (even though the file isn't saved). It's really two commands, and the ! modifies the q from quit-if-write-succeeds to quit-regardless.

    Nope. That would all be very logical, but vi (vim at least) is not that logical. The exclamation mark in :wq! instructs vim to force the write, not the quit. The quit is thus also more likely to succeed, but this is merely a side effect. So :wq! is actually like :w!, followed by :q on success.

    :w!q would be a more logical mnemonic for this command - but to vim, this one actually means "force write to a file named q"...

  • immibis (unregistered) in reply to Tobias
    Tobias:
    Trigger...interface...reflection....guh?

    Are these special Microsoft things, or do I just not know how to program after all?

    Behold: (linebreaks added for clarity)

    IGunInterface g; // interface
    g = Class.forName("org.illegalfirearms.ShotGun")
    .newInstance(); // reflection
    g.aim("<package name=\"org.illegalfirearms\">
    <object type=\"ShotGun\" variableType=\"IGunInterface\">
    <functionCall type=\"aim\"><parameters type=\"none\" 
    /></functionCall></object></package>"); // mandatory xml
    g.pullTrigger(); // trigger
    
  • Gazzonyx (unregistered) in reply to protected static

    IIRC (I'm an intern that maintains the worlds biggest WTF VBA database), if you don't do that, you'll get a "No current record" error the second you try to dereference the var.

    And, due to the semantics of VBA/VB6 (they're actually the same, only one is more gimped), you have to dereference to check null, unless it's a number variant which will say not null even if it is, but you have to know which it is before you can check either way. Or something like that. I remember that some variants which have no value will pass the isnull() and freak out about whatever VB's equivalent to dereferencing a null pointer if you check for isnumber() after the isnull(). Ugh, VBA. Shoot me. What I wouldn't give to be allowed to either have pointer level access, or a full blown, garbage collected, object oriented language. VB[A | 6] is the worst of both worlds.

    Luckily, they didn't bother to actually document DAO before killing it. Well, they did some documentation, but a good portion of it is outright incorrect. Moving to ADO, which is prototyped nearly the same, but the order of formal arguments are in a different order. So close to compatible that it tempts you to do a Find/Replace on a 250K SLOC beast.

  • Gazzonyx (unregistered) in reply to protected static
    protected static:
    3. Getting the active row and then immediately setting the active row to that row. WTF?
    I suspect that the coder in question used to write VB6 or VBA code... Wasn't there a quirk with DAO that required you to MoveFirst -> MoveLast -> MoveFirst in order to really get the first row because the recordset wasn't fully populated until you'd traversed it? If you just invoked MoveFirst, you'd get an empty record.
    IIRC (I'm an intern that maintains the worlds biggest WTF VBA database), if you don't do that, you'll get a "No current record" error the second you try to dereference the var.

    And, due to the semantics of VBA/VB6 (they're actually the same, only one is more gimped), you have to dereference to check null, unless it's a number variant which will say not null even if it is, but you have to know which it is before you can check either way. Or something like that. I remember that some variants which have no value will pass the isnull() and freak out about whatever VB's equivalent to dereferencing a null pointer if you check for isnumber() after the isnull(). Ugh, VBA. Shoot me. What I wouldn't give to be allowed to either have pointer level access, or a full blown, garbage collected, object oriented language. VB[A | 6] is the worst of both worlds.

    Luckily, they didn't bother to actually document DAO before killing it. Well, they did some documentation, but a good portion of it is outright incorrect. Moving to ADO, which is prototyped nearly the same, but the order of formal arguments are in a different order. So close to compatible that it tempts you to do a Find/Replace on a 250K SLOC beast.

  • Edward Royce (unregistered) in reply to Gazzonyx
    Gazzonyx:
    Luckily, they didn't bother to actually document DAO before killing it. Well, they did some documentation, but a good portion of it is outright incorrect. Moving to ADO, which is prototyped nearly the same, but the order of formal arguments are in a different order. So close to compatible that it tempts you to do a Find/Replace on a 250K SLOC beast.

    I want to know why the hell Microsoft does this so often!?

    They create a replacement that is almost, but not quite, a replacement.

    It's like they employ someone whose job is to screw with people.

  • Edward Royce (unregistered) in reply to Harrow
    Harrow:
    Edward Royce:
    Perhaps I'm a bit behind the curve here but isn't the process of an application actively modifying code during execution a serious liability in debugging?
    Not only for debugging, but it's also a serious security liability. No trusted program should have the authority to modify its behavior without constraint, based on data recieved from outside its trust boundary. That's why you are hearing about "implementing security by monitoring the call stack programmatically" -- this is a Rube-Goldberg attempt to heal a fundamentally broken security model.

    Every application must execute a subset of its repretoire for each input it encounters, but if the input data is not trusted, then the repretoire must be. Otherwise you have written an obscure, opaque, untested interpreter.

    -Harrow.

    And seemingly the forerunner of SkyNet.

    This is almost as crazy as storing individual customer data on individual Excel spreadsheets. All 3+ million of them.

    • Ameritech Cellular

    I was a contractor there. Browsed the network. Saw a gazillion servers named "Excel001" - "Excelxxx". Thought "WTF?". Logged onto one of them by random. Took 1 hour or so for the directory listing to show up.

    But it's a close, close, second.

    ...

    Well on second thought I guess it would be useful if you developed a framework or skeleton and then plugged in components. But it would only be at design time. For an application to do so at runtime and possibly without specific user direction seems iffy.

  • (cs) in reply to Anonymous Coward
    Anonymous Coward:
    To be fair, I've never even heard of the SecurityManager. I'm a second-year CS student with only a few years of experience, so this isn't exactly unexpected.
    That's OK. You've heard of it now, and it's time you started paying attention to security matters, just as you should also pay attention to data structures and algorithms.
    Anonymous Coward:
    As the thing was a throw-away toy, I didn't bother making it secure / pleasant to use / capable of handling malformed files, etc. It was a proof-of-concept that showed I could load pretty well any noncyclical structure in about 100 lines of code.
    One of the key tenets of practical security in computing is Define Goodness. In this case, you'd be thinking in terms of defining which things you were expecting to parse and run, and rejecting everything else. (The reverse of defining goodness is defining badness, but that's doomed because all it takes is for some clever swine to come up with a new sort of badness and you're stuck. Anti-virus software is based on defining badness…)
  • (cs) in reply to Ragnax
    Ragnax:
    Welbog:
    The function itself is invoked using reflection, from whatever view is dealing with the record in question.

    It works like this: View has a record it wants to delete. View checks database for "actions" to invoke on the record before it's deleted If there are "actions", view uses reflection to instance objects based on name View casts these objects to the appropriate interface View calls the BeforeDelete method on the reflection object

    I can't be the only one thinking that some simple, custom typed event handlers would have been a more adequate solution than breaking out reflection to dynamically instantiate classes and casting those to interfaces to actually work with them.

    Reinventing the square wheel?

    This actually sounds a lot like other projects that use reflection successfully. Struts is the first that comes to mind. This app uses a database instead of xml and uses it for dynamic rather than fixed configurations but it looks similar to me.

    Am I missing something?

  • (cs) in reply to AdT
    AdT:
    real_aardvark:
    In what way is this reflection? It's just run-time type identification as far as I can see. If this be reflection, then C++ "does" reflection via dynamic_cast<> and/or typeid.

    "So if a record is deleted from any view, data about this deletion is passed to an object invoked via reflection."

    It's BeforeDelete that gets called via reflection. The post doesn't say that BeforeDelete uses reflection itself.

    real_aardvark:
    Is this a case of Microsoft misappropriating a perfectly legitimate and widely used term, as per usual, or is it a case of various posters getting thoroughly confused, as per usual?

    Neither... unless by "various posters" you mean a set including yourself. :)

    Gee, thanks for snipping the last two words of my post, where I implied precisely this. :(
  • ChiefCrazyTalk (unregistered)

    The real WTF is using VB instead of C#.

  • (cs) in reply to Edward Royce
    Edward Royce:
    SenTree:
    JimM:
    The only logical conclusion is that ALL COMPUTERS are evil and we should burn them immediately...
    But computers are the creation of PEOPLE, therefore ALL PEOPLE ARE EVIL and we should - oh, work it out for yourselves.

    Drink plenty of beer?

    Give me a hint man, I'm drowning here.

    Hint is: Don't drink too much beer. Instead, do nothing.

  • (cs) in reply to real_aardvark
    real_aardvark:
    Edward Royce:
    Perhaps I'm a bit behind the curve here but isn't the process of an application actively modifying code during execution a serious liability in debugging?

    Jeez. And I thought the angst over excessive pointer manipulation in C applications was a pain.

    Well, that's a huge topic of discussion, and you're already ahead of the curve on it.

    I used to try self-modifying code in Z80 -- bad idea, although the three bits that affected the rotation instruction were just about manageable.

    For self-modifying code a la reflection, properly implemented, well ... I think it depends upon the scope.

    What I think is a theoretically good model would be some construct that takes an object (or, I suppose, even a class, or for that matter a closed function) and does the necessary transforms for whatever reason appears to be useful within the current scope. And then discards the modifications.

    Yes, dynamic code is insanely hard to debug--the debugger has nothing to look at, and so you can't see what's going through your program's head. I've only used dynamically generated code within .net, and that was for a script interpreter. It's particularly bad when you try to invoke the method and it throws an InvalidProgramException, you have no way of inspecting the code at all. At least when it's a "valid" program .net can save it and I can use a decompiler to read it; invalid code would throw the decompiler for a loop.

    But in the end, sometimes (like when writing a script interpreter) there is no way to do what you want without using dynamic code. In my case, it was because C# doesn't allow me to pass addresses into Method.Invoke, and I had to do special handling for events emitted from my scripts that had to be done via CIL. But if there's another way, you should really consider using it.

  • david (unregistered)

    Dunno: looks to me as if ActiveRowIndex = ActiveRowIndex will throw an exception for invalid ActiveRowIndex, which you will get when the ActiveRowIndex is not valid, for example after deleting a row.

    And the "throw" only happens when there is a different kind of exception (record not found).

    Apart from that it's a function prototype for you to fix up if you need to add permissions to rows: at present it always returns true.

  • ch. (unregistered)

    TRWTF is that "classes are called". Usually methods are called on instances of the classes (objects) or at worst static methods of some classes are called, but called classes? WTF!

  • FIA (unregistered) in reply to Tobias
    Tobias:
    Trigger...interface...reflection....guh?

    Are these special Microsoft things, or do I just not know how to program after all?

    Trigger - It's the bit you pull on the gun Interface - It's where you point the gun Reflection - It's what you did to this code to decide to make you point the gun interface.

  • (cs) in reply to Joon
    Joon:
    Normally ... a pure reflection driven app is one of the things that could happen when you put 10 geeks in a room with no experienced leader, and they say to each other: "Hey, wouldn't it be cool if we..." (Insert newest shiny stone idea here)

    I spoke to someone recently that called this the Magpie approach to software development, and thought that was a brilliant metaphor.

    Please tell whoever thought up "Magpie paradigm" that they are quite, quite brilliant (it's a beautifully succinct and descriptive terminology).

    JD:
    GregP:
    JD:
    No one is pointing out the "If RecordFound = False Then" which is what a friend of mine uses to call "boolean panic".
    As WTF'y as that looks - it's an equality check in VB
    You mean it couldn't be written as "If Not/! RecordFound Then"??? Ifs in VB do not evaluate a boolean but a comparission??
    And another case of (GregP) missing the point - the point is not = being overloaded to asignment and comparison(because obviously "a equals b" being an assignment and "a equals equals b" being a comparison is much more logical?) but using an equality comparison on a boolean: it's just as much a wtf as "if(recordfound == false)" which I saw from so many beginning programmers during my MSc...

    JD: yes, you can just write "If Not RecordFound Then". On the other hand, as you can compare two values with just one equals sign, you can also ask a question with just one question mark...

    Addendum (2008-07-07 07:12): p.s should also say that I love the idea of a "boolean panic" "Magpie Paradigm" and "boolean panic", two top phrases brought to you by friends of people who comment on TDWTF. We should be honoured ;^)

  • Egelke (unregistered)

    Isn't the biggest WTF the "not invented here"-syndrome? Why do people find it more fun to do it there own way instaid of using something that is available. In this case "data binding".

  • Fox (unregistered)

    Thanks for explaining the WTFs - it helps for the aspiring WTF'ers :)

  • Me (unregistered) in reply to Pierre Tramo
    Pierre Tramo:
    picker du nit:
    real_aardvark:
    It's simply fixed. Go into vi and type 20dd:wq!
    Why the exclamation mark?
    :wq! -> (try to) _w_rite and _q_uit even if file is not saved _!_
    Is that what that means... I always thought it was _w_rite and _q_uit, DAMN IT_!_
  • Joel Coehoorn (unregistered)

    A couple more WTFs in that code:

    • It doesn't return a value on all code paths. If this isn't a SpecificController, it returns... what? (false is the correct answer, but it should be explicit)
    • "If RecordFound = False"? How 'bout "If Not RecordFound" or even reversing the order of the condition and just "If RecordFound"

    As a side note, 95% of the time I put the positive condition first in an if/else block. However, there is the occasional case where the false condition is only one or two lines and the true condition is 15 or 20. In that case, I'll go ahead and reverse it, because I think it makes the code more readable.

  • (cs) in reply to Joel Coehoorn
    Joel Coehoorn:
    A couple more WTFs in that code: ... * "If RecordFound = False"? How 'bout "If Not RecordFound" ...
    Good thing you spotted that - we'd all missed it!

    Oh, no, we hadn't had we (see the conversation about 5 comments up, then slap yourself in the forehead...)

  • (cs) in reply to Me
    Me:
    Pierre Tramo:
    picker du nit:
    real_aardvark:
    It's simply fixed. Go into vi and type 20dd:wq!
    Why the exclamation mark?
    :wq! -> (try to) _w_rite and _q_uit even if file is not saved _!_
    Is that what that means... I always thought it was _w_rite and _q_uit, DAMN IT_!_
    hm... wouldn't it be easier to use ZZ or :x! instead? ;)
  • Mr. Eff (unregistered) in reply to Jax

    This is as innocuous as it gets with reflection. It's simply looking at the object to determine if it implements a given interface, no worse than querying IUnknown. This is exactly the kind of stuff it was meant for 90% of the time.

  • Mikeh (unregistered)

    I'm late, but I can't believe no one missed that GUIDs are being stored in strings here, I mean come on.

  • Mikeh (unregistered) in reply to Mikeh
    Mikeh:
    I'm late, but I can't believe no one missed that GUIDs are being stored in strings here, I mean come on.
    that no one *caught* -- ahem.
  • Long (unregistered) in reply to picker du nit
    picker du nit:
    My point was: is there a scenario in which wq wouldn't work, but wq! would?

    echo aaa > aaa.txt chmod 444 aaa.txt vi aaa.txt :dd :wq :wq!

  • JD (unregistered) in reply to JimM
    JimM:
    JD: yes, you can just write "If Not RecordFound Then". On the other hand, as you can compare two values with just one equals sign, you can also ask a question with just one question mark...

    Addendum (2008-07-07 07:12): p.s should also say that I love the idea of a "boolean panic" "Magpie Paradigm" and "boolean panic", two top phrases brought to you by friends of people who comment on TDWTF. We should be honoured ;^)

    Hahaha... Sorry about the multiple marks... is kind of a local costume. (As for using a sigle equals sign for comparision, I have nothing against it.)

  • fanha (unregistered) in reply to danixdefcon5

    +1

  • Ivan (unregistered) in reply to Bill

    This. Option Strict being Off is the WTF.

  • (cs)

    I actually like the DataF-a-c-a-d-e. Super

    http://thedailywtf.com/Articles/Are-You-Cool,-Man-and-More.aspx

  • Thats just crazy talk (unregistered) in reply to ChiefCrazyTalk
    ChiefCrazyTalk:
    The real WTF is using VB instead of C#.

    Yep, because they're completely different.

    Oh, wait...

  • Mikeh (unregistered) in reply to Thats just crazy talk
    Thats just crazy talk:
    ChiefCrazyTalk:
    The real WTF is using VB instead of C#.

    Yep, because they're completely different.

    Oh, wait...

    Too bad it doesn't work, just try this simple ass code:

    Module Module1

    Sub Main()
        Console.WriteLine(HelloWorld("Mikey"))
    End Sub
    
    Public ReadOnly Property HelloWorld(ByVal input As String) As String
        Get
            Return "Hello " & input
        End Get
    End Property
    

    End Module

  • Mikeh (unregistered) in reply to Mikeh
    Mikeh:
    Thats just crazy talk:
    ChiefCrazyTalk:
    The real WTF is using VB instead of C#.

    Yep, because they're completely different.

    Oh, wait...

    Too bad it doesn't work, just try this simple ass code:

    Module Module1

    Sub Main()
        Console.WriteLine(HelloWorld("Mikey"))
    End Sub
    
    Public ReadOnly Property HelloWorld(ByVal input As String) As String
        Get
            Return "Hello " & input
        End Get
    End Property
    

    End Module

    and this one from c# to VB is even better!

    class myType { public int x, y, z; public mySubType s; }

    class mySubType
    {
        public int x, y, z;
    }
    
    
    class Program
    {
        static void Main(string[] args)
        {
            myType m =
                new myType()
                {
                    x = 42,
                    y = 13,
                    z = 12,
                    s = new mySubType()
                    {
                        x = 42, y = 91, z = 5
                    }
                };
        }
    }
    
  • Mikeh (unregistered) in reply to Mikeh
    Mikeh:
    Thats just crazy talk:
    ChiefCrazyTalk:
    The real WTF is using VB instead of C#.

    Yep, because they're completely different.

    Oh, wait...

    Too bad it doesn't work, just try this simple ass code:

    Module Module1

    Sub Main()
        Console.WriteLine(HelloWorld("Mikey"))
    End Sub
    
    Public ReadOnly Property HelloWorld(ByVal input As String) As String
        Get
            Return "Hello " & input
        End Get
    End Property
    

    End Module

    and this one from c# to VB is even better!

    class myType { public int x, y, z; public mySubType s; }

    class mySubType
    {
        public int x, y, z;
    }
    
    
    class Program
    {
        static void Main(string[] args)
        {
            myType m =
                new myType()
                {
                    x = 42,
                    y = 13,
                    z = 12,
                    s = new mySubType()
                    {
                        x = 42, y = 91, z = 5
                    }
                };
        }
    }
    
  • stt (unregistered) in reply to JimM
    JimM:
    JD: yes, you can just write "If Not RecordFound Then". On the other hand, as you can compare two values with just one equals sign, you can also ask a question with just one question mark...
    Sorry to beat a dead horse here, someone pointed this out as WTF and then the discussion went into syntax, I can't be satisfied until it's made clear it's not just more verbose way to write the same thing.. not that it'd matter in computing resources of even the oldest computers or anything, just being pedant, and bored.

    Although compiler/interpreter might optimize it away, comparing a boolean to a static value and then testing the result (another boolean) does a few instructions more than just testing the boolean that you already had.

    ...in retrospect that was pretty useless, guess I'll go back to organizing the sock drawer.

Leave a comment on “Completely missing the point...”

Log In or post as a guest

Replying to comment #:

« Return to Article