Linked Questions

3 votes
6 answers
9k views

Setters or constructor for many variables? [duplicate]

Possible Duplicate: Are there guidelines on how many parameters a function should accept? I have got class with 30 variables (it is an application form), so I wonder what is the best practice to ...
user avatar
  • 201
3 votes
0 answers
533 views

Function that has too many parameters [duplicate]

I'm a junior developer learning programming in Python. I found that some of functions I write uses too many parameter, like def f(a,b,c,d,e,g,h): What would one recommend to avoid such a situations? ...
user avatar
-1 votes
1 answer
166 views

Is it common to have a constructor with 7 elements for example? [duplicate]

Is it common to have a constructor with 7 elements for example? or is it better to use many setters instead?
user avatar
  • 115
23 votes
6 answers
10k views

Is readability a valid reason to not use const in (reference) parameters?

When writing some functions, I found a const keyword in parameters like this: void MyClass::myFunction(const MyObject& obj,const string& s1,const string& s2,const string& s3){ } ...
user avatar
  • 5,705
16 votes
4 answers
6k views

Single method with many parameters vs many methods that must be called in order

I have some raw data I need to do many things to (shift it, rotate it, scale it along certain axis, rotate it to a final position) and I am not sure what the best way to do this to maintain code ...
user avatar
16 votes
4 answers
12k views

Techniques for minimising number of function arguments

In Clean Code, it is written that "the ideal number of arguments for a function is zero". The reasons why are explained and make sense. What I'm after is techniques to refactor methods with 4 or more ...
user avatar
9 votes
2 answers
3k views

Is "too many parameters" a visual or a logical issue?

according to Are there guidelines on how many parameters a function should accept?, a method should not have too many parameters. However, some answers suggest this issue can be solved by builder ...
user avatar
  • 5,592
5 votes
2 answers
609 views

Function that requires many parameters

I have a problem related to this: Are there guidelines on how many parameters a function should accept? In my case, I have a function that describes a rounded rectangle. The caller specifies An ...
user avatar
2 votes
4 answers
291 views

Options for constructing an object that is not logically initialized until all fields are set

I am working on a Pokemon game at the moment, and am running into some design concerns. The easiest example is as follows: Each Species of Pokemon has several traits that are required before it is ...
user avatar
  • 2,341
0 votes
2 answers
98 views

Inside a non-static non-virtual method, if it just use a few non-static members, should I turn it into static methods with parameters?

According to Are there guidelines on how many parameters a function should accept?, it is ok for a method to have few parameters. According to https://stackoverflow.com/questions/11240178/what-is-...
user avatar
  • 5,592