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. Need a good name for an extension method

Need a good name for an extension method

Scheduled Pinned Locked Moved The Lounge
pythoncomquestionlearning
42 Posts 18 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.
  • J Jochen Arndt

    public static int AddIfNegative(this int a, int delta)
    {
    return delta < 0 ? a + delta : a;
    }

    Richard DeemingR Offline
    Richard DeemingR Offline
    Richard Deeming
    wrote on last edited by
    #19

    That changes the behaviour of the code. ;P

    int x = int.MinValue.MinDelta(-1); // -2147483648
    int y = int.MinValue.AddIfNegative(-1); // 2147483647


    "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

    "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

    J 1 Reply Last reply
    0
    • M Marc Clifton

      A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

      public static int Min(this int a, int max)
      {
      return (a > max) ? max : a;
      }

      But what would be a good name for this (which I've tentatively named "MinDelta":

      public static int MinDelta(this int a, int delta)
      {
      return a > a + delta ? a + delta : a;
      }

      Suggestions? Humor? Marc

      V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

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

      Marc Clifton wrote:

      Suggestions?

      ..on a programming question in the lounge? :rolleyes:

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      1 Reply Last reply
      0
      • M Marc Clifton

        A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

        public static int Min(this int a, int max)
        {
        return (a > max) ? max : a;
        }

        But what would be a good name for this (which I've tentatively named "MinDelta":

        public static int MinDelta(this int a, int delta)
        {
        return a > a + delta ? a + delta : a;
        }

        Suggestions? Humor? Marc

        V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

        Richard DeemingR Offline
        Richard DeemingR Offline
        Richard Deeming
        wrote on last edited by
        #21

        Has nobody suggested Shirley yet? :rolleyes:


        "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

        "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

        1 Reply Last reply
        0
        • M Marc Clifton

          A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

          public static int Min(this int a, int max)
          {
          return (a > max) ? max : a;
          }

          But what would be a good name for this (which I've tentatively named "MinDelta":

          public static int MinDelta(this int a, int delta)
          {
          return a > a + delta ? a + delta : a;
          }

          Suggestions? Humor? Marc

          V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

          B Offline
          B Offline
          Bryian Tan
          wrote on last edited by
          #22

          My ;P

          Bryian Tan

          1 Reply Last reply
          0
          • J Jochen Arndt

            AddLT0 (Add if Less Than Zero) :)

            J Offline
            J Offline
            jeron1
            wrote on last edited by
            #23

            Jochen Arndt wrote:

            AddLT0

            You don't happen to program in assembler do you?

            "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

            J 1 Reply Last reply
            0
            • M Marc Clifton

              A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

              public static int Min(this int a, int max)
              {
              return (a > max) ? max : a;
              }

              But what would be a good name for this (which I've tentatively named "MinDelta":

              public static int MinDelta(this int a, int delta)
              {
              return a > a + delta ? a + delta : a;
              }

              Suggestions? Humor? Marc

              V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

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

              Without any Humor: Minimize

              M 1 Reply Last reply
              0
              • J jeron1

                Jochen Arndt wrote:

                AddLT0

                You don't happen to program in assembler do you?

                "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                J Offline
                J Offline
                Jochen Arndt
                wrote on last edited by
                #25

                I must confess that I was inspired by some assembler commands like the Microchip decfsz (decrement file skip if zero).

                J 1 Reply Last reply
                0
                • Richard DeemingR Richard Deeming

                  That changes the behaviour of the code. ;P

                  int x = int.MinValue.MinDelta(-1); // -2147483648
                  int y = int.MinValue.AddIfNegative(-1); // 2147483647


                  "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                  J Offline
                  J Offline
                  Jochen Arndt
                  wrote on last edited by
                  #26

                  You are off course right.

                  1 Reply Last reply
                  0
                  • J Jochen Arndt

                    I must confess that I was inspired by some assembler commands like the Microchip decfsz (decrement file skip if zero).

                    J Offline
                    J Offline
                    jeron1
                    wrote on last edited by
                    #27

                    I do a good bit of maintenance of assmembler code, and darn near all of the labels are beautifully cryptic like that. Switching back and forth between c++ and assmebler is a joy that way. :rolleyes:

                    "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

                      public static int Min(this int a, int max)
                      {
                      return (a > max) ? max : a;
                      }

                      But what would be a good name for this (which I've tentatively named "MinDelta":

                      public static int MinDelta(this int a, int delta)
                      {
                      return a > a + delta ? a + delta : a;
                      }

                      Suggestions? Humor? Marc

                      V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

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

                      Max - just to confuse everyone :laugh:

                      Ah, I see you have the machine that goes ping. This is my favorite. You see we lease it back from the company we sold it to and that way it comes under the monthly current budget and not the capital account.

                      1 Reply Last reply
                      0
                      • M Marc Clifton

                        A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

                        public static int Min(this int a, int max)
                        {
                        return (a > max) ? max : a;
                        }

                        But what would be a good name for this (which I've tentatively named "MinDelta":

                        public static int MinDelta(this int a, int delta)
                        {
                        return a > a + delta ? a + delta : a;
                        }

                        Suggestions? Humor? Marc

                        V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                        M Offline
                        M Offline
                        Mark_Wallace
                        wrote on last edited by
                        #29

                        MinnieBannister But then you'll have to find a place for a HenryCrun, and maybe an Eccles and a Bluebottle.

                        I wanna be a eunuchs developer! Pass me a bread knife!

                        1 Reply Last reply
                        0
                        • L Lost User

                          Frank. Call it Frank.

                          The language is JavaScript. that of Mordor, which I will not utter here
                          This is Javascript. If you put big wheels and a racing stripe on a golf cart, it's still a fucking golf cart.
                          "I don't know, extraterrestrial?" "You mean like from space?" "No, from Canada." If software development were a circus, we would all be the clowns.

                          M Offline
                          M Offline
                          Mark_Wallace
                          wrote on last edited by
                          #30

                          I'm Frank! No, wait -- I'm Tiger Woods, aren't I? Oh, no, I've got it: I'm Spartacus! ... Brian?

                          I wanna be a eunuchs developer! Pass me a bread knife!

                          1 Reply Last reply
                          0
                          • H HobbyProggy

                            -D***Size -Asians -AlphaBetaGamma -DeltaDelta -MyFunction1 -Method -AGreaterB -Minimi -IHaveNoIdeaHowToNameThisThing just to hand you a couple ideas

                            Rules for the FOSW ![^]

                            if(this.signature != "")
                            {
                            MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
                            }
                            else
                            {
                            MessageBox.Show("404-Signature not found");
                            }

                            M Offline
                            M Offline
                            Mark_Wallace
                            wrote on last edited by
                            #31

                            HobbyProggy wrote:

                            MyFunction1

                            That's gotta be the winner!

                            I wanna be a eunuchs developer! Pass me a bread knife!

                            1 Reply Last reply
                            0
                            • M Mladen Jankovic

                              MinDelta->Fall / MaxDelta->Climb?

                              GeoGame for Windows Phone | The Lounge Explained In 5 Minutes

                              M Offline
                              M Offline
                              Marc Clifton
                              wrote on last edited by
                              #32

                              Mladen Janković wrote:

                              MinDelta->Fall / MaxDelta->Climb?

                              Ooh, I like that! :) Marc

                              V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                              1 Reply Last reply
                              0
                              • L Lost User

                                Without any Humor: Minimize

                                M Offline
                                M Offline
                                Marc Clifton
                                wrote on last edited by
                                #33

                                0x01AA wrote:

                                Minimize

                                Ah, I think we have a winner! Marc

                                V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                L 1 Reply Last reply
                                0
                                • M Marc Clifton

                                  A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

                                  public static int Min(this int a, int max)
                                  {
                                  return (a > max) ? max : a;
                                  }

                                  But what would be a good name for this (which I've tentatively named "MinDelta":

                                  public static int MinDelta(this int a, int delta)
                                  {
                                  return a > a + delta ? a + delta : a;
                                  }

                                  Suggestions? Humor? Marc

                                  V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                  T Offline
                                  T Offline
                                  theoldfool
                                  wrote on last edited by
                                  #34

                                  minifyoufeellikeit

                                  Rules for playing Javascript frameworks. 1. You can't win. 2. You can't break even. 3. You can't get out of the game.

                                  1 Reply Last reply
                                  0
                                  • M Marc Clifton

                                    0x01AA wrote:

                                    Minimize

                                    Ah, I think we have a winner! Marc

                                    V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

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

                                    :-O Bruno

                                    1 Reply Last reply
                                    0
                                    • M Marc Clifton

                                      A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

                                      public static int Min(this int a, int max)
                                      {
                                      return (a > max) ? max : a;
                                      }

                                      But what would be a good name for this (which I've tentatively named "MinDelta":

                                      public static int MinDelta(this int a, int delta)
                                      {
                                      return a > a + delta ? a + delta : a;
                                      }

                                      Suggestions? Humor? Marc

                                      V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                      T Offline
                                      T Offline
                                      TheGreatAndPowerfulOz
                                      wrote on last edited by
                                      #36

                                      Add Inc or Increment

                                      #SupportHeForShe Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun

                                      1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        A basic extension method to implement min (yes, I know there's Math.Min, but I want a fluent implementation, so just go with it):

                                        public static int Min(this int a, int max)
                                        {
                                        return (a > max) ? max : a;
                                        }

                                        But what would be a good name for this (which I've tentatively named "MinDelta":

                                        public static int MinDelta(this int a, int delta)
                                        {
                                        return a > a + delta ? a + delta : a;
                                        }

                                        Suggestions? Humor? Marc

                                        V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                                        U Offline
                                        U Offline
                                        User 12831244
                                        wrote on last edited by
                                        #37

                                        Keep it simple and traditional: DeltayMcDeltaface

                                        1 Reply Last reply
                                        0
                                        • H HobbyProggy

                                          -D***Size -Asians -AlphaBetaGamma -DeltaDelta -MyFunction1 -Method -AGreaterB -Minimi -IHaveNoIdeaHowToNameThisThing just to hand you a couple ideas

                                          Rules for the FOSW ![^]

                                          if(this.signature != "")
                                          {
                                          MessageBox.Show("This is my signature: " + Environment.NewLine + signature);
                                          }
                                          else
                                          {
                                          MessageBox.Show("404-Signature not found");
                                          }

                                          R Offline
                                          R Offline
                                          Rage
                                          wrote on last edited by
                                          #38

                                          HobbyProggy wrote:

                                          MyFunction1

                                          This. Exactly this. :)

                                          Do not escape reality : improve reality !

                                          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