Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialLewis Cowles
74,902 PointsWhy would you have the date set in the constructor?
Probably a random question, but I actually set the Date within the object Treet's constructor, that way, as you said it was immutable, and only when constructing a tweet would it be generated, and I would know that the creation date would be immutable and represent the date created within any system. I knew that Date() would get the now, I just think it can be dangerous to have a field where the programmer gets control of the logic for creation dates, i.e. more open to error than a sealed system. Thoughts?
1 Answer
Jonathan Seed
1,223 PointsI think that it is just for the sake of example, since the Treets aren't being created in real time(or at least not at the same time as the tweets), so we need to set it to a date in the past.
Lewis Cowles
74,902 PointsLewis Cowles
74,902 PointsI Understand what you are saying, but surely this is more of an argument for importing Treets into the database and simply having them hydrate the Treet class, or another data-type?