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 Intro to Java Web Development with Spark Bells and Whistles Building Our Model

Sergei Makarov
Sergei Makarov
13,839 Points

Are there any videos/tutorials about MVC, hashCode() and equals()? Especially the last two are very confused.

MVC model have to be explained! In this course we use Models and Views, but there is no any introduction in principal. The second i would like to say, that equals() was just a cutting edge in Java Path. Don't remember about hashCode() at all. I believe they are really necessary things, but don't a lot to be explained about it. Java generics and collection -> it is a just another point, to make an accent to!

JT Keller
JT Keller
12,731 Points

Craig is correct...the MVC concept is extremely prevalent in the Spring Basics tutorials. With that being said, you're best friend as a developer is your favorite search engine. Below is a video that covers the equals and hashcode methods.

https://www.youtube.com/watch?v=7V3589CReug

Also, I prefer to use reflection when overriding the equals and hashcode methods. If you aren't familiar with reflection in Java, there's a ton of information...Google till your hearts content :)

Happy Coding!

@Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    @Override
    public boolean equals(Object that) {
        return EqualsBuilder.reflectionEquals(this, that);

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

At the beginning of this workshop they have a fairly good explanation of MVC and how the parts work together and what they're responsible for. It might be worth checking out! https://teamtreehouse.com/library/creating-your-first-aspnet-mvc-website

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

Hi Sergei Makarov !

Have you taken the Learn Java track? We cover equals and hashCode in Java Data Structures.

There is a pretty detailed discussion about MVC in Spring Basics. I'll add some notes about the pattern, but was trying to just get you focussing on web development here, before diving to deep into the separation of concerns.

I'll ping you when I update the notes as well to point to the equals and hashCode video, thanks for calling that out!