|
https://www.hackingwithswift.com/quick-start/beginners/checkpoint-6 I missed a week from being out sick but am back and ready to go. Just finished my Checkpoint 6 and am looking for critiques and pointers, even if its over code style, etc. Any tips appreciated!
Thinking about code style, do you normally put initializers before methods, or after? I'm thinking it would be... properties initializer methods ...since the initializer is ran before any methods can ever be run? Do people have a preference for code order here? |
|
@xan asks for critique:
The code below is fine. But I appreciate the comments. This shows that you understand that you don't understand the entire problem being solved. It's common that your customers will assume a great deal of you. Also some requirements lead to derived requirements. They're not specifially stated, but could be assumed to be requirements.
As you guessed, when a car is in gear, it is moving. So, no! Cars do not start in first gear, they start from a Also, you wrote this for changing gears:
It would be a Very Bad Idea™️ for your gear box to change from fifth gear directly to first gear. It would be a disaster to shift from fifth gear to reverse! There would be lots of broken gear teeth. So while it's legitimate to have a method to To be honest, this is out of scope for the intent of @twoStraw's challenge. But you were looking for any pointers, or comments. Also xan writes:
Consider using a first person voice 😜, often referred to as the active voice:
Keep Coding! |
|
@xan has code style question:
To be honest, I think this is typically a team decision. If you're late to a development effort, you'll be forced to use what ever the team initially decided, even if those team members have all left for other projects. You're stuck with their initial decisions. I've not written structs so complex that I've worried about where the Documentation MARKsI would add that if you're keen to maintain structure and readability, consider adding Like so:
This adds dividers into Xcode's pull down menu that shows properties and methods in a code file like Mini Map
TODOPlease note I added another MARK to your code snip: TODO. This doesn't add a divider. Instead it adds a tiny clipboard icon. It's a note to future you that something needs your attention. Hacking With Swift ArticleOf course @twoStraws already has an article about this. Grab a cuppa and give this a good read. See -> Code MARKs Your mileage may vary! |
SPONSORED Take the pain out of configuring and testing your paywalls. RevenueCat's Paywalls allow you to remotely configure your entire paywall view without any code changes or app updates.
Sponsor Hacking with Swift and reach the world's largest Swift community!
This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.
All interactions here are governed by our code of conduct.
Link copied to your pasteboard.