DEV Community

Philip Perry
Philip Perry

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

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.

Top comments (0)