Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How woul you response to below 2 comments? with affirmation or examples A) I am

ID: 664331 • Letter: H

Question

How woul you response to below 2 comments? with affirmation or examples

A)

I am for method overloading. You can perform the same function with differnt types and amounts of arguments. It is the code performing the same function but each part of it has different ways to use them. The fact that makes reading code easier is one big reason why it is good. It makes it easier to read things when they are lumped together in the same ways throughout the program. You will want to make sure that everything stays the same on the programming. Being able to reuse code will make the process easier overall for reading and writing the code. The fact that some are against it gets to me. I find easier is better all the way around, specially when writing code, which is a hard enough process without adding more work on yourself.

B)

I think that I would have to be on board with Method Overloading. It does seem to be way more efficient and saves a lot of work by allowing you to write less code. Less code mean less time consuming keyboard use and squinting eyes. The downside of this is that everyone needs to know the naming functions of each method to alleviate bugs and repeated naming (causing errors in the code or glitches/bugs).

Explanation / Answer

1)

Using method overloading

we can develop more than one function with the same name

Overloaded methods are methods in the same class that share the same name but accept different variable types as arguments. For example, a class may contain two different "add" methods: one that accepts two double values, "add(double a, double b)," and one that accepts two integer values, "add(int a, int b)." The computer automatically decides which method to call at run-time based on the variable types being passed to the method. Function overloading is done for code reuseability, to save efforts, and also to save memory.

2)

You may have a function that takes some number of arguments. The last few arguments may not be all that important, and most users would be annoyed in having to figure out what to pass into them. So you create a few more methods with the same name and fewer arguments, which call through to the “master” method. I’ve seen cases where we have five different versions of a method with varying numbers of arguments.

So how do I propose people deal with this situation without overloading? It turns out to be a solved problem: default arguments. We are (probably) going to support these in the Diamond release of GScript:

function emailSomeone( address:String, subject:String, body:String,
cc:String=null, logToServer:boolean=false,
html:boolean = false ) {
// a very well done implementation
}
A much cleaner solution. One method, with obvious syntax and, if your IDE is any good, it will let you know what the default values of the option arguments are (unlike method overloading.)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote