Some of the longer words are compounds of shorter words. If you learn the shorter words, putting them together can be easy depending on the word.
For example, 食器洗浄機 is composed of 食器 (dishes) and 洗浄機 (washing machine). If you know the meaning of these two words, it’s easy to put them together to get dishwasher. Breaking it down even further, if you know that 洗浄 means wash and 機 means machine, it’s not difficult to see them together and know that 洗浄機 means washing machine.
For something like 一所懸命, that is harder because it comes from a type of Chinese expression composed of 4 characters. In Japanese, these 4-character word expressions are called 四字熟語 (yo ji juku go).
The meaning of the expressions ares generally derived from a story that you have to know in order for it to make sense, so it can’t be inferred from the meaning of the 4 individual characters. However, if you know the meaning of the individual characters and the story behind the expression, it can be quite easy to learn the expression.
Also, because these expressions come from Chinese, the onyomi (Chinese) reading of the kanji would be used, so each expression always has just 4 syllables.
One of my favorites is 四面楚歌 (shi men so ka). The first two characters mean ‘4 directions’ or ‘4 sides’. The third one is the name of a state in China at the time of the story, and the fourth one means song. The short of the story is that a warlord was fighting a losing battle and when he heard soldiers singing the song of the army he was fighting (the So army, or Chu in Chinese) from all four directions, he knew he was surrounded and doomed.
The expression literally means something like ‘Hearing the So army song coming from all four directions’, and it’s used to express that someone in a tight situation is screwed. For example, if you arrive to class and see that you have a midterm exam that you forgot about and didn’t study for, you could say 四面楚歌 (shi men so ka) to express ‘I’m screwed!’.