5

EDIT: Martijn Pieters posted the text of the specific deleted answer that motivated my request (thanks!) However, my general question still stands - should we allow longer-time contributors see their deleted work even if they don't have 10K rep? I think it's relevant to Stack Overflow in particular because it's been around a long time. This is a specific case where middle-rep veteran users like me should get some extra "trust". (Although I am also sympathetic to the more general case as discussed here for example: Introduce a better way to identify trusted users)

--

A guy at work asked me a question in person and I told him "I'll send you a link to something I wrote about that". But when I checked my Stack Overflow profile it was gone - presumably the question was deleted. I think the question was marked as wiki since I can't see any related "reputation" loss in my history. (That also means I can't even find the question name.)

It's not the end of the world but it really bugs me that I spent time writing an answer and now I can't go back and refer to it.

I've read some of the stuff here about this, for example:

Show all of my question/answers to me even if they are deleted

It makes sense that things get deleted, and that it shouldn't be easy to see stuff that was deleted. Having a "reputation" threshold for that also makes some sense.

But I've been contributing to Stack Overflow for ~5 years. I only have ~4K "reputation" because I don't post tons of answers. When I do post it's often a few days after the question was asked, specifically because nobody has given a correct answer yet. More often than not the asker finds my answer useful enough to accept it.

I will never have 10K "reputation", but I think I can be trusted not to whine about lost points or whatever just because I can see deleted stuff. Probably that is true for other people in my situation. Pretty much by definition, long-time users who haven't racked up a big "score" don't care much about said scores.

Should the threshold for a user seeing his or her own deleted work be made a function of how long the user has been contributing to the site?

[To be totally self-serving, why not make it (10K / (1 + count of yearling badges))?]

EDIT: I found a link to my deleted answer, or at least to the question I was answering. (I had left the link in a comment on a different question.) Please note that I'm not complaining about the deletion of the question, although I think it could be reworded into something correct. I just want to see my answer:

https://stackoverflow.com/questions/5488314/using-variant-variables-in-vba-should-it-be-avoided-or-not

  • 1
    So people we don't trust (have low rep score) just have to hang around for long enough to get the privilege? I know it can suck when 10k seems so far off, but rep is the best method we have of measuring site participation. As such, I am opposed to this feature. – Martijn Pieters Apr 26 '14 at 17:49
  • And how certain are you the post was deleted? Can you see the answer still listed in your 'recently deleted answers' list? If so, feel free to post the link here and we can have a peek. – Martijn Pieters Apr 26 '14 at 17:50
  • No, the answer was probably ~2 years old. And I have no idea if the deletion was of question, answer, or user. – jtolle Apr 26 '14 at 17:51
  • The topic was VBA Variant data types and under what situations they should be avoided, so maybe the deletion was for being a subjective question. – jtolle Apr 26 '14 at 17:53
  • It doesn't matter how old the answer was; if it was deleted recently it'll be listed. – Martijn Pieters Apr 26 '14 at 17:58
  • @Martijn, I guess that's what I'm saying - years of contribution plus less than 10K rep should be as "trustworthy" as 10K all by itself. At least for this purpose. After all, most longer-time users are going to have some of their work deleted. – jtolle Apr 26 '14 at 17:58
  • @Martijn, there are no recently deleted answers shown, but given the age of the answer, the deletion probably happened more than a few months ago. – jtolle Apr 26 '14 at 18:01
  • 2
    You should be able to view all your answers, deleted or not, independently of your reputation or the time since your registration. I'm surprised you can't see your own posts, even if they were deleted. – A.L Apr 27 '14 at 2:55
  • @Martijn, I found a link to my deleted answer, or at least the question I was answering. (I had left the link in a comment on a different question.) Please note that I'm not complaining about the deletion of the question, although I think it could be reworded into something correct. I just want to see my answer: stackoverflow.com/questions/5488314/… – jtolle May 3 '14 at 4:25
  • Post undeleted. – mhlester May 3 '14 at 19:34
  • @mhlester, thanks. While I was not specifically asking for that, I approve. I just edited the undeleted question to hopefully make it fit within the guidelines. – jtolle May 3 '14 at 20:20
  • @jtolle, they deleted it again, I cast an undelete vote for it, and have also added it to the Archive. It is definitely not Primarily-Opinion Based, and is a very pertinent question for VBA programmers. – Lance Roberts May 7 '14 at 0:45
  • @Lance, annoying. Obviously I agree with you. This exact deleted answer was only incidental to my request, but having seen it again, it feels like vandalism to just delete it. What's more, I scanned through my old answers, and a lot of them are to questions now marked "closed" for what seems like kind of nitpicky reasons. That's really discouraging, given that I suppose they could all be deleted if the right strongly opinionated people come along. All the more reason to let long-time contributors have some extra trust even if they don't have 10K "reputation". – jtolle May 11 '14 at 18:12
6

You've had an answer and a half there; the question was deleted October 2013 after deletion votes by community members.

Here it is in full, as copied directly from your deleted answer:

