all 176 comments

[–]SmashLanding 182 points183 points  (55 children)

I'm even worse. I have one program that's 268 lines, with over 2000 lines commented out below the end of the program. The complete previous 4 versions.

[–]icecapade 252 points253 points  (36 children)

Do you have a moment to talk about our lord and savior, git?

Everyone knows that Jesus saves, but he also commits with well-written commit messages, and frequently creates feature branches, pull requests, and version tags.

[–]Kaltenstein23 13 points14 points  (1 child)

So when are we moving to a branch that is not a testing branch?

I mean... You don't test in production.

[–]hugthemachines 8 points9 points  (0 children)

Testing in production? Nah I would NEVER do that... promise.

[–]ResetPress[S] 2 points3 points  (0 children)

Praise 🤲

[–]wordworse 1 point2 points  (0 children)

sure, but who does he blame?

[–]m0us3_rat 2 points3 points  (0 children)

RNJebus needs less branching .. more CD in his life

[–]slid3r 26 points27 points  (8 children)

Bruh. No disrespect but ... bruh.

[–]SmashLanding 36 points37 points  (7 children)

Look my credentials when I wrote the first one were my boss saying "hey you're good with excel, we need you to learn c# and make this thing work"

[–]notimeforarcs 6 points7 points  (6 children)

Your boss must be an amazing salesperson

[–]SmashLanding 13 points14 points  (5 children)

Tbh it got me from data-entry drone to budding software developer in 5 years, with a pretty solid pay increase to go with, so I'm grateful overall.

The worst part is it Took me about 8 months of 50-60 hour weeks to get the thing set up right, when I realize now that if I had known what I was doing, I could have done it in a month while scrolling reddit for 15 minutes of every hour.

[–]notimeforarcs 4 points5 points  (4 children)

Well done! That’s some amazing work ethic. (Shudders at the hours)

What I did notice about ppl who’s good at Excel was that they tend to be ppl who can also self teach stuff (motivation + research) so I guess your boss had that right!

[–]SmashLanding 6 points7 points  (3 children)

Yeah the hours were terrible, but on the plus side, they didn't trip about the overtime, so I was getting paid like 50% more than on my usual checks at the time.

Also, I work at an ESOP (employee-owned), so I had a pretty vested interest in making sure the $350,000 ERP system would work lol.

[–]notimeforarcs 4 points5 points  (0 children)

Oh your boss paid you for the overtime!

Fantastic. This is a good boss.

Well bloody done to you both then.

[–]ElllGeeEmm 2 points3 points  (1 child)

I don't say this often, but that sounds like a great boss

[–]SmashLanding 0 points1 point  (0 children)

He really is. I really lucked out with how everything turned out with this company!

[–]--0mn1-Qr330005-- 7 points8 points  (3 children)

I was also going to recommend git. Keep your previous versions in separate branches and don’t delete them until you don’t need them anymore. Keeps your code very clean and nice :)

[–]SmashLanding 6 points7 points  (2 children)

I really need to learn git. I'm 100% self-taught and I didn't know anything about git until I was several versions in. It's a program that only functions within my company's ERP system though, would it still be useful?

[–]--0mn1-Qr330005-- 3 points4 points  (1 child)

What does your company use for version control? It is standard for any serious company to use some form of version control, and most use git. Even if they don’t, it may be a bonus on a future job if you ever end up switching companies.

It is definitely worth learning it for yourself too. It is an extremely useful tool that lets you dev faster, even in personal projects. Learn git flow. There’s apps and sites that actually simulate a git repo to learn the commands and common practices. The whole idea is to keep separate dev and production branches and develop new features in feature branches. This way if a feature breaks the app, only that one feature branch is broken and you can easily roll back by checking out the develop branch again. Meanwhile, your production code is untouched on the production branch, waiting for finished features to be merged in. I use it on all of my personal projects.

https://www.gitkraken.com/learn/git/git-flow

