Using methods is all well and good, but the methods should do something worth doing. Its also worth noting that using a method for something that takes only a single line of code can be a bad idea, and can often make your code more difficult to read.
Thatās also a suitable and more elegant solution. You should never use a method to return the same as youāve put in. Itās sloppy and definitely not good coding practice. Iād fire someone for that :-p
Occasionally itās worth doing. Say itās meant to be a big complex method, but you donāt intend to develop it till later. It can also be done to build a dummy interface implementation for testing purposes. I can also see something like a buff system in an RPG, that will sometimes retun a value unmodified.
So donāt get to quick with the warning notices.
But on the OP script Iām pretty confident itās pointless. There are also extraneous assignments that are totally unneeded.
If they were going to flesh out the method later to return a modified value then it would be acceptable. I would certainly ask why they used a method instead of a variable. If they have proper justification I would have no problem with it, but if you are using a method to return a constant value that is never modified its just plain wrong. Thereās no reason to obfuscate something thatās already as complex as writing software. I try to code for ease of use and simplicity. This is pretty important when you are working as part of a team in an agile scrum environment.
Chill, this is just for coding practice i mentioned i am a newbie at this i completely understand that there is no use for this method if its only going to represent 1 statement.
If it is for practice you should practice good standards. You can use a method, but make it a method that returns a modified value. Thatās much better practice. Not trying to offend you here; rather just making observations. Best of luck to you and try not to get discouraged
Noob questions often lead to more complex discussions once the question is answered. Itās how we keep ourselves same when every other question is a missing semi colon. Forget reading it as a comment on your work, read it as a discussion between two coders on the merits of a particular technique.