At the moment I'm spending more time planning out a commit than actually writing code when adding a new feature. Less than two hours would be lucky, and sometimes I'd spend a good part of the day without writing any code. This is making me unhappy, since I don't feel I'm productive enough (I'm living with my parents, and have never been employed as a programmer).
If I don't do this amount of planning, I just end up writing code that will have to be undone before I commit, and this just messes up my project, because I don't like wasting any code I've already written and try to recycle it as much as possible (my precious).
Someone said that programming isn't about how fast you can type; it's about how fast you can think. I'm not very good at thinking fast.
I think I'm overly cautious making my productivity not economically viable, but even still its far too easy for me to waste a whole lot of time making a mess of my codebase.
Travis asked
Can you explain what you mean by "planning out a commit"?
I guess there's the time spent architecting, i.e., planning out the object hierarchy, which thread will do the work, GPU or CPU, planning polymorphism for m to n relationships, and which asynchronous pattern should I use.
Then there are implementation details and parameter choice for scientific computations. I like to think about how I could iterate, so if I get a bad result it is rectifiable.
Breaking down a feature into a series of behaviours, which you can verify correctness at each step. I suppose I think about how to verify correctness of intermediate steps a lot before I've even started.
Why does the code you write have to be undone before you commit?
Well, it's easy to write code that's unmaintainable, and difficult to debug. So I have to backtrack and write something more structured. I also sometimes overlook some detail that makes my first attempt not viable.
"Planning commits" is just what I came up with to communicate when you've finished one feature and are moving on to the next (obviously committing your changes first). You've got no Git changes and haven't yet written any code committing you down one path.
There's one big commit that gets the scaffold in place and need lots of planning, and followed by a couple of smaller ones that don't need any planning. So maybe the commits in question are more like new branches. (It's just that I don't use Git branches.)
Firstly: when coding for a living, especially as a junior in a team, typically not much design work is needed. This is because you'll be working in an existing code base. Chances are, you'll often be working on a feature that is similar to existing features, so you can look at those as an example. This is nowhere near as boring as it may sound; you'll be learning plenty of things, still need to understand the examples and adapt them to suit your needs.
Designing something new can indeed be much harder, but it is also much rarer, especially when you're a junior developer.
That is to say: in a typical junior-level development job, I don't think you'll run into the things you're worried about. Or at least to a far smaller extent.
If I don't do this amount of planning, I just end up writing code that will have to be undone
I would argue that for most developers, this is fairly normal, if they are developing something that is novel (to them and their existing code base).
I do that planning sometimes, and when I start writing the code, I often realise that the plan translates to an awkward implementation that feels forced or over-engineered.
... which is good to know! Coding provides feedback on the plan.
Planning and coding are very much iterative processes. You plan a bit, try to create some code with the planning in mind, which makes you realise that you overlooked something during planning, so you adjust the plan, code some more, rinse, repeat.
I like to think that this is also how artists work. It's a creative journey. Often messy, sometimes boring, sometimes exhilarating, sometimes frustrating. Sometimes you end up with something boring that just works, sometimes with something beautiful that doesn't work. And, every now and then, with something that works and is beautifully elegant.
[I] don't like wasting any code I've already written and try to recycle it as much as possible (my precious).
Throwing code away is fine! The code has already served a useful purpose: it provided feedback on the planning. It helped you iterate.
Someone said that programming isn't about how fast you can type, it's about how fast you can think. I'm not very good at thinking fast.
Neither are most people, especially if they have to do the thinking without seeing any code. Coding helps to make things concrete. It may also obfuscate the bigger picture, so zooming in (code) and out (planning) is part of the iterative process.
It's also worth noting that people, after years of professional experience, develop a kind of muscle memory for specific approaches, and an instinct for applying these. Which is half the battle when making something new. You cannot be expected to have that already (nor should you expect it from yourself).
Put differently, the examples in existing code bases that I mentioned at the top of this answer are in their heads now, and they can apply them in new projects as well.
I think I'm overly cautious making my productivity not economically viable, but even still its far too easy for me to waste a whole lot of time making a mess of my codebase.
I think you're being too hard on yourself (I can relate). Try to change your mindset to allow the iterative process, to embrace the creative journey.
And code that just works (and is readable) is good enough. If later on, new requirements or new features means that the code is no longer good enough, you can adjust it. That adjustability is the reason the world moved away from specialised hardware and embraced software (running on generic hardware).
Edit:
Also, small steps are good, and focussing on making it work first, and only then making it right is also good. If you already have working code, the planning gets easier because there are fewer unknowns an hypotheticals. Relevant quote is relevant:
First make it work, then make it right Kent Beck
in the smallest steps you can manage. Uncle Bob Martin
(source)
As always, everything is more nuanced in practice, and I don't completely let go of design when focussing on making it work.
similar to existing features, so you can look at those as an example
- yes and no. It can be very useful and it is good to use same patterns in the same project. But often times these examples are just very outdated. So watch out. — Aug 08, 2022 at 12:47 External links referenced by this document: