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 readability. On one hand, I can make a single method with many parameters (10+) to do what I need, but this is a code reading nightmare. On the other hand, I could make multiple methods with 1-3 parameters each, but these methods would need to be called in a very specific order to get the correct result. I have read that it is best for methods to do one thing and do it well, but it seems like having many methods that need to be called in order opens up code for hard-to-find bugs.
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 readability. On one hand, I can make a single method with many parameters (10+) to do what I need, but this is a code reading nightmare. On the other hand, I could make multiple methods with 1-3 parameters each, but these methods would need to be called in a very specific order to get the correct result. I have read that it is best for methods to do one thing and do it well, but it seems like having many methods that need to be called in order opens up code for hard-to-find bugs.
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 readability. On one hand, I can make a single method with many parameters (10+) to do what I need, but this is a code reading nightmare. On the other hand, I could make multiple methods with 1-3 parameters each, but these methods would need to be called in a very specific order to get the correct result. I have read that it is best for methods to do one thing and do it well, but it seems like having many methods that need to be called in order opens up code for hard-to-find bugs.
Source file shouldn’t be more than 100 SLOC [closed]
Closed 9 years ago.
When designing a directory structure should filenames include folder names?
Suppose I have two directories: house-1
and house-2
. Each house directory needs to have files describing its windows and doors.
Assigning to fields in function or by function?
While writing the constructor for class A
in Python, I calculate some of the class’s fields using function fun()
. This function is never used outside the constructor of instances of this class.
In situations like these, I tend to write fun()
so that it returns the desired values and then I assign these values in the initialization, like so:
How can I reorganize others’ code shared in source control repository, just for my own purpose?
When several persons work together on a project shared in repositories in github, it happens quite often that I feel that someone else’s code is hard to read, and want to change and reorganize his code and add more comments.
It is for improving readability just for my own purpose, and I don’t want to ask others to change their code in the same way that I change it.