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. General Programming
  3. C#
  4. Property Name Sementics - IsEmpty or Empty

Property Name Sementics - IsEmpty or Empty

Scheduled Pinned Locked Moved C#
question
26 Posts 13 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.
  • L Lost User

    Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

    P Offline
    P Offline
    PIEBALDconsult
    wrote on last edited by
    #3

    Yeah, what he said.

    1 Reply Last reply
    0
    • L Lost User

      Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #4

      Hmmmm... from the existentialism point of view, isn't a polygon with no points null?? Seriously, IsEmpty could also be used to describe the polygon as an enclosure. So, IsEmpty could actually refer to the polygon enclosing some content. And is a polygon with only one or two points really a polgyon? Wouldn't the property then become IsValidPolygon? Just some food for thought...

      A guide to posting questions on CodeProject[^]
      Dave Kreskowiak

      1 Reply Last reply
      0
      • L Lost User

        Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #5

        .NET isn't entirely consistent on the matter. Have a look at all the boolean properties of a System.Windows.Forms.Form, including: 1. Visible 2. IsAccessible, IsDisposed, IsMdiChild, ... 3. AllowDrop, CanFocus, CanRaiseEvents, CanSelect, ... 4. AutoScroll, AutoSize, ... 5. Created, Enabled, ... Except for #1, they all have a verb (or even two), and that is how I'd do it too. One should avoid confusion, especially when the word could be an adjective as well as a verb. So I would reserve Empty for an action (method or event), IsEmpty for a property. :)

        Luc Pattyn [My Articles] Nil Volentibus Arduum

        P 1 Reply Last reply
        0
        • L Lost User

          Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

          R Offline
          R Offline
          R Giskard Reventlov
          wrote on last edited by
          #6

          Exists or IsExists?

          "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

          L 1 Reply Last reply
          0
          • R R Giskard Reventlov

            Exists or IsExists?

            "If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair. nils illegitimus carborundum me, me, me

            L Offline
            L Offline
            Luc Pattyn
            wrote on last edited by
            #7

            Are you speaking to non-existing objects now? Do you really expect Exists to return false any time soon? This reminds me of Thread.IsAlive :doh:

            Luc Pattyn [My Articles] Nil Volentibus Arduum

            P 1 Reply Last reply
            0
            • L Luc Pattyn

              Are you speaking to non-existing objects now? Do you really expect Exists to return false any time soon? This reminds me of Thread.IsAlive :doh:

              Luc Pattyn [My Articles] Nil Volentibus Arduum

              P Offline
              P Offline
              PIEBALDconsult
              wrote on last edited by
              #8

              e.g. FileInfo.Exists

              L 1 Reply Last reply
              0
              • L Lost User

                Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

                C Offline
                C Offline
                Caleb McElrath
                wrote on last edited by
                #9

                There has been references to "Exists" from FileInfo. You CAN "Empty" something while you canNOT "Exists" something therefore, "Exists" is valid as a boolean property. The question is more about grammar and how we associate words and actions. "IsEmpty" is asking a question with only two answers (boolean true/false). "Empty" is either stating something is empty or indicates an action that can be taken to obtain something that is empty (String.Empty allows you to obtain an empty string). Therefore, if a boolean value indicating whether a Polygon 'is empty' is needed I would suggest "IsEmpty". If you would like to obtain an empty Polygon, Polygon.Empty will suffice.

                1 Reply Last reply
                0
                • P PIEBALDconsult

                  e.g. FileInfo.Exists

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #10

                  PURGE *.*;* :)

                  Luc Pattyn [My Articles] Nil Volentibus Arduum

                  P 1 Reply Last reply
                  0
                  • L Luc Pattyn

                    PURGE *.*;* :)

                    Luc Pattyn [My Articles] Nil Volentibus Arduum

                    P Offline
                    P Offline
                    PIEBALDconsult
                    wrote on last edited by
                    #11

                    Alas. I moved in December and haven't even hooked my AlphaServers back up yet.

                    1 Reply Last reply
                    0
                    • L Lost User

                      Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

                      A Offline
                      A Offline
                      AspDotNetDev
                      wrote on last edited by
                      #12

                      IsPointless

                      Thou mewling ill-breeding pignut!

                      1 Reply Last reply
                      0
                      • L Lost User

                        Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

                        Richard Andrew x64R Offline
                        Richard Andrew x64R Offline
                        Richard Andrew x64
                        wrote on last edited by
                        #13

                        IsEmpty sounds like it should be a method because it contains a verb. And verbs are actions, like methods. Empty sounds like it should be a property because it's simply a state of being.

                        The difficult we do right away... ...the impossible takes slightly longer.

                        L 1 Reply Last reply
                        0
                        • L Luc Pattyn

                          .NET isn't entirely consistent on the matter. Have a look at all the boolean properties of a System.Windows.Forms.Form, including: 1. Visible 2. IsAccessible, IsDisposed, IsMdiChild, ... 3. AllowDrop, CanFocus, CanRaiseEvents, CanSelect, ... 4. AutoScroll, AutoSize, ... 5. Created, Enabled, ... Except for #1, they all have a verb (or even two), and that is how I'd do it too. One should avoid confusion, especially when the word could be an adjective as well as a verb. So I would reserve Empty for an action (method or event), IsEmpty for a property. :)

                          Luc Pattyn [My Articles] Nil Volentibus Arduum

                          P Offline
                          P Offline
                          PIEBALDconsult
                          wrote on last edited by
                          #14

                          We can take this thread over and discuss such issues. :-D On something I was writing last week I have a Parse method and decided to have a TryParse as well, but it occurred to me that there is no need to differentiate the method names -- having overloaded Parse methods won't cause any trouble. So I wonder why Microsoft decided to use a new name. I suspect it's simply a matter of marketing -- they can advertise and talk up the new TryParse methods more easily that way.

                          L 1 Reply Last reply
                          0
                          • P PIEBALDconsult

                            We can take this thread over and discuss such issues. :-D On something I was writing last week I have a Parse method and decided to have a TryParse as well, but it occurred to me that there is no need to differentiate the method names -- having overloaded Parse methods won't cause any trouble. So I wonder why Microsoft decided to use a new name. I suspect it's simply a matter of marketing -- they can advertise and talk up the new TryParse methods more easily that way.

                            L Offline
                            L Offline
                            Luc Pattyn
                            wrote on last edited by
                            #15

                            I guess it would be considered too confusing to have some Parse() methods that throw exceptions on failure, and others that just return false; I do recall a Microsoft recommendation NOT to have a parameter that controls whether failures would throw exceptions, for the same reason. :)

                            Luc Pattyn [My Articles] Nil Volentibus Arduum

                            P 1 Reply Last reply
                            0
                            • Richard Andrew x64R Richard Andrew x64

                              IsEmpty sounds like it should be a method because it contains a verb. And verbs are actions, like methods. Empty sounds like it should be a property because it's simply a state of being.

                              The difficult we do right away... ...the impossible takes slightly longer.

                              L Offline
                              L Offline
                              Luc Pattyn
                              wrote on last edited by
                              #16

                              For a different view[^]... :)

                              Luc Pattyn [My Articles] Nil Volentibus Arduum

                              Richard Andrew x64R 1 Reply Last reply
                              0
                              • L Luc Pattyn

                                For a different view[^]... :)

                                Luc Pattyn [My Articles] Nil Volentibus Arduum

                                Richard Andrew x64R Offline
                                Richard Andrew x64R Offline
                                Richard Andrew x64
                                wrote on last edited by
                                #17

                                Well, since .NET is inconsistent on the matter, why follow them? Set your own naming standards for your own code, I say.

                                The difficult we do right away... ...the impossible takes slightly longer.

                                L 1 Reply Last reply
                                0
                                • Richard Andrew x64R Richard Andrew x64

                                  Well, since .NET is inconsistent on the matter, why follow them? Set your own naming standards for your own code, I say.

                                  The difficult we do right away... ...the impossible takes slightly longer.

                                  L Offline
                                  L Offline
                                  Luc Pattyn
                                  wrote on last edited by
                                  #18

                                  It is only a little inconsistent, it is mostly all right, so I choose to go along with their view, which helps readability I'd say. The most annoying inconsistency IMO is Array.Length versus List.Count (I would applaud them if they would introduce the missing one as a synonym). :)

                                  Luc Pattyn [My Articles] Nil Volentibus Arduum

                                  1 Reply Last reply
                                  0
                                  • L Lost User

                                    Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

                                    R Offline
                                    R Offline
                                    Roger Wright
                                    wrote on last edited by
                                    #19

                                    If a polygon has no points, it's not a polygon. If a polygon comprised of four or more points contains no additional points within the boundaries which define it, then it IsEmpty. How you code it makes little difference; it's still going to be a boolean value that you'll test. But I prefer to name boolean properties for the value I expect to find most often. It makes no difference logically, but I find it easier to read and understand what the code is looking for.

                                    Will Rogers never met me.

                                    1 Reply Last reply
                                    0
                                    • L Lost User

                                      Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

                                      P Offline
                                      P Offline
                                      Pete OHanlon
                                      wrote on last edited by
                                      #20

                                      If you're just using a property to indicate whether or not it has any points, then I would expect it to be HasPoints. If, however, you need to indicate whether or not it has enough points to be classed as a polygon, I would use IsPolygon.

                                      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

                                      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

                                      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

                                      1 Reply Last reply
                                      0
                                      • L Lost User

                                        Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

                                        B Offline
                                        B Offline
                                        BobJanova
                                        wrote on last edited by
                                        #21

                                        The short answer is that both are acceptable and both are used within the Framework, so use whichever you think is better. I typically drop the 'Is'. I also agree with other posters who've said that you should really be defining a Valid (or IsValid ;P ) property which checks that there are at least 3 points (maybe 3 non-colinear points?). The points array being empty isn't really a relevant concern, I don't think.

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          Can't make up my mind. Coding a class that represents a Polygon. If the polygon has no points should the property name be Empty or IsEmpty?

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

                                          "Empty"; as "IsEmpty" would be question and would indeed imply either a delegate or a method. "Empty" is a property of the Polygon. "IsEmpty" would be a method that can be called from that property to fetch a value, but a property never begins with "Is". The color of an apple is "Apple.Color", not "Apple.IsColor". Yes, you might be persuaded to prefix the "Is" because the property returns a bool. It shouldn't matter whether it returns a bool or an enum - if it's a property, then it'll have the name of a property - not the form a question.

                                          Bastard Programmer from Hell :suss:

                                          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