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 Objects (Retired) Creating the MVP Prompting for Guesses

Miguel Gonzalez Rocha
Miguel Gonzalez Rocha
2,849 Points

game.java and promppter.java could be combined?

in the hangman.java i got confused when one class uses the other class and that one uses the other class. is this the price of having everything separate? but is it possible to have for example the game.java and the prompter.java as one? i know it wont in order but is it possible?

2 Answers

You should consider that a class should just do one job or one responibility. For sure you could make a class called "AllinOne.class". But imagine how much methods and properties/fields you might fill in there when you create a greater project.

there are some coding guidelines which tell how you could create a nice code architecture which is good to read and manage later.

You might google for the "SOLID Principles"

One of them is the "S" of SOLID which means "Single Responsibility Principle". In other words: "A class should only do one job" If you need a different job done - create another class for it.

Hope I helped you a bit...as I said - check out that SOLID thingie

Miguel Gonzalez Rocha
Miguel Gonzalez Rocha
2,849 Points

This is exactly what i wanted, i know i was going to learn all that with time but this is going to help me get my codes in order faster, ty

glad I could help bro