0

I am trying to develop a conceptual model (object-oriented) of GPS-collected data. Usually, common classes are Track, which represents an ordered sequence of Trackpoints, and the class Trackpoint itself, which has properties such as latitude, longitude, elevation, timestamp, speed, accumulated distance, etc.

The fact is: since a Trackpoint instance only "makes sense" as an item of a Track (or a Segment, or a ConnectedSegment, or other possible similar collection types), the question is:

Is it good/common practice to design a class so that it "behaves" better (or exclusively) as member of a collection? And should I design the collection itself to enforce this?

heltonbiker
  • 26,657
  • 28
  • 137
  • 252

1 Answers1

0

I think most languages provide various collections implementations and they are well optimized. There is not much point in rolling your own implementations.

If you really don't want "TrackPoint" to be visible outside "Track", then, in Java, one can make TrackPoint a private class inside the definition of Trackclass. I guess in other languages too, you can apply similar visibility restrictions. Again, normally one does not need to to this kind of design either.

Design a Track class which has list of TrackPoint as member. It is as simple as that, and is perfectly good OO design.

Wand Maker
  • 18,476
  • 8
  • 53
  • 87