Parameters are important for any non trivial program, to help make it generic and data driven. Parameters are usually function arguments but can also be part of the configuration.

learn more… | top users | synonyms

3
votes
1answer
116 views

How full pass-by-name is implemented?

When you consider Scala and its pass-by-name you could (if I am not mistaken) pack the argument to lambda and pass it by value to the function. Internally the function would use pass-by-name parameter ...
2
votes
1answer
43 views

Does a message in a UML sequence diagram have parameters or arguments? [duplicate]

I recently took an exam for the introductory course on Computer Science. One question was about sequence diagrams (very simple example, boiled down to its essentials): The Bank object sends a ...
0
votes
2answers
122 views

Is it bad practice to verify arguments passed to a function? [duplicate]

I find myself writing a lot of functions whereby the first few lines "verify" the arguments, that is, they typecast, check falseness, range, etc. before doing any work. The main reasoning for this is ...
10
votes
2answers
517 views

Is it bad to create classes whose sole purpose is to be converted to another class implicitly?

Imagine a situation where we're using a library that allows you to create Circle objects, where you can specify the radius and the center of the circle to define it. However, for some reason, it also ...
-2
votes
2answers
88 views

Java Ellipses Signature for Multiple Parmeters

Firstly, I am studying function with new type of signature and body, and in this code, I want to know, what type of object is values? It doesn't appear to be an array of strings based on my ...
4
votes
2answers
62 views

Unused function parameters and polymorphism

I had a discussion with a co-worker about interface members having parameters that some implementations don't use. Say I have an interface interface IDoctor { string GetMedicalOpinion(Age age, ...
2
votes
2answers
198 views

In C++, why shouldn't all function parameters be references?

I am currently learning C++ from the C++ Primer 5th edition. The book's chapter on functions states that only large objects (large being relative as standard library strings count, but "primitive ...
46
votes
10answers
6k views

Should we avoid custom objects as parameters?

Suppose I have a custom object, Student: public class Student{ public int _id; public String name; public int age; public float score; } And a class, Window, that is used to show ...
0
votes
1answer
94 views

How to handle extra arguments in a JavaScript library?

JavaScript is the only language I've come aross which allows variable-length argument lists by default. A case where it would be helpful to detect too many arguments would be Mozilla's Add-On SDK's ...
5
votes
1answer
97 views

Clean code deep parameter pass

So Clean Code says you should separate each task to a single function (and add these functions a correct name). I like the idea, but I've faced this problem so far: you receive a parameter which you ...
0
votes
1answer
62 views

Execution of cmd over SSH

In my current architecture, I connect from my local script to a server in SSH, and execute a .sh script. The purpose of the script is to execute an SQL query and to output the result in a file. My ....
3
votes
1answer
68 views

Within an interface specified by a core component, should it request IReadOnlyCollection or IEnumerable?

In thinking about the principle of "be conservative in what you send and liberal in what you accept", I generally try to make my methods receive IEnumerable parameters, but emit a IReadOnlyCollection (...
22
votes
7answers
2k views

Specify optional parameter names even though not required?

Consider the following method: public List<Guid> ReturnEmployeeIds(bool includeManagement = false) { } And the following call: var ids = ReturnEmployeeIds(true); For a developer new to ...
124
votes
5answers
9k views

What are good habits for designing command line arguments?

While developing the application I started to wonder - How should I design command line arguments? A lot of programs are using formula like this -argument value or /argument value. Solution which ...
1
vote
2answers
151 views

Parameterization vs subclassing

Example taken from : Agile software development : principles, patterns and practices A new employee is added by the receipt of an AddEmp transaction. This transaction contains the employee's name, ...
3
votes
3answers
244 views

I want to overload a function with the same type parameter; what should I do?

I'm creating an API, and I want to overload a function for strip: QString MyClass::strip(); QString MyClass::strip(QRegularExpression open); QString MyClass::strip(QRegularExpression close); QString ...
2
votes
2answers
424 views

Is it good practice to have your C++/Qt functions always check all its arguments for null values?

Backstory While developing with Qt Signal/Slots, I came across a few segmentation faults that had me puzzled as to what was causing it. Eventually I figured out that you could actually pass a slot ...
0
votes
0answers
59 views

Specifying a default value for an optional anonymous function parameter in VB.NET

I'm considering a class that uses a generic type (though this isn't directly important to the question here) and allows the user to specify an optional "strategy" function when instantiating a class ...
0
votes
1answer
137 views