As always, we should use the right tool for the job. In VBA, I think variants are quite often the right tool. (But just so it's clear, I too am against the "reckless" use of any language feature.)

First, and in general, "Should we avoid variants?" is just a VBA-specific version of the larger question "Is static typing better than dynamic typing?" If there is ever a programming question where the answer is "it depends", it's that. For example. the authors of this book clearly like static type systems, but even they say:

It's important to recognise that each of these approaches involves tradeoffs. Very briefly put, the [static] perspective emphasises safety, while the dynamically typed outlook favours flexibility. If someone had already discovered one way of thinking about types that was always best, we imagine that everyone would know about it by now.

I think many VBA programs fall into the scripting/prototyping category, and can thus make profitable use of variants. That doesn't mean that only variants should be used, but they certainly shouldn't be avoided "just because". That's cargo-cult programming. (It's not the only cargo-cult you see a lot in VBA. "Every routine needs an error handler" is another. See VBA Error "Bubble Up")

It seems like many VBA resources come down very hard against using variants, and do make blanket statements about how they are best avoided. My own guess is that this is mainly a trickle-down from the previous history of VB. VB, as opposed to VBA, was much more appropriate for the development of large systems where static typing and object-oriented designs get more useful.


To address the more specific question of whether we should avoid variants even when we know the data type we're dealing with, I'd say that the difference between the two approaches in the answers to the linked question, VB - Append to array?, speak for themselves:

arr(i) = Split(arr(i), "=")(1)

vs.

arr(i) = Mid$(arr(i), InStr(arr(i), "=") + 1)

I edited them a bit to clarify the point, but surely the former is more obvious, and thus "better" in the context of what is basically a little file-parsing script. The latter probably performs better, but how often does that matter for this kind of thing? (And if it does matter, why are you doing it in VBA anyway?)

EDIT: Here is another example of a situation in which I think it's cleaner to use variants, even though it's possible to do everything statically. I've simplified it a bit from real code, but hopefully not too much.

Here is a generic, Variant-using function to find the size of an array in the first dimension:

Public Function lenOfArr(arr) As Long
    Debug.Assert IsArray(arr)

    lenOfArr = UBound(arr) - LBound(arr) + 1
End Function

Note the assertion. So we still get a little bit of "type checking", but only for "is array", and we only get it at run time, in debug mode, instead of at compile time. In return for this and a performance hit, though, we get to have a single function in our library of array utilities. It would certainly be possible to define multiple utilities like this:

Public Function lenOfStrArr(arr() As String) As Long
    lenOfStrArr = UBound(arr) - LBound(arr) + 1
End Function

and get more safety and performance. But honestly, it would be a pain, at least in the kind of VBA code (mostly supporting models in Excel) that I write a lot of. And that's the point. Whether or not to use variants, even when you could avoid them, depends on the context of what you're trying to do.

Now here is a non-simplified example from real code:

'Filters a collection of worksheets based on a predicate
Public Function shtsFiltered(shts, predName As String) As Collection
    Const PROC As String = "shtsFiltered"
    Dim dbg As FW_Dbg: Set dbg = mkDbg(MODL_, PROC, shts, predName)

    Call dbg.assert(expIsObj(shts))
    Call dbg.assert(TypeOf shts Is Sheets Or TypeOf shts Is Collection, "Can only filter a collection of Worksheet objects")

    Set shtsFiltered = New Collection

    Dim sht As Worksheet
    For Each sht In shts
        If sheetPredicate(sht, predName) Then
            Call shtsFiltered.Add(sht)
        End If
    Next sht

    Call dbg.exiting(shtsFiltered)
End Function

It's using some other library code, but you don't need to know everything that's going on for this discussion. The purpose of the routine is to take a collection of Worksheet objects and return a collection of the ones that meet some criteria. But because of the way Excel works, it needs to be able to take either an input of type Sheets, or of type Collection. So that requires a parameter of type Variant, even though everything else can be explicitly typed.

As with the case of the array length functions above, it would be possible to define a Sheets version and a Collection version of this routine. But because the routine is non-trivial, that would mean repeating logic (very bad) just to avoid using variants.


Finally, in VBA used with Excel (and I know you're not questioning this but it's worth mentioning for completeness), Variant is practically the native data type. It's almost impossible to write decent Excel VBA UDFs without using it. For example, I do this all the time:

Public Function calcSomething(parm)
    On Error GoTo EH

    If IsError(parm) Then
        calcSomething = parm

        Exit Function
    End If

    'Do calculation...

    calcSomething = 42  'or whatever...

    Exit Function

EH:
    calcSomething = CVErr(xlErrValue)
End Function

That's a trivial example, but it should make the point. There are plenty of more involved examples that make use of variants, such as arrays of arrays:

How can I "ReDim Preserve" a 2D Array in Excel 2007 VBA so that I can add rows, not columns, to the array?

  • 1
    To the downvoter: I invite you to read the comments on the question. What the OP really wanted was to see a specific answer; this is that answer. – Martijn Pieters May 3 '14 at 7:54
  • 2
    Thanks! My feature request still stands because I think it's a good idea and would like to hear what others think. However, this specific instance was my motivation. I appreciate the help. – jtolle May 3 '14 at 14:44
3

As of February 28th, anyone with an answer to a deleted question can view it.

See: View *my* deleted question and answer with less than 10K

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .