I'm writing my first OOP project, just a personal project one to get comfortable with this approach over procedural.

I've got a heap of common objects car, staff, customer etc.

I'm writing the object class but am also writing a second page for each for the list of, such as

`Public Class Customer(){

}`

then have

Public Class CustomerList(){
}

I seem to be doing that for them all.

Is it possible to have

`Public Class ListOfObject(){

}`

Then inside the return a list of generic objects or add in a new object, remove an object etc.

Is this approach good practice?

    tl;dr: I personally would just stick related objects into an array if that's the only reason you're creating the list class.

    So...depending on what you're doing, maybe it's overkill in some cases? I.e., if the only purpose of the list class is to store a bunch of related objects, you could do that in an array (and pretend you're using Ruby, where "everything is an object" [including arrays] 🙂 ). If, however, you add additional methods to that list class to do stuff with those contained objects, then it makes more sense -- but then there's also a decent chance that those additional methods will be specific to the type of object being contained, perhaps? So I guess for me it would be an "it depends", probably opting for the simpler solution until I ran into something that made me decide to make a list class (whether generic or object-type-specific).

      Write a Reply...