Alrighty.
So over the next lectures we will dig deeper into code formatting and structuring, which is also very
important.
And now we will start with the most obvious, uh, well lecture you can imagine, which is indentation
and spacing.
And usually if you create a class, you want to come up with something like this and not with something
like this.
As I said, like it's very obvious I wasn't even able to create code like this.
I needed to remove all the auto edit indentation from Visual Studio manually, so it was harder to come
up with something like that then something like this.
However, let's just talk about some practices here.
Uh, this is not what you want to have.
You want to have it that way.
So let's assume you create a class and then you want to create great indentation and blocks.
So here we have a block for our properties.
Right.
We have those three property properties one by another all in a new line of code for sure.
And then we have one line break.
And then we have a void here.
Then we would have another void.
Another void.
But we don't or we would not have like a void a property.
Avoid a property.
That's not what you want to have.
You want to have properties, fields and then you want to have methods going on.
Alrighty.
So an indentation it depends.
But usually you have for white spaces.
So if I go ahead and say one, two three, four then I have one indentation.
Or I can simply hit tab which is like four uh spaces basically like count it like four spaces but as
a tab.
Great.
So that said, let's try to fix this very bad indented user class here.
Simply tap it, tap it and tap it.
Same for this public void.
Here we're going to tap this entirely.
And then inside of the void we have some logic going on.
And we for sure also want to indent that one.
And then since this is a block and the void is another block, we have to add a line break here.
Now it looks really good.
One thing that I see pretty much often as soon as the code grows are nested.
If loops that are nested if statements that are a bit weird, but we'll get to that or that can happen
sometimes is a wrong indented most of the time with the white space indented, uh, closing brace so
that it looks like this.
But you know, just keep it everything in one line.
I mean, this is why we got all that helpful lines here from Visual Studio.
So with all of the help that you get from Visual Studio, it will be very hard to mess this up.
However, still wanted to talk about that.
So if I speak for the class you would have properties, private fields, constructor and then all of
your methods.
So this is something that you will see almost every time.