Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Suggestion - stackexchange site which requires answers with unit tests?

Suggestion - stackexchange site which requires answers with unit tests?

Scheduled Pinned Locked Moved The Lounge
question
19 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M maze3

    Add requirement to stackoverflow questions or create a separate exchange which requires unit tests included with answers. Why - so it can be learned by a broader group of people.

    N Offline
    N Offline
    NeverJustHere
    wrote on last edited by
    #10

    Would you agree that the following are true or not? 1) a question posed is usually a simplification or genericisation of the true problem been faced. It may exclude constraints such as memory, time, parallelism, bandwidth, precision, reliability, data size, etc, etc which may impact selection of a solution. 2) any answer to such a question is therefor only partially informed. 3) a variety of 'correct' answers can be made to such a question, but only the questioner has the full context to evaluate the pros and cons of each answer, and hence which may be most suitable to the true problem. 4) any unit tests proposed by the answerer are incomplete due to point 1 5) any unit tests proposed by the answerer cannot anticipate the true edge cases Would it also be true that the best questions are those that explicitly identify/exlcude constraints. ( E.g I need to sort 10,000 numbers, and have gigabytes of memeory but need to do it as quickly as possible verses I need to sort 10,000 numbers, but only have 1kb memory available...)

    1 Reply Last reply
    0
    • M maze3

      Add requirement to stackoverflow questions or create a separate exchange which requires unit tests included with answers. Why - so it can be learned by a broader group of people.

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #11

      maze3 wrote:

      Why - so it can be learned by a broader group of people.

      Hahaha, that broad group isn't inhibited now; they're free to learn the subject. So no, I won't accept that as a reason. If I want to add unit-test with my answer on CP, I can do so; simply add a link to the GitHub that contains them. Next, answers should be short and to the point, with examples being as simple as possible - anything that isn't relevant to the question or answer should not be there; imagine a book to learn C# that has unit-tests for its "Hello world". Finally, it will mean very few volunteers there; given the questions here (and there), a unit-test is hardly relevant. Also lot of people who might want to answer, and won't (due to the added requirement). Perhaps you want full XML-documentation too? And did you consider asking for multi-version answers, so that you can download code & unit-test for your exact .NET version? And, if the question involves a database, a complete SQL-script to generate the structure and fill it with test-data? Let's have all that before allowing someone to answer :D

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

      F 1 Reply Last reply
      0
      • P PeejayAdams

        Probably one for Stack Exchange Meta, but if we must discuss it here - take it to The Weird & The Wonderful, it's way too surreal for the Lounge!

        Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain

        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu PeterK Offline
        Kornfeld Eliyahu Peter
        wrote on last edited by
        #12

        Only CCC is too surreal for the Lounge... :-D

        "The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012

        "It never ceases to amaze me that a spacecraft launched in 1977 can be fixed remotely from Earth." ― Brian Cox

        P 1 Reply Last reply
        0
        • Kornfeld Eliyahu PeterK Kornfeld Eliyahu Peter

          Only CCC is too surreal for the Lounge... :-D

          "The only place where Success comes before Work is in the dictionary." Vidal Sassoon, 1928 - 2012

          P Offline
          P Offline
          PeejayAdams
          wrote on last edited by
          #13

          Oh, I don't know - all this talk of missing spoons ...

          Whenever you find yourself on the side of the majority, it is time to pause and reflect. - Mark Twain

          1 Reply Last reply
          0
          • M maze3

            Add requirement to stackoverflow questions or create a separate exchange which requires unit tests included with answers. Why - so it can be learned by a broader group of people.

            Sander RosselS Offline
            Sander RosselS Offline
            Sander Rossel
            wrote on last edited by
            #14

            [TestMethod]
            public void QuestionIsAnsweredCorrectly()
            {
            var question = GetQuestion();
            var answers = question.GetAnswers();
            var isCorrect = answers.Any(a => a.Body.Contains("duplicate") || a.Body.Contains("Google") || a.Author == "Jon Skeet");
            Assert.IsTrue(isCorrect);
            }

            Directly taken from the StackExchange source code :D

            Best, Sander sanderrossel.com Continuous Integration, Delivery, and Deployment arrgh.js - Bringing LINQ to JavaScript Object-Oriented Programming in C# Succinctly

            1 Reply Last reply
            0
            • L Lost User

              maze3 wrote:

              Why - so it can be learned by a broader group of people.

              Hahaha, that broad group isn't inhibited now; they're free to learn the subject. So no, I won't accept that as a reason. If I want to add unit-test with my answer on CP, I can do so; simply add a link to the GitHub that contains them. Next, answers should be short and to the point, with examples being as simple as possible - anything that isn't relevant to the question or answer should not be there; imagine a book to learn C# that has unit-tests for its "Hello world". Finally, it will mean very few volunteers there; given the questions here (and there), a unit-test is hardly relevant. Also lot of people who might want to answer, and won't (due to the added requirement). Perhaps you want full XML-documentation too? And did you consider asking for multi-version answers, so that you can download code & unit-test for your exact .NET version? And, if the question involves a database, a complete SQL-script to generate the structure and fill it with test-data? Let's have all that before allowing someone to answer :D

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

              F Offline
              F Offline
              F ES Sitecore
              wrote on last edited by
              #15

              Maybe the code isn't posted to the thread at all, maybe the person answering should have to physically visit the asker to enter the code directly into their solution and fixed any errors that occur?

              L 1 Reply Last reply
              0
              • F F ES Sitecore

                Maybe the code isn't posted to the thread at all, maybe the person answering should have to physically visit the asker to enter the code directly into their solution and fixed any errors that occur?

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #16

                Exactly, but you worded it a lot better :)

                Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^] "If you just follow the bacon Eddy, wherever it leads you, then you won't have to think about politics." -- Some Bell.

                1 Reply Last reply
                0
                • M maze3

                  Add requirement to stackoverflow questions or create a separate exchange which requires unit tests included with answers. Why - so it can be learned by a broader group of people.

                  D Offline
                  D Offline
                  Dan Neely
                  wrote on last edited by
                  #17

                  When they can't even get the lusers posting irredeemable drek to post an MCVE; isn't just a bridge too far. It's a bridge from here to Jupiter where the people who're failing to ask good questions have all gone to get more stupider.

                  Did you ever see history portrayed as an old man with a wise brow and pulseless heart, weighing all things in the balance of reason? Is not rather the genius of history like an eternal, imploring maiden, full of fire, with a burning heart and flaming soul, humanly warm and humanly beautiful? --Zachris Topelius Training a telescope on one’s own belly button will only reveal lint. You like that? You go right on staring at it. I prefer looking at galaxies. -- Sarah Hoyt

                  1 Reply Last reply
                  0
                  • M maze3

                    Add requirement to stackoverflow questions or create a separate exchange which requires unit tests included with answers. Why - so it can be learned by a broader group of people.

                    J Offline
                    J Offline
                    jesarg
                    wrote on last edited by
                    #18

                    By "unit tests" you probably mean "unit tests, according to test-driven-development standards" (or a TDD variant). Problems with this idea: 1. You can't learn TDD by code snippets and basic intuition; you learn its theory by organized study, and then do lots of exercises to solidify the knowledge. 2. The vast majority of unit tests written in the industry are by people who don't understand TDD basics. The answers with unit tests will be written (and upvoted) by people who don't understand TDD, accomplishing nothing for beginners hoping to gain useful knowledge. 3. TDD is not as widespread or useful to the industry as it appears. People pay lip service to how wonderful it is, clutter their code with useless unit tests not written according to any real standard, and then proceed to ignore all those useless unit tests 99% of the time (except for the 1% of the time where they talk about how wonderful and useful the unit tests are).

                    1 Reply Last reply
                    0
                    • M maze3

                      Add requirement to stackoverflow questions or create a separate exchange which requires unit tests included with answers. Why - so it can be learned by a broader group of people.

                      D Offline
                      D Offline
                      dandy72
                      wrote on last edited by
                      #19

                      Are you making the suggestion to ensure the cut-and-paste "developers" have even less to do on their own?

                      1 Reply Last reply
                      0
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • World
                      • Users
                      • Groups