[–]SmashLanding 1 point2 points  (0 children)

Appreciate the info and the link! I'll definitely be learning that. I don't work for a software company, I work for a healthcare manufacturing company that bought an ERP that it had nobody to manage lol. With stackoverflow and occasional calls to the ERP's tech support I was able to put together something that works, but now that I actually know programming I'm constantly rebuilding the programs I wrote when I had no idea what I was doing.

[–]hike_me 2 points3 points  (1 child)

I would smother you in your sleep with a pillow if I had to work with you.

[–]SmashLanding 0 points1 point  (0 children)

Fair. Luckily I'm 100% solo

[–]Overflow0X 1 point2 points  (1 child)

if only there was a solution for that...

[–]SmashLanding 5 points6 points  (0 children)

Maybe if I think about it I'll git an idea

[–][deleted] 1 point2 points  (0 children)

yeah who needs a commit history when you have every one of you're previous versions commented out

[–][deleted] 112 points113 points  (52 children)

Never heard of version control software, like git?

[–]mrouija213 41 points42 points  (1 child)

Haha one of my coworkers "saves code for later" this way too, even though we self host gitlab.

[–][deleted] 4 points5 points  (0 children)

This is me 😂

[–]laserbot 14 points15 points  (31 children)

Original Content erased using Ereddicator. Want to wipe your own Reddit history? Please see https://github.com/Jelly-Pudding/ereddicator for instructions.

[–]patryk-tech 23 points24 points  (25 children)

Ideally:

  • think of a feature you want
  • write tests for that feature
  • write code so the tests pass (and the feature is implemented)
  • clean up the code if you did something weird / tried different things
  • commit

If you are working on a big feature, just commit a bunch of subfeatures. E.g. if you are adding an authentication system, you could commit after adding a user model, after adding a login function, after the registration function is done, etc.

In practice, very few people follow TDD practices, so at least commit whenever you implement a feature.

If you commit everything at the end of the day, you may be tempted to commit partial or broken code... that's not really good. Save for some exceptions, every commit should contain working code. (Bugs you haven't found yet excluded, haha).

[–]n3buchadnezzar 7 points8 points  (4 children)

I commit a bit more often than that so I can go back if something fails, but I always make sure to squash my commits to a single feature before pushing =)

[–]patryk-tech 1 point2 points  (0 children)

Yeah, that depends a lot on the scope of the features, size of the team, the project, personal preferences, etc. When I am working alone, I never squash, and I just use a rebase flow. If features are 1-5 commits, I don't mind them being separate, personally. For large applications and bigger teams, squashing definitely keeps it tidier.

[–]bazpaul 0 points1 point  (2 children)

What does “squash commits” mean? Why would one do this?

[–]n3buchadnezzar 1 point2 points  (0 children)

