4 ms·
That makes sense when the function has two arguments With more arguments the function call is hard to read countDominoTilings(4, 7), what is 4, what is 7? So
by benibela 4y ago
That makes sense when the function has two arguments
With more arguments the function call is hard to read
countDominoTilings(4, 7), what is 4, what is 7?
Some languages have named parameters. Then you can write
countDominoTilings(width = 4, height = 7), which is very readable.
But without named parameters,
DominoTilingCounter tc;
tc.width = 4;
tc.height = 7;
tc.count()
would be more readable
- Zababa 4y agoEvery IDE I've used would show you the name of parameters when you hover the function. These days there are even inlay hints that will transform countDominoTiling(4, 7) to countDominoTiling(width: 4, height: 7). Another option would also be to just pass a struct: struct dimensions dim = { .width = 4, .height = 7}; countDominoTiling(dim); My C++ is rusty so this might not compile but you get the idea. There isn't a big difference with just one simple thing, but when you're having 10 of these things, with some classes having classes in themselves, it quickly becomes a mess.