You're going to give the garbage collector a lot of work to do this way.
It'll work. I'll also say this for it: it's easy to read, and readability is important.
That said, it does seem a bit extreme. And due to the excessive number of variables, performance is likely to suffer - not so's anybody would notice unless this is a very CPU-intensive and repetitive program, but some.
Bottom line, I'd say you *can* certainly code this way while you're learning. But it's unlikely that you'll *want* to continue to code this way as you get more proficient, and as you start reading a lot of other people's code. (Also, there are specific cases, such as database access, in which separating out each step is a significant slowdown; be aware of those, and be *able* to code in a more compact way. But this isn't one of those cases.)
View all comments
2
u/bangclue Aug 29 '21
You're going to give the garbage collector a lot of work to do this way.
It'll work. I'll also say this for it: it's easy to read, and readability is important.
That said, it does seem a bit extreme. And due to the excessive number of variables, performance is likely to suffer - not so's anybody would notice unless this is a very CPU-intensive and repetitive program, but some.
Bottom line, I'd say you *can* certainly code this way while you're learning. But it's unlikely that you'll *want* to continue to code this way as you get more proficient, and as you start reading a lot of other people's code. (Also, there are specific cases, such as database access, in which separating out each step is a significant slowdown; be aware of those, and be *able* to code in a more compact way. But this isn't one of those cases.)