DEV Community

Philip Perry
Philip Perry

Posted on • Originally published at programming-decoded.com on

2

Entering unknown code territory

Adding a new feature to an existing codebase can be intimidating and initially one might feel overwhelmed and not know where to start.

Here I’m writing about my experience of tackling this. First, I try to understand as best as I can the existing code that is related to where I plan to add my own code. If I’m not sure what a method will return, I’ll dump out the variable to the screen or console. I also look for similar code that does what I plan to do. I might find that I can even create a new class that can be used by both the old functionality and for the new feature. But at this stage it’s better not to refactor anything yet, but just get something to work. So initially doing some copy and pasting is fine. Once I have something working, I write some tests and now I can start refactoring.

I think the main takeaway (apart from not panicking) is to just get started. I try to get something small working and gradually I start to understand better how things fit together. That doesn’t mean that I start without making a plan. Sketching things out first is very useful to help with understanding what I need to accomplish.

As I spend time experimenting and making small improvements it’s important to frequently commit the code to source control. So anytime I break something, I can easily go back to a working state.

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

Learn More

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more