DEV Community

Cover image for Why You Need a Coding Scratch File
Kevin Hicks
Kevin Hicks

Posted on β€’ Originally published at kevinhicks.software

3

Why You Need a Coding Scratch File

Sometimes the best place to write code for your project is outside it.

This may sound like a lie. How could writing code outside of a project be the best place for the project's code? How can it even help the project at all?

Working within a project, especially a large and complex one, other code can get in the way of what you are writing.

By removing the distraction of unrelated code, you can focus on your task.

When experimenting with designs or figuring out a tricky issue, it's quicker and easier to focus on the smallest amount of code needed. You don't have to worry about passing arguments around, multiple software layers, and other complexities. You also won't need as many manual steps or automated tests to test your code.

Sometimes you will need the rest of the project code, but removing it can be a huge productivity boost when you don't.

How does a scratch file help?

A scratch file allows you to write code that can be compiled, ran and debugged without the rest of your project or setting up a new one. You can copy the code to your project and delete the file when you finish. Scratch files also help avoid accidentally committing temporary code.

It's like a sticky note for the code you throw out when done with it.

Create your first scratch file.

Scratch files can usually be created inside your IDE. The process is different between IDEs, so search for "your IDE name + scratch file" to get started. It's also helpful to read everything your IDE can do with scratch files when you look this up.

Once you create the file, start writing code.

There are also options outside of IDEs for scratch files.
You could use a fiddle site (like jsfiddle) for your language. Some languages and frameworks have tools for this, such as artisan tinker for Laravel and LinqPad for C#. A default project for your language or framework could also serve as a scratch file if you need to work across multiple layers with no other custom code.

Learn about the scratch file options for your project and use what you prefer.

While not suitable for every situation, scratch files are a fantastic tool when focusing on a small amount of stand-alone code.

Image of AssemblyAI tool

Challenge Submission: SpeechCraft - AI-Powered Speech Analysis for Better Communication

SpeechCraft is an advanced real-time speech analytics platform that transforms spoken words into actionable insights. Using cutting-edge AI technology from AssemblyAI, it provides instant transcription while analyzing multiple dimensions of speech performance.

Read full post

Top comments (1)

Collapse
 
alphaolomi profile image
Alpha Olomi β€’

I currently work with Next.js mostly and several times i had to create different temporary(scratch apps ) next app to try some features packages and more

It really helps with focusing and reducing interference with other parts

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

πŸ‘‹ Kindness is contagious

Dive into an ocean of knowledge with this thought-provoking post, revered deeply within the supportive DEV Community. Developers of all levels are welcome to join and enhance our collective intelligence.

Saying a simple "thank you" can brighten someone's day. Share your gratitude in the comments below!

On DEV, sharing ideas eases our path and fortifies our community connections. Found this helpful? Sending a quick thanks to the author can be profoundly valued.

Okay