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 Delivering the MVP Validating and Normalizing User Input

Pedro Araya
Pedro Araya
1,912 Points

What is normalization?

I still don't understand what normalization means in this context?

Viktor Khon
Viktor Khon
2,798 Points

I believe that in this specific video, what normalization does is checking if the inputted character is first of all a valid character and not a number or anything else. It then takes the input and converts it to lower case, and finally checks if the inputted character was already used before or not.

1 Answer

Hassaan Ahmad
Hassaan Ahmad
1,979 Points

Generally,what normalization does,is to modify the input in such a way as to meet our program requirements eliminating any related errors. Suppose,the user inputs a number when he/she was required to input a letter. You can't convert it into a letter but what if the user inputs an upper case letter when a lower case letter was required. You can definitely modify or 'normalize' the input to match required form.That's what normalization generally refers to. The former supposition leads to an exception and does the validation of input.

In this video, the method normalizeGuess() handles both the normalization and validation and wraps things up pretty nicely without complicating them. The technicalities of this method have been neatly described by Viktor Khon in the above comment.