I would love a simple explanation

so I have no problem following the steps of this section and I kinda understand how it works but can someone simple explain why we are moving everything around and when I should do this kind if thing.


I’m not sure of the specific changes you refer to, but “moving everything around” is typically refactoring. Often, you will find that you create a method and write some lines of code and it does exactly what you want, but you may feel that it’s a bit long winded. You may also find that in other areas of your project you have the same or very similar functionality. This is where you would often to start to refactor. The process of tidying things up, streamlining your code, removing duplication, making methods a bit more generic so that you develop re-usability.

Here’s an example two methods which do the same thing;

public void SayHello()
    Debug.Log("Hello Marshall!");

public void SayGoodbye()
    Debug.Log("Goodbye Marshall!");

In the above, we have two specific methods which display different messages, but what they are actually doing is the same, they both display a message. We could refactor that to look more like this;

public void DisplayMessage(string message)

In the above, the one method has a string parameter which will receive the text to be displayed and then display it. To use it we can use the following;

DisplayMessage("Hello Marshall!");

Hope this helps :slight_smile:


what about the Goodbye marshall line???

Then you could just call the DisplayMessage function again, passing a different message, like so:

DisplayMessage("Goodbye Marshall!");

You could just chuck that under the “Hello Marshall” one and it would display both, if you wanted. The beauty of this is you can display a message that says anything you want, rather than only being able to call SayHello(), or sayGoodbye(), now you could say:

DisplayMessage("Have a wonderful day!");

And you wouldn’t have to write a whole function called SayHaveAWonderfulDay() or something like that. Does that make sense?


Ohhh now i got it!! thanks so much for taking the time and explaining it to me…
Have a blessed day.

1 Like

I’m glad I was able to help :slight_smile:

Have a blessed day yourself!

1 Like

ok i understand you example but i still dont understand what the purpose is in the video. i get its to change the greeting message but why would you need to do that

hey thanks for taking the time to answer everyone, its really interesting to look back at this and realize just how computer illiterate I was when first starting, even these forums were confusing. Thanks for all the great classes you guy make in a way that anyone could learn. Also for the wonderful community and support system you have created. I’m very grateful for all the skills I have been able to learn while being apart of it

1 Like

Privacy & Terms