Please enable JavaScript to use CodeHS

CodeHS Glossary


Break Down (Decompose) Java

Breaking down (decomposing) your code is splitting it up into several smaller, simpler methods. Having your code broken down well is called having good "decomposition." You often want to break down your code to make it more readable, avoid repeating code, and to simplify your program. For example, if your code looks like this: public void run() { move(); move(); move(); takeBall(); turnAround(); move(); move(); move(); } you would want to "break it down" into multiple methods, so that it reads like a story: public void run() { moveToBall(); takeBall(); returnHome(); } // moveToBall, takeBall, and returnHome would be defined here By breaking the code down, the program is much easier to read and tells more of a story.