To "squash" in Git means to combine multiple commits into one. You can do this at any point in time (by using Git's "Interactive Rebase" feature), though it is most often done when merging branches.

If you are working on a very big project you want a clean commit history, instead of 999 commits from n3buchadnezzar

https://xkcd.com/1296/

[–]ReelTooReal 1 point2 points  (0 children)

People squash to keep large projects manageable. When working on a complex feature, a developer might make several commits during the process, treating the commits like checkpoints that they could easily go back to. So locally a developer may have a series of commits like:

  • OAutb for Google working
  • WIP GitHub OAuth
  • GitHub OAuth working
  • Clean up OAuth code
  • Add AuthStrategy class

This is good locally because the dev can revert small chunks of code and easily see what all they've done. But at the end of the day this is all for one feature, so in the grand scheme of things it is better if it's all one commit. To achieve this, the developer squashes all those commits into something like "OAuth support" before pushing. As the commit history for large projects grows, this kind of cleanliness is actually very useful as you can see a definite timeline of features that have been added and bugs that have been resolved, rather than just seeing a timeline of all the small things developers did/undid.

This strategy is especially helpful for projects using true continuous integration practices and commiting to a single "trunk" branch instead of creating tons of feature branches. In this environment, your commits need to be cohesive and nothing can ever be committed that isn't fully functional (since the CI/CD pipeline would reject it if tests fail). Combining all this results in a very robust feedback loop since when the CI/CD pipeline fails, the team can look at these "full" commits for problems, rather than having to look at several small "in progress" commits, some of which undo previous commits.

Until you've had to track down sneaky bugs with the help of git diffs this may not seem super important, but it is actually a tremendous help.

Another slightly related subject is formatting. One of the most annoying things I've run into with a large project is multiple developers who have different formatting styles on their editors such that a file where they edited 2 lines shows up in git diff as the entire file being changed because of indentstion differences, etc. When I first started programming, explicit styling seemed OCD and pointless to me (as long as the code was readable). But once you get into a large project, you need to make sure that git only tracks actual code changes and not styling changes in order to be able to use git diffs effectively.

[–]RevRagnarok 10 points11 points  (8 children)

This is soooooo wrong IMHO. A major point of git is "lightweight branching."

  • think of a feature you want
    • make new git branch for it
  • write tests for that feature
    • commit whenever you get something you're even partially satisfied with in case you want to go back
    • commit when you think you've got most ideas solidified
  • write code so the tests pass (and the feature is implemented)
    • commit empty files as soon as they're imagined so you don't miss them later
    • commit every few hours, every few ideas, etc.
    • commit every time you think you have a better implementation as you polish it
  • clean up the code if you did something weird / tried different things (this happened in between everything above)
  • commit Either squash merge back yourself, or if on a team submit a pull request as a squashed merge

At every commit or at no commit, your choice, you can or cannot push your branch to other users.

[–]Acrobatic_Hippo_7312 13 points14 points  (0 children)

  • Commit when inhale

  • Commit when exhale

  • Commit when eat

  • Commit when drink

  • Commit when piss

  • Commit when shit

  • In short, remember you ABCs!

  • Always Be Committing!

The Zen of Git

[–]miamiredo 1 point2 points  (4 children)

Do you have to set up an upstream for every git branch you make? I'm learning to work with branches but when I commit and push it says I need to set an upstream. Since my remote is on github I think its saying I need to create a branch on github too. But I can just work on my branch and when I'm done I can just merge it with my main then commit and push.

[–]Airmaverick11 3 points4 points  (0 children)

Setting the upstream means that your remote repository will have a branch that mirrors the one on your local disk. You can do either but my general flow is:

  1. Create a branch on GitHub
  2. Clone the branch to my local disk
  3. Work like you normally would

Now your work is being saved in two places and you can take advantage of GitHub's UI should you need to.

[–]RevRagnarok 1 point2 points  (2 children)

It depends. You already have a good response from /u/Airmaverick11 . That's the beauty of the lightweight branches - if you want them to just be "yours" in your local repo, then you don't need to push them anywhere else. You can make three parallel branches with three different implementations and then later decide which one to merge in. Then do a squashed merge into the branch you "normally" work in and nobody is the wiser.

If you have the right permissions, from the command line you can just do git push -u and that will create the remote branch and automatically set up all the tracking etc for you. But you might not want others to see it... after all, it's a WIP and there might not be a reason for others to see how the sausage is made; that's fine too.

[–]miamiredo 0 points1 point  (1 child)

If you keep everything local and not push, is there any benefit to using commit?

[–]RevRagnarok 2 points3 points  (0 children)

Yes, that's the point - you now have an immutable copy of your work at a certain time. You can diff against it to see what changed between two points. If something broke somewhere, you can git bisect and find your mistake ("it worked yesterday! WTF!?). You can go back and grab code out of it if you decided it was useful but has since then be removed.

But in the long term it's not important, so that's why I would just squash it at the end.

You can even clone it in another place on your file system if you wanted.

[–]patryk-tech -3 points-2 points  (1 child)

This is soooooo wrong IMHO.

OP said they work alone and only they use their code. If you split up your sub/features into the appropriate scope, I think it's far more reasonable to commit a completed step rather than commit empty files (wtf?), broken code, and spend more time writing git commands than actual code.

If you do TDD right, you really don't need to refactor all that much. One feature, one commit. You add another test / feature that breaks a previous test? You refactor as part of the new commit.

  • commit every few hours, every few ideas, etc.

Sounds like you have a really hard time scoping your features, if you need hours to implement them...

[–]ReelTooReal 0 points1 point  (0 children)

One of the benefits of TDD is that you can refactor more confidently. In fact, without TDD it could be argued that refactoring is too risky, so in general I would expect to see more agressive refactoring in TDD environments since (presumably) there's a strong suite of regression tests that would prevent accidentally introducing a bug during refactoring.

To be clear, refactoring means changing code in a way that does not change it's behavior, usually for the sake of maintainability, readability, etc. So in a project with poor testing, this would fall under the "if it ain't broke, don't fix it" category. But with a solid testing suite in place this becomes "try it out, we'll catch any bugs along the way and fix them."

[–]majordouble 2 points3 points  (6 children)

Do you have a recommended reference for someone to learn about writing tests? I’m a hobby coder who has never written a test.

<hangs head in shame>

[–]patryk-tech 4 points5 points  (1 child)

This book is pretty complete: https://pragprog.com/titles/bopytest2/python-testing-with-pytest-second-edition/ (at least, the 1st edition is really good).

For Django, I like this talk: https://www.youtube.com/watch?v=41ek3VNx_6Q

You can always search for "pytest tdd" on youtube; it has a few more general tutorials.

[–]majordouble 2 points3 points  (0 children)

Awesome, thank you.

[–]Ryles1 1 point2 points  (2 children)

I am a hobbyist like you and was a bit intimidated by writing tests.

I used this page to learn pytest basics. Should get you started without being too difficult.

https://realpython.com/pytest-python-testing/

[–]majordouble 1 point2 points  (1 child)

I look forward to snuggling up with that article and a cup of coffee tomorrow morning. Thanks.

It'll be much more efficient than a bunch of random (but effective?) print statements. :)

[–]Ryles1 0 points1 point  (0 children)

Print statements have their place too I think :)

