classes..
-
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
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
-
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
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
-
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
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
-
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, 2007Jason 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
-
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
Wow, I've never seen such a touchy bunch. Apologies... May I never put words in your mouth again.
-
Wow, I've never seen such a touchy bunch. Apologies... May I never put words in your mouth again.
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 -
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.noYep - 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
-
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
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 -
And the color of the day is - black I presume? ;) Happy painting! -Larantz-
for those about to code, we salute you
http://www.itverket.noDulux 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
-
And the color of the day is - black I presume? ;) Happy painting! -Larantz-
for those about to code, we salute you
http://www.itverket.noThat'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