How to document **kwargs in python? [closed]

I have a function which has a large number of arguments. I want to have the names of the arguments available in the help() function, but I want the results as a dict. At the moment, I have the ...
-3
votes
1answer
197 views

Designing a programming language, seeking simple and logical parameter behavior [closed]

I am designing a programming language, and would want to make it as simple as possible, conforming to layman's logic. I've been using many programming languages, although the last few years I've been ...
7
votes
3answers
781 views

How to deal with constructors in large data classes [duplicate]

Several times now I have come across the situations where you have some kind of settings class that simply contains a mass of data. Often these classes are simply not valid without at least most of ...
4
votes
2answers
203 views

How to handle singular and plural parameters for functions

Often when I'm writing a set of utility functions, I find myself wanting a function that applies some logic to multiple items, as well as a function that does the same with just a single item. There ...
1
vote
4answers
139 views

When is an object passed to a function?

Trying to clearly state the semantics of a function call. In calling a function, are the arguments passed to the function the ones the calling code initially gives or the ones the function receives?...
2
votes
1answer
57 views

Should I be taking these as arguments or define them in a sub class?

So I am making a mario clone in pygame and I have a base class Character and two sub classes, Mario and Luigi. The methods that the Character class defines require a significant amount of attributes ...
0
votes
0answers
140 views

Should a SPA have a route URL visible in address bar?

I am developing a Angular SPA using angular-ui-route. We are in a confusion of should we have the route visible for User in the address bar or just have index.html (or home page) always ? Is there a ...
21
votes
6answers
3k views

Should a method be forgiving with the arguments that are passed in? [closed]

Suppose we have a method foo(String bar) that only operates on strings that meet certain criteria; for example, it must be lowercase, must not be empty or have only whitespace, and must match the ...
16
votes
4answers
2k views

Why does C# have both out and ref?

C# has the out and ref keywords. Why are these two required? Disclaimer: I don't have deep knowledge of C#.
2
votes
2answers
72 views

How to handle large number of configuration parameters across a program conceptually?

Imagine a software system where you have like 100 parameters, each of which is sensible to change (in my case this is a reasearch system for machine learning). The obvious solution is to store all ...
5
votes
2answers
292 views

Identifier vs domain object as a method parameter

