Which way is best and why?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Pastuh


I have found two ways of writing the same code. But which one is the right way to do it and why?

		$Node2D/Particles2D.amount = 30

:bust_in_silhouette: Reply From: KND2501

I’m going to take a guess and go with the first one.

   $Node2D/Particles2D.amount = 30

Why, because it sounds simpler, it just states an amount not having to set anything wich sounds like a process or at least a thing.

Unless something specifically requires the amount to be set ofcourse. Maybe there’s the exception?

Don’t listen to me, i don’t know nothing.

:bust_in_silhouette: Reply From: umsee

Just making sure it is out there, if you are using setters and getters (like the set_amount(n)) you are using you shouldn’t be able to do it the first way.

So it’s a property of Object Oriented Languages to have a private class(where you can’t access the property by Class.property because duh, Private Class) you have a public method in that class that sets and gets the value for that property.

So by all means go by KND2501’s suggestion. KISS(Keep it Simple Stupid) all the way