|
piratepilates posted:Mid is how you get a substring in a string given beginning and end indices in VB6. That's now burned in my brain.
|
# ? Aug 31, 2015 07:25 |
|
|
# ? May 27, 2024 01:33 |
|
piratepilates posted:Mid is how you get a substring in a string given beginning and end indices in VB6. That's now burned in my brain. It's still in VBNet (can use it from other languages by importing Microsoft.VisualBasic) and it's the best thing. Unlike Substring() it doesn't freak out and throw if the string is too short, it just returns whatever part of the string fell within the given boundaries. For most use cases this will save you a couple of ugly and easily-forgotten calls to Math.Min(). Its only annoyance is that it uses 1-indexing for historical reasons, but it's trivial to make a 0-indexed wrapper (and you can make it an extension method while you're at it).
|
# ? Aug 31, 2015 07:50 |
|
Jabor posted:Getting the median of three values is exactly what the clamp function does Well, gently caress me. I always hated LEFT$/RIGHT$/MID$ and looked enviously at Spectrum Basic's A$ (5 TO 10) / A$ ( TO 5) syntax.
|
# ? Aug 31, 2015 10:27 |
|
Jabor posted:Getting the median of three values is exactly what the clamp function does It can be but isn't always since clamping to an empty range isn't well defined. To again use GLSL as an example, clamp(x, minVal, maxVal) is defined as min(max(x, minVal), maxVal), so clamp(0.0, 1.0, -1.0) will return -1.0.
|
# ? Aug 31, 2015 12:48 |
|
John Big Booty posted:In Grampa Basic, it was MID$. It is in vb6 too, because calling MID (or LEFT or RIGHT) without the $ at the end returns Nothing instead of "" when the substring you selected has no contents. So many bugs can be traced to forgetting the $ that our code review practices require a developer to prove he has a good reason to want Nothing as a possible return value in this instance if he leaves $ off of a string manipulation function.
|
# ? Aug 31, 2015 13:36 |
|
LeftistMuslimObama posted:our code review practices I'm the present tense
|
# ? Aug 31, 2015 14:22 |
|
LeftistMuslimObama posted:It is in vb6 too, because calling MID (or LEFT or RIGHT) without the $ at the end returns Nothing instead of "" when the substring you selected has no contents. So many bugs can be traced to forgetting the $ that our code review practices require a developer to prove he has a good reason to want Nothing as a possible return value in this instance if he leaves $ off of a string manipulation function. Oh poo poo, I always thought it was the other way around. All those poor lovely programs that I made very mildly worse Edit: really speaks as to what a coding horror that place was where not only did that never come up in our lovely code review but that I'm pretty sure I was the only person there that knew the difference, and I apparently still got it wrong. piratepilates fucked around with this message at 14:37 on Aug 31, 2015 |
# ? Aug 31, 2015 14:35 |
|
Soricidus posted:I'm the present tense We're slowly transitioning to a C# web-based front end, but it takes time to do that in a stable manner for a huge enterprise product and we have to maintain and enhance the older front end in the mean time.
|
# ? Aug 31, 2015 16:00 |
|
Sedro posted:Oh boy, that's so convenient! It was probably posted here already but someone made a game of this. What does it say about me that I'm 10/20? Nothing good, right
|
# ? Aug 31, 2015 16:34 |
|
It's ok. I write VB at work now too. It's a terrible language. We are constantly discovering poo poo in it-- subtle bad behaviors, things it allows that lead to runtime errors. The most recent VB fuckery I found was that comparing an Integer? to an Integer with = produced a result of type Boolean?. Combine this with the fact that even Option Strict will permit you to provide a Nullable<T> in a context where a T is required, with no complaints, simply causing a runtime error if your Nullable is null, and you get a for the rest of the week.
|
# ? Aug 31, 2015 16:35 |
|
I've never used Spring, so I only got 5/20 (and one of those only because I had already seen it on a previous screen).
|
# ? Aug 31, 2015 16:37 |
|
fleshweasel posted:It's ok. I write VB at work now too. It's a terrible language. We are constantly discovering poo poo in it-- subtle bad behaviors, things it allows that lead to runtime errors. This seems pretty reasonable to me
|
# ? Aug 31, 2015 18:27 |
|
fleshweasel posted:It's ok. I write VB at work now too. It's a terrible language. We are constantly discovering poo poo in it-- subtle bad behaviors, things it allows that lead to runtime errors. I was with them right up until that last line where VB apparently defeats the entire purpose of Nullable<T>. I don't tell people my first "real" job was doing .NET... as in VB.Net. I just lie and say it was C#. That was before Nullable and I haven't kept up with what VB has been doing. Still happy with that decision.
|
# ? Aug 31, 2015 23:04 |
|
We had someone submit their code exercise in VB6. Two weeks ago.
|
# ? Aug 31, 2015 23:21 |
|
uncurable mlady posted:We had someone submit their code exercise in VB6. Lol. We just have people pseudocode, but the exercises are more akin to Algorithms homework than FizzBuzz type stuff.
|
# ? Sep 1, 2015 00:00 |
|
I was doing a white board programming exercise for a Java position, and the interviewer complained about poo poo like missing @Override annotations. gently caress that guy.
|
# ? Sep 1, 2015 00:28 |
|
GrumpyDoctor posted:This seems pretty reasonable to me It is not reasonable to return a nullable Boolean as the result of an equality comparison of any two values. Either they are equal or they are not. I'm assuming this is what you're referring to. This is especially bad when you can pass that Boolean? on to a context that wants a Boolean and your program will explode if the answer to the question "are these values equal?" is "Nothing! " It's also not reasonable to allow a Nullable<T> to be implicitly unwrapped and provided to a method that consumes a T. C# won't let you do this and VB will. Programmers need to opt in to such unsafe behavior. If you really want an unsafe program then pass in the .Value member to the method. C# vs. VB fiddles: (I screwed up these examples a few times in haste, sorry.) https://dotnetfiddle.net/Mk5tMZ https://dotnetfiddle.net/7ValA0 The C# implementation of equality comparison for nullables, if you're curious: https://github.com/dotnet/coreclr/blob/master/src/mscorlib/src/System/Nullable.cs#L118 There's an implicit conversion from T to Nullable<T> when you compare to a T. The return type is simply a boolean. If both are null, they're equal; if exactly one is null, they're not equal; otherwise, both are present so do the comparison with the unwrapped values. brap fucked around with this message at 01:42 on Sep 1, 2015 |
# ? Sep 1, 2015 01:21 |
|
loinburger posted:I was doing a white board programming exercise for a Java position, and the interviewer complained about poo poo like missing @Override annotations. gently caress that guy. gently caress that guy. Jesus.
|
# ? Sep 1, 2015 04:55 |
|
Winter Stormer posted:gently caress that guy. Jesus. I had one like that who complained about missing ; at the end of pseudocode lines.
|
# ? Sep 1, 2015 08:46 |
|
Your indentation is off by 1/12", this interview is over
|
# ? Sep 1, 2015 09:09 |
|
I believe your whiteboard coding was using [tabs | spaces] and not [spaces | tabs], and thus you are not qualified for my company.
|
# ? Sep 1, 2015 09:26 |
|
Jsor posted:I believe your whiteboard coding was using [tabs | spaces] and not [spaces | tabs], and thus you are not qualified for my company. I'm going to interpret that as concatenation and so a requirement of spaces followed by tabs for indenting and aligning. Then I will scream quietly.
|
# ? Sep 1, 2015 10:32 |
|
I had a teaching assistant that docked me marks on an assignment because the source code, which had to be physically printed out and handed in (and therefore the code was marked visually and never actually run) was not syntax highlighted, due to my poor rear end not owning a colour laser printer. He said having big blocks of comments that are not green makes the code very hard to read. Also I used recursion before we'd covered it in class so I was "making the problem more difficult for yourself to understand and for me to mark". He refused to believe that the code would do what it was supposed to School is a joke and god is dead.
|
# ? Sep 1, 2015 11:21 |
|
From a KD-Tree test:code:
|
# ? Sep 1, 2015 11:57 |
|
Dylan16807 posted:I'm going to interpret that as concatenation and so a requirement of spaces followed by tabs for indenting and aligning. Then I will scream quietly. Python code:
|
# ? Sep 1, 2015 11:59 |
|
fleshweasel posted:It is not reasonable to return a nullable Boolean as the result of an equality comparison of any two values. Either they are equal or they are not. I'm assuming this is what you're referring to. This is especially bad when you can pass that Boolean? on to a context that wants a Boolean and your program will explode if the answer to the question "are these values equal?" is "Nothing! " You are wrong. DotNetFiddle has Option Strict = Off by default. If you turn on Option Strict, Nullable<T> is handled correctly. Both of the runtime errors you pointed out become compile-time errors: https://dotnetfiddle.net/GaJdJ8 quote:Option Strict On disallows implicit conversions from "Boolean?" to "Boolean" If you can implicitly unwrap a Nullable<T> in your work project, then it most likely has Option Strict Off as well - either the project properties were changed, or That One Coworker® snuck an "Option Strict off" statement on you somewhere (because he couldn't be arsed to put a bunch of DirectCast()s in his brilliant List(Of Object)-based procedure). Which would explain why you are "constantly discovering" "terrible things" in VB. NihilCredo fucked around with this message at 20:12 on Sep 1, 2015 |
# ? Sep 1, 2015 20:07 |
Apparently github is bad at plugins https://www.humankode.com/security/how-a-bug-in-visual-studio-2015-exposed-my-source-code-on-github-and-cost-me-6500-in-a-few-hours
|
|
# ? Sep 1, 2015 20:13 |
|
Could there be Boolable or Errorable types instead of Nullable types?
|
# ? Sep 1, 2015 20:13 |
|
little late on the clamp chat but:
|
# ? Sep 1, 2015 20:19 |
|
MALE SHOEGAZE posted:Could there be Boolable or Errorable types instead of Nullable types? Of course. Nullable is just a structure with a couple of useful methods, there's no compiler magic involved beyond the shorthand SomeType?. Remember, Nullable isn't the C#/VB version of Maybe/Option. It does jack poo poo to protect you from NullReferenceException; checking someNullable.HasValue is not any more powerful than checking someObject isnot nothing, in fact it's a little less comfortable because you can't use the various shorthands available (If(), ?. etc.). Its anti-NRE usefulness comes strictly from the fact that it acts as a reminder to do those null checks, and you can have the switch from SomeType? to SomeType as a hint that you hopefully did check for null at least once (but obviously nothing guarantees that the unwrapped value didn't get set to Nothing at a later point, so you will still want to null check anyway). When it comes to actual compiler-enforced features, Nullable's only power is to let you have a boolean/numeric/date variable whose default/unassigned value can be distinguished from a regular False / 0 / 1st Jan 1 A.D. value. Getting back to your question, you could make both of the things you describe, or you could make a more general Eitherable<SomeType><SomeOtherType> with little effort. Just define the appropriate Narrowing CType and Widening CType operators so you can implicitly assign values. But again, you won't gain any more type safety than before, you'll just save on some typing by checking x.IsFirstType instead of comparing x.GetType() = GetType(FirstType). code:
NihilCredo fucked around with this message at 22:14 on Sep 1, 2015 |
# ? Sep 1, 2015 20:48 |
|
NihilCredo posted:You are wrong. DotNetFiddle has Option Strict = Off by default. Something is wrong in our project settings I guess, because I was sure we had Option Strict On. Is it a project-wide setting, or does it need to be applied in each source file? Also possible that some projects in our solution have it on while others don't. Actually, that might be exactly what's wrong. At any rate, unsafety by default is the wrong way to design a language.
|
# ? Sep 1, 2015 21:53 |
|
fleshweasel posted:Something is wrong in our project settings I guess, because I was sure we had Option Strict On. Is it a project-wide setting, or does it need to be applied in each source file? It's a project-wide setting, but you can override it for an individual file by putting Option Strict [on|off] at the top of the file. There is also a setting in the Visual Studio options that sets the default value for new VB projects you create. In any case, as far as awful legacy features VB.Net inherited from VB6, Option Strict and hell even Option Explicit aren't that bad. Since we're in the Coding Horrors thread, everybody go check out the On Error Resume Next statement. Bring vodka. (If you don't fully grasp why OERN is such a horror, or why I have a don't-try-to-find-out-if-I'm-joking rule at work that anybody who puts that in a commit is fired, consider that the following code: code:
NihilCredo fucked around with this message at 22:30 on Sep 1, 2015 |
# ? Sep 1, 2015 22:10 |
|
NihilCredo posted:In any case, as far as awful legacy features VB.Net inherited from VB6, Option Strict and hell even Option Explicit aren't that bad. Since we're in the Coding Horrors thread, everybody go check out the On Error Resume Next statement. Bring vodka. now try vbscript, where it's literally the only way to handle errors. enjoy trying to predict which operations can cause an error and then manually checking the global error object after every single one! or what everyone actually does, which is leaving it to the next guy to figure out why things suddenly start failing silently five years down the line.
|
# ? Sep 1, 2015 23:29 |
|
Soricidus posted:now try vbscript, where it's literally the only way to handle errors. enjoy trying to predict which operations can cause an error and then manually checking the global error object after every single one! or what everyone actually does, which is leaving it to the next guy to figure out why things suddenly start failing silently five years down the line. poo poo, it didn't even have On Error Goto? I thought that one at least was alright, since it's pretty much a primitive try/catch block. Other than the whole "no exception object" thing. fake edit: SO'd it, apparently you're supposed to put dangerous operations into their own OERN-less procedures, which will return immediately on an exception, and you call them from an OERN procedure in which you check the return / global variables immediately after calling one of those dangerous functions. I guess it encouraged proper function splitting at least?
|
# ? Sep 2, 2015 00:12 |
|
OERN is just a slightly weirder version of the standard C error handling scheme of return code + errno.
Plorkyeran fucked around with this message at 01:00 on Sep 2, 2015 |
# ? Sep 2, 2015 00:45 |
|
Plorkyeran posted:OERN is just a slightly weirder version of the standard C error handling scheme of return code + errno. I think you mean the standard C error handling scheme of failing to check return codes and continuing blindly after an operation fails goto fail.
|
# ? Sep 2, 2015 01:06 |
|
ChickenWing posted:Apparently github is bad at plugins The horror is that he committed AWS keys in his source code.
|
# ? Sep 2, 2015 02:14 |
|
I find it pretty funny that someone did $6,500 of SHA256 hashes in a few hours.
|
# ? Sep 2, 2015 03:18 |
|
Blinkz0rz posted:The horror is that he committed AWS keys in his source code. Adding to that, the immediate response by the masses of internet know-it-all programmers was to blame Microsoft. The idiot who committed AWS keys could have omitted VS from the post title, but then people would just call him a loving idiot for committing AWS keys. Because he is.
|
# ? Sep 2, 2015 03:18 |
|
|
# ? May 27, 2024 01:33 |
|
It's a little of column A, little of column B. It's a bad bug that Visual Studio creates a public repository when you check the private checkbox. It also makes no sense to commit API keys in version control.
|
# ? Sep 2, 2015 03:22 |