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. .NET Framework Logic

.NET Framework Logic

Scheduled Pinned Locked Moved The Lounge
databasequestioncsharpdotnetlinq
13 Posts 11 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    Mike Marynowski
    wrote on last edited by
    #1

    TL;DR is at the bottom if you aren't in for a read.

    IList : ICollection
    ISet : ICollection
    ICollection : IEnumerable

    Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

    List : IList

    Here is where it gets a little wonky:

    LinkedList : ICollection

    Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

    Collection : IList
    ObservableCollection : Collection
    ReadOnlyCollection : IList

    Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

    ReadOnlyEnumerable(IEnumerable source)
    ReadOnlyCollection(ICollection source)
    ReadOnlyList(IList source)

    I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

    OriginalGriffO M H J N 8 Replies Last reply
    0
    • M Mike Marynowski

      TL;DR is at the bottom if you aren't in for a read.

      IList : ICollection
      ISet : ICollection
      ICollection : IEnumerable

      Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

      List : IList

      Here is where it gets a little wonky:

      LinkedList : ICollection

      Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

      Collection : IList
      ObservableCollection : Collection
      ReadOnlyCollection : IList

      Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

      ReadOnlyEnumerable(IEnumerable source)
      ReadOnlyCollection(ICollection source)
      ReadOnlyList(IList source)

      I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

      OriginalGriffO Online
      OriginalGriffO Online
      OriginalGriff
      wrote on last edited by
      #2

      Probably, because it was developed by a committee - which I suspect have never met - and nobody took any account of what each other was doing. What annoys me is simpler: why does an array have a Length, and a collection a Count?

      The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
      "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

      M L M 4 Replies Last reply
      0
      • OriginalGriffO OriginalGriff

        Probably, because it was developed by a committee - which I suspect have never met - and nobody took any account of what each other was doing. What annoys me is simpler: why does an array have a Length, and a collection a Count?

        The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

        M Offline
        M Offline
        Mike Marynowski
        wrote on last edited by
        #3

        I don't mind that one so much. It's splitting hairs and debatable, but Count is more generic than Length. A list can have a longer length than the count of items inside it. A collection could generate values on the fly, so it has no length per se, but rather a count of the values it will spit out. I could see that one from either perspective. I think I'm slightly in favor of consistency and keeping it Length but whatever.

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          Probably, because it was developed by a committee - which I suspect have never met - and nobody took any account of what each other was doing. What annoys me is simpler: why does an array have a Length, and a collection a Count?

          The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

          M Offline
          M Offline
          Mike Marynowski
          wrote on last edited by
          #4

          Here is a better worded explanation than I just offered you: http://stackoverflow.com/questions/300522/count-vs-length-vs-size-in-a-collection/300540[^]

          1 Reply Last reply
          0
          • OriginalGriffO OriginalGriff

            Probably, because it was developed by a committee - which I suspect have never met - and nobody took any account of what each other was doing. What annoys me is simpler: why does an array have a Length, and a collection a Count?

            The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

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

            OriginalGriff wrote:

            why does an array have a Length, and a collection a Count?

            Because an array is linear, but a collection may or may not be.

            Use the best guess

            1 Reply Last reply
            0
            • M Mike Marynowski

              TL;DR is at the bottom if you aren't in for a read.

              IList : ICollection
              ISet : ICollection
              ICollection : IEnumerable

              Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

              List : IList

              Here is where it gets a little wonky:

              LinkedList : ICollection

              Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

              Collection : IList
              ObservableCollection : Collection
              ReadOnlyCollection : IList

              Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

              ReadOnlyEnumerable(IEnumerable source)
              ReadOnlyCollection(ICollection source)
              ReadOnlyList(IList source)

              I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

              M Offline
              M Offline
              M Badger
              wrote on last edited by
              #6

              My favourite, of those I've randomly stumbled into, is the donkey who decided that it would be smart to index arrays as (row, column) and DataGridViews as (column, row). That had me editing a custom IEnumerable for ages before I finally checked the DGV syntax. Could. Not. Believe. It.

              1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Probably, because it was developed by a committee - which I suspect have never met - and nobody took any account of what each other was doing. What annoys me is simpler: why does an array have a Length, and a collection a Count?

                The universe is composed of electrons, neutrons, protons and......morons. (ThePhantomUpvoter)

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

                OriginalGriff wrote:

                why does an array have a Length, and a collection a Count?

                An array is a contiguous block of memory having a specific allocation length, whereas a collection is a "bag" of items having a count. At least, that's how I always think about it. :) Marc

                Testers Wanted!
                Latest Article: User Authentication on Ruby on Rails - the definitive how to
                My Blog

                1 Reply Last reply
                0
                • M Mike Marynowski

                  TL;DR is at the bottom if you aren't in for a read.

                  IList : ICollection
                  ISet : ICollection
                  ICollection : IEnumerable

                  Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

                  List : IList

                  Here is where it gets a little wonky:

                  LinkedList : ICollection

                  Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

                  Collection : IList
                  ObservableCollection : Collection
                  ReadOnlyCollection : IList

                  Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

                  ReadOnlyEnumerable(IEnumerable source)
                  ReadOnlyCollection(ICollection source)
                  ReadOnlyList(IList source)

                  I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

                  H Offline
                  H Offline
                  H Brydon
                  wrote on last edited by
                  #8

                  You are right - it was too long to read (ie. size and length were both too long; I counted my time carefully). Strings are also a special case where they have both a size and a length.

                  char buff[] = "Hello";
                  int iSize = sizeof(buff); // 6
                  int iLen = strlen(buff); // 5

                  -- Harvey

                  1 Reply Last reply
                  0
                  • M Mike Marynowski

                    TL;DR is at the bottom if you aren't in for a read.

                    IList : ICollection
                    ISet : ICollection
                    ICollection : IEnumerable

                    Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

                    List : IList

                    Here is where it gets a little wonky:

                    LinkedList : ICollection

                    Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

                    Collection : IList
                    ObservableCollection : Collection
                    ReadOnlyCollection : IList

                    Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

                    ReadOnlyEnumerable(IEnumerable source)
                    ReadOnlyCollection(ICollection source)
                    ReadOnlyList(IList source)

                    I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

                    J Offline
                    J Offline
                    jschell
                    wrote on last edited by
                    #9

                    Mike Marynowski wrote:

                    I just find this all very strange.

                    Although much of the time naming is fairly easy that isn't always the case. And it becomes more problematic with more esoteric designs, with multiple inheritance possibilities (primarily interfaces) and with multiple developers.

                    1 Reply Last reply
                    0
                    • M Mike Marynowski

                      TL;DR is at the bottom if you aren't in for a read.

                      IList : ICollection
                      ISet : ICollection
                      ICollection : IEnumerable

                      Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

                      List : IList

                      Here is where it gets a little wonky:

                      LinkedList : ICollection

                      Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

                      Collection : IList
                      ObservableCollection : Collection
                      ReadOnlyCollection : IList

                      Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

                      ReadOnlyEnumerable(IEnumerable source)
                      ReadOnlyCollection(ICollection source)
                      ReadOnlyList(IList source)

                      I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

                      N Offline
                      N Offline
                      Nish Nishant
                      wrote on last edited by
                      #10

                      Enjoyed reading your post. :-)

                      Regards, Nish


                      Blog: voidnish.wordpress.com The life of a Malayalee American - by Nish

                      An article I recently wrote for an event souvenir

                      1 Reply Last reply
                      0
                      • M Mike Marynowski

                        TL;DR is at the bottom if you aren't in for a read.

                        IList : ICollection
                        ISet : ICollection
                        ICollection : IEnumerable

                        Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

                        List : IList

                        Here is where it gets a little wonky:

                        LinkedList : ICollection

                        Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

                        Collection : IList
                        ObservableCollection : Collection
                        ReadOnlyCollection : IList

                        Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

                        ReadOnlyEnumerable(IEnumerable source)
                        ReadOnlyCollection(ICollection source)
                        ReadOnlyList(IList source)

                        I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

                        B Offline
                        B Offline
                        BillWoodruff
                        wrote on last edited by
                        #11

                        An excellent example of a post, that, if posted in the C#, or .NET FrameWork forum, might have led to an even more educational discussion. yours, Bill

                        “Human beings do not live in the objective world alone, nor alone in the world of social activity as ordinarily understood, but are very much at the mercy of the particular language which has become the medium of expression for their society. It is quite an illusion to imagine that one adjusts to reality essentially without the use of language and that language is merely an incidental means of solving specific problems of communication or reflection." Edward Sapir, 1929

                        1 Reply Last reply
                        0
                        • M Mike Marynowski

                          TL;DR is at the bottom if you aren't in for a read.

                          IList : ICollection
                          ISet : ICollection
                          ICollection : IEnumerable

                          Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

                          List : IList

                          Here is where it gets a little wonky:

                          LinkedList : ICollection

                          Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

                          Collection : IList
                          ObservableCollection : Collection
                          ReadOnlyCollection : IList

                          Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

                          ReadOnlyEnumerable(IEnumerable source)
                          ReadOnlyCollection(ICollection source)
                          ReadOnlyList(IList source)

                          I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

                          B Offline
                          B Offline
                          Brisingr Aerowing
                          wrote on last edited by
                          #12

                          Logic? Microsoft? Does not compute!

                          Gryphons Are Awesome! ‮Gryphons Are Awesome!‬

                          1 Reply Last reply
                          0
                          • M Mike Marynowski

                            TL;DR is at the bottom if you aren't in for a read.

                            IList : ICollection
                            ISet : ICollection
                            ICollection : IEnumerable

                            Okay, so far so good. IEnumerable can enumerate through a bunch of items, ICollection can modify the items, and List can access the items by index. ISet can also be modified, which is why it inherits ICollection, supports its own set operations, and because it can't be indexed it doesn't inherit IList. Beautiful. Makes sense. As for sensible implementations, we have:

                            List : IList

                            Here is where it gets a little wonky:

                            LinkedList : ICollection

                            Now I understand that a "linked list" is the common name for the data structure...but if you aren't going to use the world "list" consistently within the same damn namespace, then just change IList to something more descriptive like IIndexedCollection. Now here is where it gets super funky:

                            Collection : IList
                            ObservableCollection : Collection
                            ReadOnlyCollection : IList

                            Sooo....if Collection implements IList then why isn't it called something like CustomList? It's purpose is to allow custom implementations to hook into changes to the collection. ObservableCollection has indexed access since Collection actually implements them, so why isn't it ObservableList? Why does ReadOnlyCollection require an IList as input, and why does it provide indexed access? It should be three different types with the following constructors:

                            ReadOnlyEnumerable(IEnumerable source)
                            ReadOnlyCollection(ICollection source)
                            ReadOnlyList(IList source)

                            I just find this all very strange. IQueryable/IEnumerable Side Note: As a related side note, why did they make IQueryable implement IEnumerable? It should be a separate interface with a method ToEnumerable on it which forces query execution. This way, you wouldn't be able to pass an IQueryable into a method that takes IEnumerable and accidentally cause the query to execute, which I see newbies do all the time. They don't realize there's going to be a huge performance problem when the queryable loads all the records from the database and the rest of the filters are executed client side. I don't see why it wouldn't be desirable to explicitly see the point where the IQueryable gets executed and converted to a local IEnumerable. All of my custom IEnumerable extension methods show up on IQueryable objects, and if you i

                            R Offline
                            R Offline
                            RafagaX
                            wrote on last edited by
                            #13

                            Don't take consistency too seriously, or you would end up totally bald... ;P

                            CEO at: - Rafaga Systems - Para Facturas - Modern Components for the moment...

                            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