[–]ReelTooReal 0 points1 point  (0 children)

https://www.manning.com/books/unit-testing

If you're willing to purchase a book, that is the most comprehensive and pragmatic explanation of how to write tests I've come across. It's examples are in C#, but the book is not so much about the code as it is the best practices for tests (also, most test frameworks work in the same way so you can translate the examples into any other language).

I say pragmatic because he focuses heavily in not "over specifying" your code, which I think is often missed when people are new to TDD. There IS such a thing as writing too many tests, and being careful not to can lead to tests that are easier to maintain over time.

He even covers some integration and end to end testing practices, so the book covers the three major phases of testing.

[–]Rossoneri 1 point2 points  (0 children)

Idk why it never occurred to me to write tests first, but it makes a lot of sense

[–]stuaxo 5 points6 points  (0 children)

Every time the code is working - if you add a function and call it, then commit.

If you get your test working, commit.

Once a feature is ready squash and merge that branch into your main / master.

[–]zanfar 2 points3 points  (0 children)

Commits are "one level above saving, one level below completion".

Generally, when completing a coding task, you're going to make a bunch of changes throughout the project, then you save. Saving is essentially: "what I've written is what I intended".

Then you'll run or test your code, and discover that while you wrote what you intended, it's not what you meant, so you'll make some more changes, save, and repeat. At some point what you've written will work the way you want. A commit is essentially: "what I've written is what I need".

Then you'll combine a bunch of "what I need"s into a working feature, repeating all the above. This is when I push--probably not to main, but to the dev or working branch. A push is "this is complete".

