javaeclipseworkspaceproject-organizationfile-organization

I Had a panic attack, I deleted import files on accident. How can I prevent this?


I don't know,

Its late at night, I'm pressing buttons mindlessly, then all of a sudden after I look up and notice that my Main Class file isn't there. I spit my coffee out like a mad llama. I spam the cmd+z, and scarcely look for it, but its gone. My most important file is gone and I have no idea how to get it back...

Whatever, I ended up decompiling my past .jar file and was able to restore the file I deleted after a painful 30 minutes. I made a huge mistake and I'm curious on what you Pros do to prevent this!

(Note: I'm using Eclipse, and I did try to sort this problem out by going through the procedure of 'Restore Local History...' but I was lead to an empty history of which I couldn't restore.)

I have a couple sub-questions:
• What can you suggest to me for improving my workspace for not only organization but a way to prevent myself from deleting files accidentally?

• Are there any good autosave / upload / something to make sure I can get back my previous code from lets say 5 minutes ago or so like backups?


Solution

  • I'm curious on what you Pros do to prevent this!

    1) Don't panic

    2) Don't press buttons mindlessly

    3) Don't program late at night ... when you are too tired to think straight

    4) Do use a good version control system for any programming of any importance. These days, DVCS systems like Git or Mercurial are the best option.

    5) Do check your code into your version control system regularly.

    6) Do make sure that critical parts your computer systems are backed up to a (separate or removable) storage medium. Ideally, keep an off-site copy.

    7) In addition to 6), put a copy of your software into a public or private repo hosted on different infrastructure; e.g. on Github / BitBucket / etc. Remember to push your changes to the remote repo regularly.


    What can you suggest to me for improving my workspace for not only organization but a way to prevent myself from deleting files accidentally?

    Nothing really works.

    That is why you should be taking backups.

    Are there any good autosave / upload / something to make sure I can get back my previous code from lets say 5 minutes ago or so like backups?

    Nothing works reliably at that level of granularity. Sure IDE's have undo/redo, but they are limited in their scope and typically don't cover things like deleting files.