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. Why you shouldn't inherit someone else's code...

Why you shouldn't inherit someone else's code...

Scheduled Pinned Locked Moved The Lounge
csharpjavascriptlinqcomsysadmin
45 Posts 19 Posters 52 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.
  • Sander RosselS Sander Rossel

    It's named after the color of a steaming pile of... X| (Probably not, but I like to think so and it's often true)

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

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

    Any farmer will call that a fertile field :rolleyes: Our carrots were fertilized with cow-dung. We ate them without washing them. George Carlin - Germs, Immune System - YouTube[^] "You gonna get sick, you gonna die, and you gonna deserve it, because you fakking weak and you got a fakking weak immune-system". "The polio never had a prayer; we were tempered in raw shit"

    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
    • Sander RosselS Sander Rossel

      However, notice that the SMTP call is NOT in the loop ;) It's just a single email, unless it's called from within a loop (which happens at least once, but at least three times it's just a single email). So... I guess it may be what you're saying, but handled very poorly? :laugh:

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

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

      or this is a method called from within another loop [that is preparing the messages]?

      1 Reply Last reply
      0
      • Sander RosselS Sander Rossel

        I just spent over an hour fixing some custom DateTime TextBox that only worked if the system clock was in a specific Dutch format (both CurrentCulture and CurrentUICulture had to match) X| I'm sure it all works at the customer (for now), but as a developer I prefer having my OS in English because it's more Googleable. And I REALLY don't know what to make of this :~

        smtp.Send(mail)
        For n = 1 To 10
        Thread.Sleep(500)
        Application.DoEvents()
        Next

        I wanted to apply the boy scout rule, but that's a full time job X| There's new work (and a new customer) in it for me though. Probably a new web or mobile application hosted in Azure :D

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

        V Offline
        V Offline
        V 0
        wrote on last edited by
        #31

        it's VB? :doh:

        V.

        1 Reply Last reply
        0
        • Sander RosselS Sander Rossel

          I just spent over an hour fixing some custom DateTime TextBox that only worked if the system clock was in a specific Dutch format (both CurrentCulture and CurrentUICulture had to match) X| I'm sure it all works at the customer (for now), but as a developer I prefer having my OS in English because it's more Googleable. And I REALLY don't know what to make of this :~

          smtp.Send(mail)
          For n = 1 To 10
          Thread.Sleep(500)
          Application.DoEvents()
          Next

          I wanted to apply the boy scout rule, but that's a full time job X| There's new work (and a new customer) in it for me though. Probably a new web or mobile application hosted in Azure :D

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

          A Offline
          A Offline
          Abbas A Ali
          wrote on last edited by
          #32

          Sander Rossel wrote:

          I REALLY don't know what to make of this

          Why don't you remove the lines and push the app. That way when something crashes or misbehaves in the wild you'd know the first place to look. :laugh: ;P

          1 Reply Last reply
          0
          • Sander RosselS Sander Rossel

            I know what DoEvents does, but why would you need it in the first place? X| And in a loop? With a Thread.Sleep? I should add that the class in which it is used is not even a Form.

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

            M Offline
            M Offline
            Member 9167057
            wrote on last edited by
            #33

            My bet is that the SMTP method runs asynchronously and they wanted to make sure it goes through before the code goes on. Could be worse, I've inherited a code base that crashes when compiled in release build, works only in debug build. Thankfully, I am rid of it now.

            D 1 Reply Last reply
            0
            • Sander RosselS Sander Rossel

              I just spent over an hour fixing some custom DateTime TextBox that only worked if the system clock was in a specific Dutch format (both CurrentCulture and CurrentUICulture had to match) X| I'm sure it all works at the customer (for now), but as a developer I prefer having my OS in English because it's more Googleable. And I REALLY don't know what to make of this :~

              smtp.Send(mail)
              For n = 1 To 10
              Thread.Sleep(500)
              Application.DoEvents()
              Next

              I wanted to apply the boy scout rule, but that's a full time job X| There's new work (and a new customer) in it for me though. Probably a new web or mobile application hosted in Azure :D

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

              D Offline
              D Offline
              Davyd McColl
              wrote on last edited by
              #34

              that code block was a common trick from VB6 days -- there's code under a button somewhere and that has to run for some time, but async code is hard, so we just "block" logical progression by waiting for completion (in this case, 5 seconds), but we have to `Application.DoEvents()` now and then or the app becomes unresponsive. It's not an ideal situation -- `Thread.Sleep()` could rather be replaced by something like `Test if mail sent`, but that's why it's there.

              1 Reply Last reply
              0
              • Sander RosselS Sander Rossel

                I just spent over an hour fixing some custom DateTime TextBox that only worked if the system clock was in a specific Dutch format (both CurrentCulture and CurrentUICulture had to match) X| I'm sure it all works at the customer (for now), but as a developer I prefer having my OS in English because it's more Googleable. And I REALLY don't know what to make of this :~

                smtp.Send(mail)
                For n = 1 To 10
                Thread.Sleep(500)
                Application.DoEvents()
                Next

                I wanted to apply the boy scout rule, but that's a full time job X| There's new work (and a new customer) in it for me though. Probably a new web or mobile application hosted in Azure :D

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

                G Offline
                G Offline
                glennPattonWork3
                wrote on last edited by
                #35

                Ummm, Thread.Sleep() holds the UI & Application.DoEvents releases the UI ? (I have used it to update the Form while waiting for some stuff to happen) most of the time unless you are very luck if DoEvents gets through a code review!..

                1 Reply Last reply
                0
                • M Member 9167057

                  My bet is that the SMTP method runs asynchronously and they wanted to make sure it goes through before the code goes on. Could be worse, I've inherited a code base that crashes when compiled in release build, works only in debug build. Thankfully, I am rid of it now.

                  D Offline
                  D Offline
                  Daniel Wilianto
                  wrote on last edited by
                  #36

                  Then he should put that send mail call in an async method and prevent user from sending another mail or closing the program before it's done.

                  M O 2 Replies Last reply
                  0
                  • D Daniel Wilianto

                    Then he should put that send mail call in an async method and prevent user from sending another mail or closing the program before it's done.

                    M Offline
                    M Offline
                    Member 9167057
                    wrote on last edited by
                    #37

                    I suppose that's kinda the point of the loop in the first place: To prevent the user from doing anything else in the meantime.

                    D 1 Reply Last reply
                    0
                    • Sander RosselS Sander Rossel

                      I just spent over an hour fixing some custom DateTime TextBox that only worked if the system clock was in a specific Dutch format (both CurrentCulture and CurrentUICulture had to match) X| I'm sure it all works at the customer (for now), but as a developer I prefer having my OS in English because it's more Googleable. And I REALLY don't know what to make of this :~

                      smtp.Send(mail)
                      For n = 1 To 10
                      Thread.Sleep(500)
                      Application.DoEvents()
                      Next

                      I wanted to apply the boy scout rule, but that's a full time job X| There's new work (and a new customer) in it for me though. Probably a new web or mobile application hosted in Azure :D

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

                      G Offline
                      G Offline
                      Gary Wheeler
                      wrote on last edited by
                      #38

                      Sander Rossel wrote:

                      I just spent over an hour fixing some custom DateTime TextBox that only worked if the system clock was in a specific Dutch format (both CurrentCulture and CurrentUICulture had to match)

                      Yet another reason why we UI developers get the big money :rolleyes:.

                      Sander Rossel wrote:

                      I prefer having my OS in English because it's more Googleable

                      My employer insists on providing our UI's in English, French, Italian, German, Spanish, Japanese, Chinese Simplified, and occasionally Polish and Russian. Despite that, we find most of our customers running the UI in English. I think you've helped me figure out why.

                      Software Zen: delete this;

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        Quote:

                        And I REALLY don't know what to make of this

                        Simple: it's a chunk of code which says "I have absolutely no idea what the :elephant: I'm doing".

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

                        A Offline
                        A Offline
                        agolddog
                        wrote on last edited by
                        #39

                        Did somebody also comment out code, then leave it to be checked into the repository? That's a sure sign too. yes, I deal with that on a daily basis. Them: "What if we ever change the repository? Then we lose all that history!" Me: "Who ******* cares? The application should support the business rules at this point in time. If those ever change, we need to understand how to make the application work differently, and write that code. Having this clutter around just makes the code less readable."

                        C 1 Reply Last reply
                        0
                        • D Daniel Wilianto

                          Then he should put that send mail call in an async method and prevent user from sending another mail or closing the program before it's done.

                          O Offline
                          O Offline
                          obermd
                          wrote on last edited by
                          #40

                          That smtp call followed by the loop stinks of a VB6 port. I had to write garbage like this in VB6.

                          1 Reply Last reply
                          0
                          • L Lost User

                            It could be worse in case of c++... I faced the situation when inherited from a class which implement a method "Sleep". For a lazy implementation while inheriting from that class I called Sleep in the assumption I'm calling the W32 Sleep. But instead of, it ended in something like this:

                            for (i = 0; i < 5; i++)
                            {
                            ProcessMessages();
                            ::Sleep(0.2 * cnMilliseconds);
                            ProcessMessages();
                            }

                            I could kill that beast X|

                            It does not solve my Problem, but it answers my question

                            K Offline
                            K Offline
                            Kelly Herald
                            wrote on last edited by
                            #41

                            I've come across C++ code where you would see several sleeps in a row just to "resolve" a timing issue.

                            sleep(0);
                            sleep(0);
                            sleep(0);
                            sleep(0);
                            sleep(0);

                            Of course after the code was properly debugged I was able to eliminate all of the sleep(0) lines.

                            Kelly Herald Software Developer

                            1 Reply Last reply
                            0
                            • A agolddog

                              Did somebody also comment out code, then leave it to be checked into the repository? That's a sure sign too. yes, I deal with that on a daily basis. Them: "What if we ever change the repository? Then we lose all that history!" Me: "Who ******* cares? The application should support the business rules at this point in time. If those ever change, we need to understand how to make the application work differently, and write that code. Having this clutter around just makes the code less readable."

                              C Offline
                              C Offline
                              charlieg
                              wrote on last edited by
                              #42

                              happy to hear it's not just me. I'm okay with commenting out code and forgetting about it - we all do it from time to time. HOWEVER, having multiple levels of commented out code so that you can see the history (yet we're using svn...), yeah, that's either stupid or a bad habit.

                              Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                              1 Reply Last reply
                              0
                              • Greg UtasG Greg Utas

                                A brilliant idea, although the reaction was unsurprising. Having to suffer through this three times was cruel, but applying it to a two-stage project would be fair. If told up front that it would rankle them, it would probably temper the reaction.

                                C Offline
                                C Offline
                                charlieg
                                wrote on last edited by
                                #43

                                I agree - brilliant. I can tell you this - there may have been much disgust during the class, but a few years into working, and they are going to have their "aha!" moment.

                                Charlie Gilley <italic>Stuck in a dysfunctional matrix from which I must escape... "Where liberty dwells, there is my country." B. Franklin, 1783 “They who can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety.” BF, 1759

                                1 Reply Last reply
                                0
                                • M Member 9167057

                                  I suppose that's kinda the point of the loop in the first place: To prevent the user from doing anything else in the meantime.

                                  D Offline
                                  D Offline
                                  Daniel Wilianto
                                  wrote on last edited by
                                  #44

                                  Yes but user should be still allowed to do stuffs such as clicking on menus or continue typing. Using async method gives user smooth experience. While using thread.sleep and window.doevents continuously wont be smooth, I believe.

                                  M 1 Reply Last reply
                                  0
                                  • D Daniel Wilianto

                                    Yes but user should be still allowed to do stuffs such as clicking on menus or continue typing. Using async method gives user smooth experience. While using thread.sleep and window.doevents continuously wont be smooth, I believe.

                                    M Offline
                                    M Offline
                                    Member 9167057
                                    wrote on last edited by
                                    #45

                                    For starters, I don't mean to defend the code. It's a clear code smell and should be restructured to be asynchronous proper. That said, it can be smooth depending on the interaction rate. No process in computing ever is smooth in reality, it's just granular on a fine-enough scale to make us, slow-reacting meatbags, think, it's smooth. In gaming, 60 FPS are, as a rule of thumb, pretty enough to make things feel smooth so if the application processes messages 60 times per second, that would feel smooth despite doing busy-wait-nonsense.

                                    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