4 ms·
One middleground option if you have a long function but also want to break it into chucks for easy readability: In C# and some other languages you can put brace
by Nition 7y ago
One middleground option if you have a long function but also want to break it into chucks for easy readability: In C# and some other languages you can put braces around a block of code without actually having any condition on it.
Or just throw some big comment headers in.
- skohan 7y agoIn Swift I use locally-scoped functions for this. It has the advantage of ensuring that this single-use function can't be called from outside the intended scope, but I can still chunk the work into easy-to-reason-about pieces.
- Nition 7y agoC# has those now also: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/local-functions https://docs.microsoft.com/en-us/dotnet/csharp/programming-g...
- aptwebapps 7y agoVS Code has regions, which look like preprocessor instructions but I don't think they actually have any affect on the code. They do, however collapse while providing a nice label.
- scns 7y agoJetbrains IDEs have those too
- aptwebapps 7y agoThanks, I've been using PyCharm for years and didn't know that.