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 trial

Java Java Data Structures - Retired Getting There Class Review

Aliasing

In the challange after this video we require to write a constructor that accept all member fields value and initialize them, for example:

public BlogPost (String author, String title ....... ,Date creationDate){ mAuthor = author; mTitle = title; ... ... mCreationDate = creationDate; (This is Aliasing!!!!) }

in your challange when i try to set mCreationDate as a copy! of creationDate like this: mCreationDate = new Date(creationDate); it is fail. but this is the right way to do it, because date is an object and passing away the object it self and not a copy of it will cause a great problem late because the idea of encapsulation will be damaged (mCreationDate will be able to change the value of creationDate and they should be two different object but because of the aliasing they will point to the same address in the heap)

You should teach what is aliasing and how to avoid it (using the constructor that takes and object) and only after that ask people to pass in object and return them.

avoid aliasing is a Very importent thing to know while programming!!