This example will show how to debug code in a short and best way. You have to use System.assert to expose your code for debugging purpose.
Lets Assume-
You have created a page which uses DemoController and which are not showing expected value on the page . So you want to debug the value of Name field of Contact object. Below is the code
//Page exposes contact Name in the form of following error
Now, you have known that contact.Name contains ‘Rose Gonzalez‘.

