Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Delete All The Codes

Tags: code

Posted on Aug 8 This article is about is not about writing Code, it's about deleting code. Ok, maybe not all the code. But hear me out.When I was in fifth grade and starting to program, I was fascinated by big programs. .EXE files that had megabytes in file size whereas my programs only had a few kilobytes. Professional programmers are able to write huge programs and that's a cool thing, I thought.But, there reality is that code is a liability. As soon as you write it, is your team's legacy. A legacy in reality can be something good like a house but it can also be something bad like debts. In software development, it is quite often the latter, unfortunately.One might think that code once written can just stay there for free. It doesn't do harm, right...right?Code needs to be maintained. It needs love and care to stay healthy otherwise it might break and take your beloved app with it.There are all kinds of things need to be considered:Where my younger me had a deep admiration for big program, my older me has learned that code that does not exist is actually the best code. It doesn't need any of the things discussed in the previous section.I don't have any personal relationship to my code anymore (which is actually not my code by our team's code anyways) and so you shouldn't.I actually feel happy and relieved deleting code.To delete code, I actually follow a couple of practices:The Boy-Scout-Rule is a general practice of continuous improvement. It basically says: Leave the fire place cleaner than you found it. Or in more technical terms: If you are working on a part of code, try to improve things in the area that you are working on even if it is not strictly necessary for your current task.That includes cleaning and deleting code. Most often, your editor or IDE will tell you about unused code. Delete it. No excuses. There should be tests covering it, if the code is actually necessary.Sometimes you start with a new bigger feature and implement it in the most basic way (TDD, wink wink). But as soon as you add new features around that code, it might need some refactoring.If you did it right, most of the time you should be able to actually delete a significant amount of code. For me, this is like the reward I get when I we did a good refactoring. It let's me delete code. I love it.This is a tricky one. You might have code that is used (by tests) but actually not in production anymore. So it looks like it is used but it is actually some undead code disturbing your neighborhood. This is the case e.g. when you have APIs that are covered by unit tests or even integration test but which are not used, neither by a UI nor by customer.This needs a check from time to time. Could be done as a regular item in a team meeting or task in a maintenance sprint etc. Obviously, you could also explicitly deprecate APIs which are used by customers and mark them for removal.You might say "But I might need that code!". You might also know the answer. Use your version control system of choice to get the code back. Yes, it might not immediately work but the effort to keep code alive is most often higher. Also, in 99% of the cases, no don't need that code ever.Keep you code clean and tidy. Delete as much code as you can. Thank me later :)Cover image by Ujesh Krishnan on UnsplashTemplates let you quickly answer FAQs or store snippets for re-use. Are you sure you want to hide this comment? It will become hidden in your post, but will still be visible via the comment's permalink. Hide child comments as well Confirm For further actions, you may consider blocking this person and/or reporting abuse Nashe Omirro - Jul 21 Nevo David - Aug 1 Syed Muhammad Ali Raza - Jul 24 Dhruv Joshi - Aug 2 Once suspended, stealthmusic will not be able to comment or publish posts until their suspension is removed. Once unsuspended, stealthmusic will be able to comment and publish posts again. Once unpublished, all posts by stealthmusic will become hidden and only accessible to themselves. If stealthmusic is not suspended, they can still re-publish their posts from their dashboard. Note: Once unpublished, this post will become invisible to the public and only accessible to Jan Wedel. They can still re-publish the post if they are not suspended. Thanks for keeping DEV Community safe. Here is what you can do to flag stealthmusic: stealthmusic consistently posts content that violates DEV Community's code of conduct because it is harassing, offensive or spammy. Unflagging stealthmusic will restore default visibility to their posts. DEV Community — A constructive and inclusive social network for software developers. With you every step of your journey. Built on Forem — the open source software that powers DEV and other inclusive communities.Made with love and Ruby on Rails. DEV Community © 2016 - 2023. We're a place where coders share, stay up-to-date and grow their careers.



This post first appeared on VedVyas Articles, please read the originial post: here

Share the post

Delete All The Codes

×

Subscribe to Vedvyas Articles

Get updates delivered right to your inbox!

Thank you for your subscription

×