|
|
|
|
|
by pouyathe
143 days ago
|
|
Thank you for the kind words and the specific, actionable feedback. You've pinpointed the exact issue - it's option (b). I developed a personal style coding in isolation and didn't learn conventional formatting. The "else if on separate lines" pattern became a habit that snowballed into that brace nesting. I'm fixing it now. You're absolutely right that it will be much more maintainable. The "brilliant 17 year old" comment means a lot. I'm learning that part of brilliance is knowing when to follow established patterns. Thank you for the mentorship through critique. The cleanup starts today. |
|
D is a good language. You chose well. Walter Bright would be happy to see what you're doing here.
If you're not using version control yet, now's a good time to start, as it will help with the cleanup work. Fossil is my favorite as it's easier to use than git, but whatever you like is fine. More people use git than fossil so it's good to learn it and master it. It's very easy to introduce some kind of subtle bug in situations like this, but with version control you can check carefully after each change to make sure the code still works properly, and if not, easily see the problem and fix it or revert and try again.
clang-format would be the perfect tool for this also, even though it's not designed to work on D. The language is close enough to C++ in syntax that it should do the job, at least helping you get rid of the brackets in one go without screwing anything up too much. I recommend basing your styling on the "Microsoft" preset and customizing from there. That's also known as the "Allman" style, with the brackets starting on their own lines. With the brackets lined up like this it helps to see where code blocks begin and end. But you can use whatever style you like of course, just experiment and see what looks good to you.
Ultimately it comes down to just Doing the Right Thing. Sometimes that's the same as following established patterns, and sometimes it means breaking them. As you gain more experience you'll figure it out.
I think HN lets you post the same link once a month, so spend a while cleaning it up good and making it look as pretty as you can, then post it up again next month, on a Friday or Saturday to get more eyes on it. Send me the link when you do and I'll have another look. Here's my email:
domain: killthe.net
name: dave
Here's a good clang-format config file to get you started:
http://killthe.net/clang-format
Use it like this, from your source directory.
Just make sure to have a backup copy first, or version control, before running that command as it might screw things up.