Are there any objective arguments for or against using objects vs unique ID as method/function parameters? (and members of other objects?). Specially in the context of statically typed languages (C#/...
36
votes
2answers
2k views

Why do methods that take an unlimited amount of parameters often define overloads with fewer parameters?

For instance, the System.IO.Path.Combine method in .NET has the following overloads: Combine(params String[]) Combine(String, String) Combine(String, String, String) Combine(String, String, String, ...
4
votes
3answers
93 views

Sets of pair parameters

I have the following class, this class like many rely one parameters coming in as a pair. Originally for convenience, I set them as params Object[] values and check if there is an even number of them ...
2
votes
3answers
4k views

What is the difference between a variable and a parameter? [closed]

Its a conceptual question. But I would like to use the right term at the right place. That is why I would like to read some other views on this.
13
votes
3answers
782 views

What is the difference between ref and out in runtime?

C# provides the ref and the out keyword to make arguments to be passed by reference. The semantic of the two is very similar. The only difference is in the initialization of the flaged variable: ref ...
3
votes
2answers
153 views

Strategies for parameter wrapping

Methods with many parameters are often sometimes unavoidable. In my own experience I often find this is the case for program entry points and complex mathematical procedures - where refactoring is ...
5
votes
1answer
88 views

Should I use exceptions to control the range of parameters in Python?

For example for the following method signature: def genClusters(n_clusters, n_nodes, cluster_distribution): n_clusters should be an integer of more than 1. n_nodes should be an integer of more ...
0
votes
3answers
308 views

Understanding the concept of “arguments” and “parameters”

In the third last paragraph at page number 26 of the ebook "The C Programming Language" the author(s) say, "We will generally use parameter for a variable named in the parenthesized list in a ...
1
vote
1answer
517 views

OOP best practice: Optional referenced-type paremeter

I know in C#, by default, referenced type variables are passed by reference to a method. I have a function which sometimes I just need its return value and sometimes both return value and the changes ...
6
votes
3answers
667 views

Passing parameters that need to be copied by value or const reference

I have a basic (mathematical) vector class, which in my opinion benefits from C++'s operator overloading. Vector-scalar operations are defined as self-modifying functions in the class itself, class ...
4
votes
3answers
9k views

Best OOP Practice in C#: Passing the Object as Parameter VS Creating a New Instance of the Object

First of all, I would like to know if passing an object as parameter is much better than creating another object again in a class that will use it again and second what are the pros and cons of each ...
38
votes
9answers
6k views

Should I accept empty collections in my methods that iterate over them?

I have a method where all logic is performed inside a foreach loop that iterates over the method's parameter: public IEnumerable<TransformedNode> TransformNodes(IEnumerable<Node> nodes) { ...
3
votes
2answers
263 views

Defensive copy in the client class or in the service class?

I have one service method that receive parameters as a Map. I will need to add new attributes to this map inside the service. If I pass the original Map object to the parameter instead of a copy, the ...
0
votes
1answer
147 views

Method Parameters Ordering [closed]

I was recently changing a method to add in an additional parameter, and I couldn't help but wonder if there were "best practices" or "generally accepted rules" in deciding what order parameters of a ...
0
votes
2answers
138 views

Is there a way for Object 1 to call Object 2's enums in a function call?

For example, if I have two classes "Director" and "Follower". I want the Director to tell the follower where to go (ex: follower1.go(direction.LEFT)), and I want the Director to know what directions ...
2
votes
3answers
124 views

Is there a name for the technique of converting method parameters into a unified form to simplify further processing? [closed]

When working with methods which accept a parameter in various forms (e.g. nil, a single string, a single string containing multiple data or an array of strings) I tend to unify them - splitting, ...
3
votes
4answers
381 views

Is a long list of parameter checks an anti-pattern?

Background: I'm working on an application that will manage backup generators. These generators need to be able to be "linked" together. For example, Generator B might serve as a backup for ...
14
votes
7answers
3k views

Function only returns unchanged parameter, useless?

I just found this function in the project I'm working at: -- Just returns the text unchanged. -- Note: <text> may be nil, function must return nil in that case! function Widget:wtr(text) ...
3
votes
2answers
214 views

Should I throw guard exceptions that will be thrown by internal methods anyway? [duplicate]

I have some fairly simple code (C#): /// <summary> /// Truncates a string to a maximum length. /// </summary> /// <param name="value"> The string to truncate. &...
3
votes
2answers
451 views

Parameterized Java Types (Generics)

Consider this "legacy" code: public interface IPersistentCollection { IPersistentCollection cons(Object o); } Genericized in Java, it could become something like this: public interface ...
0
votes
1answer
374 views

Good practice to pass this information through URL parameter

Basically, let's suppose an application that manage some user's meetings. I have a filtering zone on a page that aims to specify the category of items I need to specifically return. ...
1
vote
1answer
128 views

Replaceable parameter syntax meaning

Replaceable parameter syntax for the console object in C#. I am taking the O'Reilly C# Course 1 and it is asking for a replaceable parameter syntax and it is not very clear on what that means. ...