Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Java Java Data Structures Efficiency! Implement Chooser UI

Tomas Verblya
Tomas Verblya
1,998 Points

Regarding the difficulty of this video.

I feel like all of my Java knowledge and motivation just went out the window after trying over and over to understand the huge amount of logic that went into this video.

I am completely stumped over every single method and feel overwhelmed with the amount of intertwining methods. So I feel like I will need a lot of time to get this lesson in check.

I have a question. I assume that the course has been planned ahead of making these videos, and Craig is not just writing this as he goes? It seems to me like this is very thought out logic and efficient ways of achieving ones goals. In a real world situation, how long would someone who is tasked with writing this code would take? It feels to me that every step or every method has to be mulled over for at least an hour before I could decide what to write and how to handle these problems.

Sorry for the rant, I just feel overwhelmed...

Orion Wolf-Hubbard
Orion Wolf-Hubbard
4,906 Points

Hi, you aren't alone, I spent hours trying to understand the last few videos.

5 Answers

Florian Tönjes
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Florian Tönjes
Full Stack JavaScript Techdegree Graduate 50,856 Points

Hi Tomas,

I can understand your frustration. Don't let it stop you though. In programming there is always a lot to learn and with time you will understand more and more of the concepts. If you get stuck for too long you might want to look for other learning material.

Kind Regards, Florian

Don't worry and don't give up. No we all can harness JShell to help us to understand this logic. Without this tool it would took me days to understand this logic included in this video. But I created simplify statement in JShell and it really helped me to stay on the track.

for example I used the simplified code in shell

jshell ==> Map<String, String> byArtist = new HashMap<>();
>>> {}. //OK ?

jshell ==> List<String>  artistSongs; // this is only empty reference, doesn't point to any object
>>> null // OK?

jshell ==> byArtist.get("Alvaro Soler"); // simplification, I don't use "song.getArtist()" // null = null.  // OK ?
>>> null // OK?

jshell ==> List<String> artistSongs = byArtist.get(AlvaroSoler);
>>> null OK?

jshell ==> if (artistSongs == null) {  // it is now null, isn't ?
________   artistSongs = new ArrayList<>();  // now we created the real list in memory
________   byArtist.put(song.getArtist(), artistSongs);}  // we put (add) to the map new entry >> current artist (Alvaro Soler) as a key and real empty list as a value
________ }

jshell ===> byArtist;
>>> {"Alvaro Soler"} // OK?

jshell ==> byArtist.get("Alvaro Soler");
>>> [] // OK ?

jshell ==> artistSongs.add("Animal");

jshell ==> byArtist.get("Alvaro Soler");
>>> [Animal] // OK ?

Now when in next loop next song is is still performed by Alvaro Soler - if conditional statement is ignored. Why? We can check it:

jshell ==> List<String> artistSong;
>>> [Animal] // OK? So its not empty and add new song for current artist - still Alvaro Soler

If in next loop in next song will be new artist then we play again:

jshell ==> List<String> artistSongs = byArtist.get(Marylin Manson);
>>> null OK?

It keeps this track in the map, so there is no problem if code meet again Alvaro Soler. Just new song will be added for him. The map keeps track for keys and values.

Uff !!! :) I spend almost 12 hours to catch this from video but it was wort it.

BUT I THING CRAIG IS MAKING AN AWSOME JOB. NO MORE BOOKS WITH SIMPLE TASK TO DO.... REALLY

He creates and teaches us how to build (or how those aps are manufactured in real environment) real aps from scratch. In 99,99% other courses I have participated, teachers only make simple examples for each topic. We all here address all our knowledge to use in one big app. Look, collection topic is hard, it hurts (I feel it in my bones after 12 hours in a chair ) and is postponed in the most books, online courses for beginners. But is vastly demanding on the market job even for junior programmers. After this month of learning I have to admit, that I really made a huge progress. Now I understand all of this (I think so). I tried once be learned by other courses or books. After 6 months I still felt stupid... really. Now I am in a place where I can say: I feel it. Moreover I understand now topics from other books and online java docs...

I apologize for my English but I'm a self taught (I love and learn General American accent).

I almost forget. Community here is great. Steve Hunter's advices change everything :) Thank you Steve.

Martin Gallauner
Martin Gallauner
10,808 Points

It's really quite difficult but I think it's the target of the video to show people how to use different data structures on a "real" example. Not enable them to write this kind of programs on their own just after this video. They code challenges are also much more easier and smaller.

Just take whatever you can :)

Hi folks , @Darth R3id4k , @Florian Tönjes ,@Martin Gallauner

thanks allot I was frustrated after watching and trying to connect the dots, it was really tough and i had to pause the video and see what the community have to say about data structure especially Implement Chooser UI, and you know what am not alone we all feel this way.I think it is just a test, do we have what it takes to be a good developer ? the answer is yes we can . @Darth R3id4k thanks again for your support and effort, your advise boosted me up and i will never give up . no way .

Thanks a looot guys I was stuck too. Thanks a lot for giving me back motivation!!! My opinion is that, I like how Craig is teaching. Because we are not going to face hello world programs in software development. We have to make progress and go to advanced stuff. It might be hard at first, but over time it will get cleaner.