Skip to main content
Software Engineering

Questions tagged [parameters]

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.

Filter by
Sorted by
Tagged with
0 votes
2 answers
133 views

Is it better to pass a specific "context" object to handlers rather than the entire domain object?

I’m designing a system where various "handlers" apply business rules to an object. Initially I had each handler receive the full domain object: // A large domain object with many properties and ...
10 votes
7 answers
3k views

Is it an anti-pattern to support different parameter types when using a dynamically-typed language?

In the Python code base we inherited there are several functions that check parameter types and try to "accommodate" different types. Example: def process_data(arg): json_ = {} if ...
7 votes
8 answers
901 views

Why is "one function do more than one thing" a disadvantage of "boolean parameter", but not in "polymorphism"?

According to Is it wrong to use a boolean parameter to determine behavior?, I know using boolean parameters to decide the behaviour is bad, for example, when using boolean parameters as the following: ...
3 votes
5 answers
761 views

Why is "dependency injection" ok, but not "the opposite of preserve whole object (pass required parameters only)"?

According to Why should I use dependency injection?, "dependency injection" has some advantages, for example: "Non dependency injection" version: public class Client{ private ...
12 votes
5 answers
4k views

Why is "hidden dependency" (required things not in parameter list directly) a disadvantage of "global variables", but not in "preserve whole object"?

According to https://softwareengineering.stackexchange.com/a/200092, as I know, "preserve whole object" is a refactor method that passes the whole object instead of required parameters only, ...
7 votes
8 answers
5k views

Is "avoid extra null pointer risk" a reason to avoid "introduce parameter objects"?

According to Should we avoid custom objects as parameters?, I know I can group related parameters to improve readability of the function, eg: Original version: public void showSchedule(long startDate,...
17 votes
8 answers
5k views

When should a function be given an argument vs getting the data itself?

When is it better to pass data to a function in a parameter, and when is it better for the function to just fetch the data itself? Here's some simplified examples in PowerShell: Option 1 (give the ...
0 votes
1 answer
219 views

Elegant way in C to store many parameters with default value and current value in embedded flash

I'm programming an embedded system that has a number of user configurable parameters, which are stored in flash memory. I have to store a default value for each parameter as well as the user settings. ...
0 votes
1 answer
163 views

Should I "introduce parameter object" for the case that the parameter is originally already a whole object?

According to Should we avoid custom objects as parameters?, for example, if I have an object to show: public class Student{ public int _id; public String name; public int age; public ...
0 votes
3 answers
240 views

Is "the boolean value is from dynamic loaded data (eg:user input, database)" a reason to use boolean parameter?

I know there are some questions about boolean flags: Is it wrong to use a boolean parameter to determine behavior?, Multiple boolean arguments - why is it bad? which indicates the following code is ...
1 vote
2 answers
753 views

For more than one parameter, when NOT to introduce parameter object?

I know there are some questions about "Introduce parameter object", eg: Is "Introduce Parameter Object" actually a good pattern?, Should we avoid custom objects as parameters?, ...
0 votes
1 answer
112 views

Why aren't mandatory options requested in the signature of ASP.NET Core "AddXXX" methods?

I've developing a .NET Core library meant to simplify the configuration of the authentication within our SSO system. It will expose two methods to be called in the Program.cs (or Startup.cs) of ASP....
4 votes
2 answers
3k views

Should a method modifying object passed as a parameter return the modified object? [duplicate]

I have some incoming request - it's an instance of class generated from api specification - POJO with public getters/setters. I would like to normalize some values. For example dimensions (to use ...
1 vote
2 answers
1k views

Ordering keyword arguments in a function call

In some languages such as Python, the order of keyword arguments in function calls does not matter. But is there a best practice for it? For instance, suppose that a function's signature is def foo(...
10 votes
8 answers
4k views

What is the purpose of enclosing all return values and arguments of a method in separate classes?

I've seen such a convention. Whenever a public method is declared, two classes are also defined that enclose its return value and parameters like this: public MethodNameReturnDTO MethodName(...

15 30 50 per page
1
2 3 4 5
...
11

AltStyle によって変換されたページ (->オリジナル) /