Monday, May 20, 2024
HomeiOS DevelopmentSuggestions and tips for exploring a brand new codebase – Donny Wals

Suggestions and tips for exploring a brand new codebase – Donny Wals


As a developer, becoming a member of a brand new undertaking or firm is usually a frightening and scary job. It’s important to get aquatinted with not only a entire new crew of individuals, however you additionally should familiarize your self with a wholly new codebase which may use new naming conventions, follows patterns that you simply’re not accustomed to, and even makes use of tooling that you simply’ve by no means seen earlier than.

There are many causes to be overwhelmed once you’re a brand new member of any engineering crew, and there’s no motive to really feel unhealthy about that.

Prior to now two years, I’ve carried out numerous contracting and consulting which signifies that I’ve needed to discover and perceive numerous codebases in brief quantities of time. Generally even having to discover a number of codebases directly every time I’d begin to work for a couple of shopper in a given week or two.

I assume it is honest to say that I’ve had my justifiable share of confusion and feeling overwhelmed with new codebases.

On this publish, I’d prefer to offer you some ideas and tips that I exploit to get myself snug with codebases of any dimension in an affordable period of time.

Meet the crew

Whereas it is perhaps tempting to get by means of your introductory calls as quickly as potential so you may spend as a lot time as potential on navigating and exploring a brand new codebase, I extremely suggest letting the code anticipate a short time. Meet the crew first.

Attending to know the those that wrote the code that you simply’re working with can actually assist to construct a greater understanding of the codebase as an entire. Ask questions on crew dynamics, and ongoing tasks, who’s an knowledgeable on what? Constructing empathy across the code you’ll be working with is a really helpful software.

Realizing which crew members know most about particular options, elements of the codebase, instruments which are utilized in an organization, and so forth additionally helps you determine the precise particular person to ask any questions you might need when you discover the codebase.

For instance, after I joined Disney virtually six years in the past I wasn’t all that accustomed to Swiftlint. I had heard about it however I had no concept what it did precisely. Within the codebase, I noticed some feedback that seemed as follows:

// swiftlint:disable:subsequent cyclomatic_complexity

After all, I may paste this remark into Google and go down a rabbit gap on what’s occurring and I’d in all probability have realized lots about Swiftlint however as an alternative, I selected to determine who is aware of most about Swiftlint throughout the crew. Certainly that particular person may assist me study lots about what Swiftlint was used for and the way it works.

I requested my crew lead and by chance it was my crew lead that truly knew tons and plenty of issues about Swiftlint, the way it was arrange, which linter guidelines we used, and so forth.

We had a superb chat and by the top of it, I knew precisely why we had Swiftlint at Disney Streaming, which guidelines we had disabled or enabled and why, and why it was okay to disable sure guidelines typically.

Google may have taught me that the remark you noticed earlier disabled a particular linter rule to permit one exception to the rule.

My coworker taught me not simply what that remark did but in addition why it did that. And why that was okay. And after I ought to or shouldn’t disable sure linter guidelines myself.

One other instance is a newer one.

One among my purchasers had a fairly large codebase that has had many individuals engaged on it through the years. There’s some Goal-C in there, numerous Swift, it has UIKit and SwiftUI, a number of structure patterns, and far more. It’s a correct legacy codebase.

As a substitute of figuring every little thing out by myself, I had conversations with numerous crew members. Generally they had been one-on-one conversations however different instances I met with two or three folks directly.

By means of these conversations, I realized about numerous architectural patterns that existed within the codebase. Which of them they thought of to be good matches, and which of them they had been seeking to section out. I realized why sure bits of code had been nonetheless in Goal-C, and which elements of the Goal-C codebase needs to be refactored finally.

I realized that sure crew members had spent numerous time engaged on particular options, patterns, and providers throughout the app. They’d inform me why sure selections had been made, and which decisions they had been and weren’t significantly pleased with.

After assembly the crew I knew a lot extra in regards to the undertaking, the codebase, the folks engaged on the undertaking, and the way issues transfer and evolve throughout the crew. This was extremely useful info to have as soon as I began to discover the codebase. By means of figuring out the crew I knew a lot extra in regards to the why of some bits of code. And I knew that some code wasn’t price exploring an excessive amount of as a result of it might be gone quickly.

On prime of that, by means of figuring out the crew, I felt extra empathic about bits of code that I didn’t like or didn’t perceive. I do know who was prone to have labored on that code. So as an alternative of getting pissed off about that little bit of code, I knew who I may ask to study extra in regards to the complicated part of code.

Break issues

Along with assembly the crew behind your new codebase, you’ll need to begin exploring the codebase itself sooner slightly than later. One of many key issues to determine is how the undertaking is about up. Which code is chargeable for what? How does one factor impression the opposite?

Hopefully, the codebase follows some well-established patterns that show you how to determine this out. Regardless, I discover it helpful to try to break issues whereas I discover.

By introducing flaws within the enterprise logic for an app on goal, you may study lots in regards to the codebase. Generally it helps you uncover sure “this could by no means occur” crashes the place a crew member used a drive unwrap or wrote a guard let with a fatalError inside.

