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.
  • 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

    R Offline
    R Offline
    realJSOP
    wrote on last edited by
    #2

    Oranges

    ".45 ACP - because shooting twice is just silly" - JSOP, 2010
    -----
    You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
    -----
    When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

    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

      R Offline
      R Offline
      realJSOP
      wrote on last edited by
      #3

      DeltaBurke

      ".45 ACP - because shooting twice is just silly" - JSOP, 2010
      -----
      You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
      -----
      When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

      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

        R Offline
        R Offline
        realJSOP
        wrote on last edited by
        #4

        RiverDelta

        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
        -----
        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
        -----
        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

        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

          R Offline
          R Offline
          realJSOP
          wrote on last edited by
          #5

          AmazingSpiderMan

          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
          -----
          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
          -----
          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

          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

            R Offline
            R Offline
            realJSOP
            wrote on last edited by
            #6

            Cliftonopolis

            ".45 ACP - because shooting twice is just silly" - JSOP, 2010
            -----
            You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
            -----
            When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

            M 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

              R Offline
              R Offline
              realJSOP
              wrote on last edited by
              #7

              Marcinator

              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
              -----
              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
              -----
              When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

              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

                R Offline
                R Offline
                richp669
                wrote on last edited by
                #8

                How about: Minimum - I told you all that I had no imagination!

                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
                  #9

                  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 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

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

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

                    M Richard DeemingR 2 Replies 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

                      H Offline
                      H Offline
                      HobbyProggy
                      wrote on last edited by
                      #11

                      -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 R 2 Replies Last reply
                      0
                      • R realJSOP

                        Cliftonopolis

                        ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                        -----
                        You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                        -----
                        When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

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

                        John Simmons / outlaw programmer wrote:

                        Cliftonopolis

                        This stuff is already in the namespace Clifton.Core.ExtensionMethods but maybe I'll change that to Cliftonpolis! 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
                        • J Jochen Arndt

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

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

                          Yeah, I though about something like AddIfNegative but it's too long. ;) 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

                          J R B 3 Replies Last reply
                          0
                          • M Marc Clifton

                            Yeah, I though about something like AddIfNegative but it's too long. ;) 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

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

                            AddLT0 (Add if Less Than Zero) :)

                            J 1 Reply Last reply
                            0
                            • M Marc Clifton

                              Yeah, I though about something like AddIfNegative but it's too long. ;) 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

                              R Offline
                              R Offline
                              realJSOP
                              wrote on last edited by
                              #15

                              Make in an acronym: pAIN

                              ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                              -----
                              You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                              -----
                              When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                              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
                                #16

                                How could you not call it JustinBeiber?

                                Sin tack ear lol Pressing the any key may be continuate

                                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
                                  Mladen Jankovic
                                  wrote on last edited by
                                  #17

                                  MinDelta->Fall / MaxDelta->Climb?

                                  GeoGame for Windows Phone | The Lounge Explained In 5 Minutes

                                  M 1 Reply Last reply
                                  0
                                  • M Marc Clifton

                                    Yeah, I though about something like AddIfNegative but it's too long. ;) 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
                                    Bassam Abdul Baki
                                    wrote on last edited by
                                    #18

                                    I prefer his approach and would call it DeltaOffset.

                                    Web - BM - RSS - Math - LinkedIn

                                    1 Reply Last reply
                                    0
                                    • 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
                                          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