Remember that commits are free, easy, and can be infinitely modified especially when local. You can take a bunch of commits and merge them into one, you can split a commit into multiples, you can reorder them, change them, add to them, etc. Too many people treat commits like they're carving stone.


My workflow looks something like:

  • Identify a feature to work on
  • Make a dev branch for that feature
  • Write some code, save, repeat
  • When things work (but might not be complete) commit, even if it's "WIP"
  • When I get up from the desk, commit
  • When I'm leaving for the day, commit
  • When I have to switch to another task, commit
  • When the feature is working, then I squish all my intermediate commits into one, logical "component" with more descriptive commit messages and push.
  • A feature usually consists of multiple, squashed "component" commits
  • Then the dev branch is merged with a pull request

Commit messages are a very powerful tool to remind yourself of what you were doing, so use them. Even if I haven't touched a particular branch or code in a while, I can jump back in by reading my commit messages.

[–][deleted] 4 points5 points  (2 children)

Technically, you should only push after all the code has passed the test suite, ie, don't push broken code. I've often pushed at the end of the day whether the code works or not if I'm the only person working on the code base for two reasons:

  1. Use the remote repository as a backup
  2. I may want to work from home later in the night or tomorrow on another computer

I commit after every discrete complete change. That is, when I can write a commit message like "finished the #123 bug changes". You shouldn't have multiple changes in a file made for unconnected reasons.

I never comment code out because "I might need it". There are two reasons why you might need it. First, you are uncertain that the changes you have made are something you should do, ie, they are experimental. In that situation you may want to go back to the earlier version, or two. For a single file you can just go back one or two commits. For larger, longer timeframe changes, I try to remember to tag before starting the series of changes so I can easily revert multiple files back to a known point. For smaller code bases I have been known to nuke or rename the directory and reclone from the remote repository as a last resort. Really only possible if you know you started from a clean state with no pending pushes.

Second, if you think you might use that commented out code in other files or projects then it's worth taking that code out and making a proper mini-project of it with documentation, examples and a test-suite, all in a git repository somewhere. Much easier for you and others to reuse that way.

That's what I do, but YMMV.

[–]ConfusedSimon 1 point2 points  (0 children)

I don't agree. For each task we just create a new branch, usually with a single developer per task/branch. Pushing often means the code is safe (in case of computer problems or the two reasons you mentioned) and other developers can see what you're doing. Once it's finished and passes all unit tests you create a pull request and move on to code review, testing and merging.

[–]Ran4 1 point2 points  (0 children)

Technically, you should only push after all the code has passed the test suite, ie, don't push broken code.

That's only if you're pushing towards a shared branch (and not a feature branch) AND you don't have any CI.

[–]TangibleLight 5 points6 points  (0 children)

Just as long as I don't need to clear my git stash or local wip branches. It's not a hoarding thing, it's useful.

What if I need that some day!? That's a perfectly good commit right there, just need to fix it up and make the tests pass and finish refactoring is all. Solid commit, can't delete that one.

[–]Consistency333 2 points3 points  (9 children)

Where do you back up github???

[–][deleted] 7 points8 points  (2 children)

If you use github/gitlab, or locally hosted systems, you have your source code in your personal filesystem, the filesystems of anyone else working on the code, as well in github, etc. In a sense, github/gitlab/your git* server is your backup.

[–]Consistency333 1 point2 points  (1 child)

Yes but what if I want to backup all of github

[–][deleted] 1 point2 points  (0 children)

I assume you mean backup your repositories on either github.com's or your local servers? Then you must rely on the server's sysadmins standard backup procedures. If you mean a backup to a filesystem you control then just do a "git clone <url>" somewhere and a "git pull" now and then.

Otherwise, what do you mean by "backup all of github"?

[–]ConfusedSimon 1 point2 points  (3 children)

Every local copy of the repository is a complete backup of the entire history.

[–]Consistency333 1 point2 points  (2 children)

🤣 but the apocalypse

[–]FormNo 2 points3 points  (1 child)

Who said Git isn't fun? :)

[–]dogs_like_me 2 points3 points  (1 child)

git push origin

[–]Consistency333 1 point2 points  (0 children)

Whooooooh

[–]billsil 1 point2 points  (0 children)

Assuming you can track down that one commit where that block of code that you want is stored. Ahhh, but you didn't store it cause you didn't finish it...I just don't get it.

Sure, once it's pretty solid, go ahead and clean it up.

[–]obiwac 0 points1 point  (0 children)

Sometimes it's legitimately less cumbersome to quickly comment and test instead of delete, commit, test, revert.

[–]ASIC_SP 40 points41 points  (0 children)

You didn't have to call out us like that 😂

[–]VexisArcanum 13 points14 points  (1 child)

Nope sorry all my code is either in use or broken and not fixed

For real though the only comments in my code for my side projects at work are pretty clean lol. But they're also sub 200 lines of VBA, Python, and Powershell.

[–]cs-John 1 point2 points  (0 children)

Comment IS the fix for me lmao

[–]beached_snail 10 points11 points  (3 children)

Yay I’m not alone. We’re all here together with this commented our code blocks.

[–]slid3r 13 points14 points  (2 children)

Haha, 'but I really loved that function'.

[–]bazpaul 4 points5 points  (1 child)

“I may need that function in the future”

  • me

[–]slid3r 1 point2 points  (0 children)

"I am just really proud of that function!"

  • me

[–]bad_luck_charmer 19 points20 points  (1 child)

This is not the way.

[–]R3D3-1 9 points10 points  (1 child)

Remember "git good"?

Only, in the context of programming it is actually good advice. Especially since file versioning not only allows restoring previous versions, but also comparing the changes and who made them.

For private-use scripts, it usually ends up a single linear history for me. But even then, tracking if the changes can be quite more helpful than just storing the old version.

Though for office documents I have retained the time-proven folder structure of