Different instances issues break in additional delicate methods the place the app doesn’t fairly work however no errors are proven. Or possibly the app is excellent about dealing with errors and it signifies that one thing went mistaken / not as anticipated however the app informs you about this.

Once you break the networking layer in your app, you would possibly uncover some hints about how the app handles caching.

By making small modifications that almost certainly break the app you may study tons. It’s a method I usually use simply to see if there are any threads I ought to begin unraveling to study increasingly in regards to the cool particulars of a codebase.

After all, you don’t need to go round and begin poking at random issues. Normally, after I begin exploring I’ll select one or two options that I need to deal with. That is precisely the main focus of my subsequent tip.

Give attention to a slender scope

Once you be part of a big sufficient codebase, the concept of getting all of that code in your head in some unspecified time in the future sounds inconceivable. And actually, it in all probability is. There’s a superb probability that almost all builders on the crew for a big undertaking can have one or two elements of the codebase internalized. They know every little thing about it. For every little thing else, they’ll roughly know which patterns the code ought to observe (as a result of the entire crew follows the identical patterns) and so they might need some sense of how that code interacts with different modules.

General although, it’s simply not life like for any crew member to know all the ins and outs of each module or function within the codebase.

So why would you be trying to discover your entire codebase ?

For those who’re employed on a particular crew, deal with the code that may be maintained by that crew. Begin exploring and understanding that code in as a lot element as potential, have crew members present you the way the code works, and see should you can break among the code.

Generally there shall be bug tickets or options you could begin taking a look at to provide you a superb start line to start studying extra a few codebase. If that’s the case, you should utilize your tickets that can assist you decide your scope. For those who’re engaged on a bug, deal with understanding every little thing you may in regards to the part of code that appears almost certainly to be the supply of the bug.

And as at all times, you’ll need to be in contact with the crew. Ask them in the event that they might help you discover one thing to deal with initially. When you have got a bug ticket to work on, see if someone on the crew might help you kickstart your analysis; possibly they’ve some ideas on the place you can begin trying first.

And in a really perfect world, leverage pair programming to double the velocity at which you study.

Leverage pair programming

One software that I normally discover to be immensely underused is pair programming. In numerous locations the place I’ve labored, builders choose to work alone. Headphones on, deep within the zone. Questions needs to be initiated on Slack so that you’re disturbed as little as potential. Disable notifications if it’s a must to.

There’s completely a time and place for deep targeted work the place you’re to not be disturbed.

Nonetheless, there’s an unlimited profit in pairing up with a teammate to discover subjects and work on options. Particularly once you’ve simply joined a crew, it’s tremendous necessary you have got entry to your crew members that can assist you navigate the corporate, crew, and codebase.

Once you’re pairing with a teammate throughout your exploration section, you may take the wheel. You can begin exploring the codebase, asking questions on what you’re seeing as you go. Particularly when you have got one thing to work on, this may be extraordinarily helpful.

Any query or thought you might need can instantly be bounced off of your programming companion.

Even should you’re not the particular person taking the wheel, there’s numerous profit in seeing someone else navigate the code and undertaking you’ll work on. Pay shut consideration to sure utilities or instruments they use. For those who see one thing you haven’t seen earlier than, ask about it. Perhaps these git instructions your coworker makes use of are utilized by everyone on the crew.

Particularly when there’s debugging concerned it pays dividends to ask for a pairing session. Seeing someone that’s skilled with a codebase navigate and debug their code will train you tons about relationships between sure objects for instance.

Two folks know a couple of, and that is very true whereas onboarding a brand new coworker. So subsequent time a brand new particular person joins your crew, supply them a few pair programming classes. Or should you’re the brand new joiner see if there’s someone fascinated about spending a while with you whereas working by means of some issues and exploring the codebase.

Use breakpoints

Once I was engaged on this publish I requested the group how they prefer to discover a codebase and lots of people talked about utilizing a symbolic breakpoint on viewDidLoad or viewDidAppear which I discovered a reasonably cool method to studying extra in regards to the totally different views and examine controllers which are utilized in a undertaking.

A symbolic breakpoint lets you pause the execution of your program when a sure methodology is known as on code you may not personal. For instance, you may have a symbolic breakpoint on UIViewController strategies which lets you see every time a brand new subclass of UIViewController is added to the navigation hierarchy.

Realizing this type of stuff is tremendous helpful since you’ll be capable of study which view controller(s) belong to which display screen fairly shortly.

I haven’t used this one lots myself however I discovered it an fascinating concept so I wished to incorporate it on this record of ideas.

In Abstract

Once you be part of a brand new crew, it’s tempting to maintain your head down and research your new codebase. In your head, you would possibly suppose that you simply’re anticipated to already know every little thing in regards to the codebase regardless that you’re utterly new to the undertaking.

You would possibly suppose that every one patterns and practices within the undertaking are business normal and that you simply simply haven’t labored in locations pretty much as good as this one earlier than.

All of those sorts of concepts exist in just about anyone’s head and so they forestall you from correctly studying and exploring a brand new codebase.

On this publish, you have got realized some tips on why human interplay is extraordinarily necessary throughout your exploration section. You additionally realized some helpful ideas for the extra technical facet of issues that can assist you successfully sort out studying a brand new codebase.

Good luck in your subsequent journey into a brand new codebase!

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments