How Can I be More Disciplined in My Coding Projects?

0
18
Asked By CreativeCoder87 On

I've been learning Python and I'm currently working on a project to boost my CV. However, I find myself rewriting my code constantly as I code, rethinking its structure. For example, I might put something into a class or define a new function only to realize later that it's only used once. Is there a more disciplined approach I can take to avoid wasting time on this? I've tried outlining a structure on paper first, but new ideas come up while I'm coding. Are there resources that provide guidance on improving project structure in advance, or tools for creating a solid roadmap? Autocomplete features in VS Code also distract me easily.

4 Answers

Answered By RefactorRanger On

Yes, there’s a disciplined way to handle this. Hold off on extracting functions or classes until you see actual duplicate code or data that needs clean-up. This way, you’re making changes based on clear needs rather than whims.

Answered By PlanItBetter On

Shift your focus toward planning before you dive into coding. Create a requirement specification document that outlines all the cases and features you want to include. This preparation can help you anticipate edge cases and necessary functionalities without getting caught in the coding loop of continuous rewrites.

Answered By CodeCrafter42 On

Don't stress too much about the impulse to refactor while coding. It’s totally normal! As you gain more coding experience, you’ll develop a better intuition for structuring your code. Remember, every time you refactor is a chance to learn. It might feel like you're redoing things now, but with time, you’ll find you’re refactoring less frequently in future projects.

Answered By DevGuru99 On

Instead of trying to fix everything on the spot, consider using TODO comments for ideas that can wait. For instance, if you think something should be refactored, just jot it down with a comment like `// TODO: refactor` near your code. This way, you can come back to it later without getting sidetracked from your current progress. Many editors highlight TODOs making them easy to find later.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.