Timeline for How can Guard Statements and Small Functions coexist?
Current License: CC BY-SA 3.0
15 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jun 11, 2015 at 11:40 | vote | accept | Lifeweaver | ||
Jun 10, 2015 at 14:22 | answer | added | Arseni Mourzenko | timeline score: 2 | |
Jun 10, 2015 at 14:22 | answer | added | Daenyth | timeline score: 0 | |
Jun 10, 2015 at 13:58 | answer | added | gnasher729 | timeline score: 0 | |
Jun 10, 2015 at 11:10 | history | reopened |
Telastyn Michael Shaw yannis |
||
Jun 9, 2015 at 12:14 | review | Reopen votes | |||
Jun 10, 2015 at 11:10 | |||||
Jun 9, 2015 at 12:05 | comment | added | rwong |
Recently I start using this coding style: converting those guard statements into "single line conditionals" as mentioned in Telastyn's answer. Example: ThrowIfBitmapNotGray8(bitmap) , which subsequently calls ThrowIfBitmapNull(bitmap) . In some cases, one can reduce the number of guard clauses down to one per argument, which I think is the minimum possible. Remember that there are other meaningful validations other than null checks.
|
|
Jun 9, 2015 at 11:57 | history | edited | Lifeweaver | CC BY-SA 3.0 |
Expanded on the quest with more detail.
|
Jun 8, 2015 at 21:25 | review | Reopen votes | |||
Jun 8, 2015 at 22:09 | |||||
Jun 8, 2015 at 20:16 | history | closed |
whatsisname Mike Nakis enderland Mason Wheeler Eric King |
Needs details or clarity | |
Jun 8, 2015 at 20:11 | answer | added | Telastyn | timeline score: 3 | |
Jun 8, 2015 at 20:05 | comment | added | Justin Cave | Trivially, including guard statements increases the size of a method. Whether that makes something "not small" depends on your definition of "small" and how many guard functions you need. If you find yourself needing dozens of guard statements, I would tend to expect that something is wrong with your design. If you have repetitive code in your guard statements, you can obviously factor that out as well. | |
Jun 8, 2015 at 20:02 | review | First posts | |||
Jun 8, 2015 at 20:19 | |||||
Jun 8, 2015 at 20:01 | comment | added | cmaster - reinstate monica | And what is the question? | |
Jun 8, 2015 at 19:58 | history | asked | Lifeweaver | CC BY-SA 3.0 |