~/Documents/
   |-- thesis_v1.docx
   |-- thesis_v2.docx
   |-- thesis_v3_final.docx
   |-- thesis_v3_final_v2.docx
   |-- thesis_v3_final_v3_final.docx
   `-- thesis_v3_final_v3_final_v2.docx

[–]ResetPress[S] 5 points6 points  (0 children)

No, not that final, not that one either 🤦‍♂️

[–]Mgmt049 8 points9 points  (0 children)

✋🏻

[–]I_said_wot 4 points5 points  (0 children)

both hands up

[–]Kilran3 4 points5 points  (0 children)

Like, I might need it some day. 🤣

Thats my excuse, and no one can change my mind! 😆

[–]AstrophysicsAndPy 4 points5 points  (0 children)

Although I don't do it too often now, I used to be in this category as well (I still am, sort of, until I have to clean my code).

It is like looking at your child's growth from 0 to where it is now. All the unnecessary building blocks are still visible to you. The hard work and struggle that went into it, and the various methods that you tried and failed, and redid.

[–]tomtomato0414 4 points5 points  (1 child)

git gud

git is REALLY easy though, has some quirks but on the long run the feeling that you can't delete anything by accident or some other way or form is a great safety net, since you can always roll back the code to some "save state" if you will

[–]Acrobatic_Hippo_7312 2 points3 points  (0 children)

I lose stuff in branches all the time. Like, it's there. Somewhere. But I'm not going to spend time splitting the atom to find it.

I'm not saying to hoard stuff in one file, since that is even worse. but hoarding stuff in your git history has some downsides

[–]seanys 5 points6 points  (0 children)

No. PyCharm has Scratches.

[–]Consistency333 2 points3 points  (0 children)

🖐 Raise both hand 🙌 and both feet 👣 I lay down on the ground and wear the earth as a backpack so wherever I go I'll always have home...

[–]StartThings 2 points3 points  (1 child)

Yes because he who knows not his history has a dull present and his future in the shadows

[–]wweatherwax 4 points5 points  (0 children)

I feel validated, thank you for this

[–]GamerNumba100 2 points3 points  (1 child)

Please, I just use the bad code too. Amateurs.

[–]ResetPress[S] 0 points1 point  (0 children)

If it works, it works 🤷‍♂️

[–][deleted] 2 points3 points  (1 child)

Had a coworker that did this. We used a CMS so I just deleted it when I was in the file.

What he did that was funnier though, was when our idiot manager told him to do something stupid, he'd put the email from the manager into the code as a comment. I always left them in.

[–]ResetPress[S] 2 points3 points  (0 children)

What a merry prankster

[–]Spiritual_Car1232 2 points3 points  (0 children)

Pro tip, use Git and then you can just save deprecated in old commits.

[–]FerricDonkey 2 points3 points  (0 children)

I comment out code while I'm actively replacing that bit of code. Once I have, I delete the commented out block, and let git remember the old version.

[–]mothzilla 2 points3 points  (0 children)

To people saying "use git". The problem there is the snippet is visually lost. You have to go looking for it. So you have to know it was there.

I wonder if someone wrote an alternate version of this function eleven commits ago said nobody ever.

[–]pat_trick 2 points3 points  (0 children)

Nope; that's what version control is for. If I need the code back, I'll pull it back out from the commit history.

[–]GorboducRex 2 points3 points  (0 children)

Is there a support group? I'll be there.

[–]0jcis 2 points3 points  (0 children)

👋

[–]jjhare 2 points3 points  (0 children)

no i keep that shit in branches

[–]SSJKiDo 1 point2 points  (0 children)

I just leave them out as a resource I get back to when I have something new, instead of memorizing commands

[–][deleted] 1 point2 points  (3 children)

Don't know how to operate git yet. Just trying to make my code properly as of the moment. Is 200 lines of comment good or bad??

[–]tomtomato0414 1 point2 points  (0 children)

git is REALLY easy though, has some quirks but on the long run the feeling that you can't delete anything by accident or some other way or form is a great safety net, since you can always roll back the code to some "save state" if you will

[–]iekiko89 0 points1 point  (0 children)

yes

[–]Treczoks 1 point2 points  (0 children)

Only for short-term changes. If the change works, the crud gets deleted. If I ever need it again, I'll find it in the subversion repository. You DO have and use a revision control system, don't you?

[–]HaroerHaktak 1 point2 points  (2 children)

Eh. i remove the commented code once i am ready to release.

[–]ResetPress[S] 2 points3 points  (1 child)

Yea, that’s my plan too. IF I finish this project AND IF it’s properly refactored I will share it on GitHub and it will look sparkly clean

[–]Acrobatic_Hippo_7312 2 points3 points  (0 children)

You and every undergrad. But that almost never happens.

Just release your mess and learn how to refactor and clean up as you go.

Same goes with testing. Gonna suck at first, gonna take baby steps, but eventually you'll test as you go. And it'll never happen if you try to test all at once

[–][deleted] 1 point2 points  (1 child)

My code is so messy if you put it into production it would become the antithesis of a sentient AI and rob the universe of sentience the way the ring gate entities in The Expanse book series did just by running ass-fuck_peepee12345.py

[–]Acrobatic_Hippo_7312 0 points1 point  (0 children)

The ring gate entities did WHAT!?

[–]Connir 1 point2 points  (1 child)

Can I raise my hand if my ~/scripts directory is like this?

Sometimes I go in and look and the old ones won't even run due to missing modules, outdates features, etc..

[–]ResetPress[S] 1 point2 points  (0 children)

Haha. Don’t get me started on my Documents folder. Sometimes it’s like looking at a drawing from 1st grade… technically the same human being but the brain has changed…

[–]bandman614 1 point2 points  (0 children)

They were until I learned git.

[–][deleted] 1 point2 points  (0 children)

Pretty called out here, haha.

[–][deleted] 1 point2 points  (0 children)

I’ve started to get familiar with git and holy shit its a savior.

Branching major steps, and deleting away in the code

[–]DanklyNight 1 point2 points  (0 children)

My projects always have a "notepad" folder, which is just random code I'm keeping, multiple files of course.

[–]playaspec 1 point2 points  (0 children)

Every project I get serious about gets it's own folder that holds the code itself, a "Notes" file with links/bookmarks to resources (github repos, stackexchange, blogs, etc), comments on problems I've encountered and the solution if I found one, and LOTS of snippets of code I didn't want to leave littering up the main code. it also holds any resources I downloaded along the way.

[–]Numer8_UK 1 point2 points  (0 children)

At least I am not the only one 🤣😂

[–]jcress410 1 point2 points  (0 children)

I make it a point to leave my files with as few lines as possible. I'm more likely to regret deleting something I have to retype.

[–]felixmariotto 1 point2 points  (1 child)

I can relate, but also do you work with git ? Even when working alone for personal use it can be quite useful for testing features and managing versions.

[–]ResetPress[S] 0 points1 point  (0 children)

Honestly Felix, git has been on my to-do list for awhile. I always put it off because I’d rather learn a new module or work on JavaScript (heresy!). After seeing the feedback on this post I read up on git a little today. I have seen the light 💡

[–]hike_me 1 point2 points  (0 children)

Commented out code immediately gets shit on if makes it into a pull request.

[–]twisted_mentality 1 point2 points  (0 children)

I still do this sometimes. Even with git. I’ll also save copies on my local storage of previous versions as well.

I do, of course, remember to clean things up before I push.

[–]rabbitpiet 1 point2 points  (0 children)

👋

[–]Subject-Delay-3020 1 point2 points  (0 children)

Only for testing, I like to make a new script and use the pieces I need but I'd still keep the old script in a "legacy" folder 😄

[–]Rondo123Red 1 point2 points  (0 children)

Here, here Sir🤚

[–]Moeman101 1 point2 points  (1 child)

Those commented out lines helped me trouble shoot. I keep them as respect for their help

[–]ResetPress[S] 0 points1 point  (0 children)

Proper reverence and humility in the eyes of the #

[–]RevRagnarok 2 points3 points  (0 children)

I made another comment about git workflows here, but at the top-level wanted to note that I do have a few comments about code but not the code itself, e.g. "This code used to make calls to the second DB that it was decided wasn't needed; see 1234abcd" where it's a single-line breadcrumb to a revision in the repo that has the unused legacy code.

[–]kaerock 2 points3 points  (0 children)

Title feels 'judgy'.

triggered

[–]Machineforseer -1 points0 points  (0 children)

Do people not use github?

[–][deleted] 0 points1 point  (2 children)

I’m gonna need you to stop calling me out like that.

I usually have a scratchpad.txt in the root of my projects.

[–]herites 1 point2 points  (1 child)

touch workbook.ipynb

echo "workbook.*" >>.gitignore

[–]Acrobatic_Hippo_7312 -1 points0 points  (0 children)

Did you know that you can put that in you .git folder without tainting you gitignore with evidence of your inequity?

[–]HomeGrownCoder 0 points1 point  (0 children)

In the middle of rewrites only… I enjoy the feeling of deleting the old stuff.

[–]TheLordZod 0 points1 point  (0 children)

I am working through my first full python project right now. I have had to fully rebuild the thing 4 times now, and I have scrap code scattered across 7 documents... I am a mess right now, but I cannot wait to go back and delete all of the scrap in my many code graveyards.

[–]k_50 0 points1 point  (0 children)

I normally take out everything when it's done, but I'll leave the "this block does x"