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

classes..

Scheduled Pinned Locked Moved C#
questiondatabasejsonhelptutorial
13 Posts 6 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.
  • R Offline
    R Offline
    rcwoods
    wrote on last edited by
    #1

    Hi.. could someone plz help me out.. I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this. Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports. Ive started creating the class for User but now how do i go about creating the rest?

    C 1 Reply Last reply
    0
    • R rcwoods

      Hi.. could someone plz help me out.. I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this. Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports. Ive started creating the class for User but now how do i go about creating the rest?

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      rcwoods wrote:

      I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this.

      public class OuterClass
      {
      public class NestedClass
      {
      // Stuff for NestedClass
      }

      // Other stuff for OuterClass
      

      }

      rcwoods wrote:

      Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports. Ive started creating the class for User but now how do i go about creating the rest?

      What has this got to do with nested classes? How you created the other classes? In the same way as you created the User class I would guess.


      Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

      J M 2 Replies Last reply
      0
      • C Colin Angus Mackay

        rcwoods wrote:

        I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this.

        public class OuterClass
        {
        public class NestedClass
        {
        // Stuff for NestedClass
        }

        // Other stuff for OuterClass
        

        }

        rcwoods wrote:

        Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports. Ive started creating the class for User but now how do i go about creating the rest?

        What has this got to do with nested classes? How you created the other classes? In the same way as you created the User class I would guess.


        Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

        J Offline
        J Offline
        Jason Hanford Smith
        wrote on last edited by
        #3

        rcwoods wrote:

        I want to create a number of classes

        Maybe you mean linked classes? So as to follow the Relationships that exist (supposedly) between the database tables. If so then you probably want something like: public class User { // Properties for the user... } public class PC { // Properties for the PC... } public class Logon { private User _user; public User User { get { return _user; } set { _user = value; } } private PC _pc; public PC PC { get { return _pc; } set { _pc = value; } } // Other properties of Logon... Kinda like that? -- modified at 15:38 Thursday 6th September, 2007

        C 1 Reply Last reply
        0
        • C Colin Angus Mackay

          rcwoods wrote:

          I want to create a number of classes. i was told to use nested classes. but im a bit unclear as to how to do this.

          public class OuterClass
          {
          public class NestedClass
          {
          // Stuff for NestedClass
          }

          // Other stuff for OuterClass
          

          }

          rcwoods wrote:

          Looking at my tables in my database, i have the followin tables: User(list of pc users), Logon(has date,user and pc), File(the file on that PC), PC, Group(the group to which that pc belongs). With these tables i want to generate reports. Ive started creating the class for User but now how do i go about creating the rest?

          What has this got to do with nested classes? How you created the other classes? In the same way as you created the User class I would guess.


          Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

          M Offline
          M Offline
          martin_hughes
          wrote on last edited by
          #4

          At the risk of hijacking the OP's question, what sort of problem maps more appopriately to a nested "composition" design? I just read one illustration that used a car and its engine as an example. They argued that composition, and a nested engine class, made sense, because a car cannot work without an engine. But this doesn't make much sense to me, as a car could have any number of types of engine or the engine could be removed completely (as happened to my car yesterday) and replaced.

          Me: Can you see the "up" arrow? User:Errr...ummm....no. Me: Can you see an arrow that points upwards? User: Oh yes, I see it now! -Excerpt from a support call taken by me, 08/31/2007

          L 1 Reply Last reply
          0
          • M martin_hughes

            At the risk of hijacking the OP's question, what sort of problem maps more appopriately to a nested "composition" design? I just read one illustration that used a car and its engine as an example. They argued that composition, and a nested engine class, made sense, because a car cannot work without an engine. But this doesn't make much sense to me, as a car could have any number of types of engine or the engine could be removed completely (as happened to my car yesterday) and replaced.

            Me: Can you see the "up" arrow? User:Errr...ummm....no. Me: Can you see an arrow that points upwards? User: Oh yes, I see it now! -Excerpt from a support call taken by me, 08/31/2007

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

            Hi, you don't need nested classes: you can create all classes at the top level of some namespace. IF a class is to be used only inside some other class, then you CAN turn it into a nested class, and completely hide it from the outside world. That would offer a higher degree of encapsulation, at the risk that you sooner or later want to use the inner class independent of the containing class... :)

            Luc Pattyn [Forum Guidelines] [My Articles]


            this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


            M 1 Reply Last reply
            0
            • L Luc Pattyn

              Hi, you don't need nested classes: you can create all classes at the top level of some namespace. IF a class is to be used only inside some other class, then you CAN turn it into a nested class, and completely hide it from the outside world. That would offer a higher degree of encapsulation, at the risk that you sooner or later want to use the inner class independent of the containing class... :)

              Luc Pattyn [Forum Guidelines] [My Articles]


              this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


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

              Ah, thanks Luc. The more I know about C# the less I know - and there's another mystery solved.

              Me: Can you see the "up" arrow? User:Errr...ummm....no. Me: Can you see an arrow that points upwards? User: Oh yes, I see it now! -Excerpt from a support call taken by me, 08/31/2007

              1 Reply Last reply
              0
              • J Jason Hanford Smith

                rcwoods wrote:

                I want to create a number of classes

                Maybe you mean linked classes? So as to follow the Relationships that exist (supposedly) between the database tables. If so then you probably want something like: public class User { // Properties for the user... } public class PC { // Properties for the PC... } public class Logon { private User _user; public User User { get { return _user; } set { _user = value; } } private PC _pc; public PC PC { get { return _pc; } set { _pc = value; } } // Other properties of Logon... Kinda like that? -- modified at 15:38 Thursday 6th September, 2007

                C Offline
                C Offline
                Colin Angus Mackay
                wrote on last edited by
                #7

                Jason Hanford-Smith wrote:

                Colin Angus Mackay wrote: I want to create a number of classes

                I never said that - You are misquoting me. Your response should have been addressed to the OP.


                Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                J 1 Reply Last reply
                0
                • C Colin Angus Mackay

                  Jason Hanford-Smith wrote:

                  Colin Angus Mackay wrote: I want to create a number of classes

                  I never said that - You are misquoting me. Your response should have been addressed to the OP.


                  Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                  J Offline
                  J Offline
                  Jason Hanford Smith
                  wrote on last edited by
                  #8

                  Wow, I've never seen such a touchy bunch. Apologies... May I never put words in your mouth again.

                  L 1 Reply Last reply
                  0
                  • J Jason Hanford Smith

                    Wow, I've never seen such a touchy bunch. Apologies... May I never put words in your mouth again.

                    L Offline
                    L Offline
                    Larantz
                    wrote on last edited by
                    #9

                    I just think the CP regulars are starting to get a bit tired of bad subjects, posts for finished code, false quotations, students trying to take the easy road through programming lessons, multi posting, cross-posting, off-topic questions/answers and so on. We've all been growing a bit touchy I guess. :) -Larantz-

                    for those about to code, we salute you
                    http://www.itverket.no

                    C 1 Reply Last reply
                    0
                    • L Larantz

                      I just think the CP regulars are starting to get a bit tired of bad subjects, posts for finished code, false quotations, students trying to take the easy road through programming lessons, multi posting, cross-posting, off-topic questions/answers and so on. We've all been growing a bit touchy I guess. :) -Larantz-

                      for those about to code, we salute you
                      http://www.itverket.no

                      C Offline
                      C Offline
                      Colin Angus Mackay
                      wrote on last edited by
                      #10

                      Yep - I'm going to try some activity that doesn't require a lot of brain power. I'm going to paint my hallway.


                      Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                      L 1 Reply Last reply
                      0
                      • C Colin Angus Mackay

                        Yep - I'm going to try some activity that doesn't require a lot of brain power. I'm going to paint my hallway.


                        Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                        L Offline
                        L Offline
                        Larantz
                        wrote on last edited by
                        #11

                        And the color of the day is - black I presume? ;) Happy painting! -Larantz-

                        for those about to code, we salute you
                        http://www.itverket.no

                        C 2 Replies Last reply
                        0
                        • L Larantz

                          And the color of the day is - black I presume? ;) Happy painting! -Larantz-

                          for those about to code, we salute you
                          http://www.itverket.no

                          C Offline
                          C Offline
                          Colin Angus Mackay
                          wrote on last edited by
                          #12

                          Dulux Daffodil white in a silk finish, actually.


                          Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                          1 Reply Last reply
                          0
                          • L Larantz

                            And the color of the day is - black I presume? ;) Happy painting! -Larantz-

                            for those about to code, we salute you
                            http://www.itverket.no

                            C Offline
                            C Offline
                            Colin Angus Mackay
                            wrote on last edited by
                            #13

                            That's me finished one wall and I've cleaned up for the evening. Tomorrow I'll try and finish the rest of the hall. (Well, at least the first coat - The previous owners had a big brown rectangle painted on the wall, I think that area might require an extra coat because I can still see it, just.)


                            Upcoming FREE developer events: * Glasgow: Agile in the Enterprise Vs. ISVs, db4o: An Embeddable Database Engine for Object-Oriented Environments, Mock Objects, SQL Server CLR Integration, Reporting Services ... My website

                            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