Four Things to Consider about Code Re-Use

Stefanie Diesi, Staff Engineer

Software developers love writing new code. There’s something thrilling and exciting about designing creative, efficient solutions to new problems. Given the chance, many would rather write something new than reuse existing code, but despite what developers want, rewriting an entire codebase is not always good for business.

At the other end of the spectrum, most business executives want to see prototypes and give demos of new products as soon as possible—and often sooner! Writing new code is slow, but reusing code can be fast. Stitching together functionality from existing in-house software or an open source software project can help create working prototypes in a matter of weeks or months depending on complexity.

As a project manager, how do you strike a balance between new, elegant, and efficient solutions that your developers will love creating, on the one hand, and your business development group wanting a prototype tomorrow, on the other? It’s true that starting from existing code will jumpstart development, but before giving into that temptation, there are a number of considerations that could prove costly down the line if overlooked.

1. How much of your problem does reuse solve?

When evaluating any codebase for potential reuse, estimate how much of your problem it actually solves. It’s unlikely the existing code forms a complete solution to your problem, or else you wouldn’t be writing new software at all. With that in mind, it’s important to identify areas where your needs are dramatically different from what’s provided. If the existing code falls short of what you need, your team will need to extend the capabilities. Alternatively, maybe you need only a small subset of the functionality provided. Should you ignore the additional capability, in case you grow into it later, or should you try to remove it, to reduce complexity? Both options can be valid depending on the situation.

2. How much flexibility do you need?

Well-defined requirements specified at the beginning of the project are great in theory, but reality is always different: feature changes inevitably creep in throughout the development phase. Try to gauge the level of effort involved in adding potential features to a codebase that your team did not write. Sometimes customers and marketing groups are willing to discuss various options for achieving the same goal, but other times, you may have to force changes in places where they don’t naturally fit. It can be much easier to bend your own code to your will than to bend someone else’s.

3. What does the existing code look like?

Code can run the gamut from utterly incomprehensible, to reasonably well written, to almost a work of art. Most likely, the code you’re evaluating falls somewhere in the middle of that scale. Differences in indentation and formatting can be overlooked as a minor irritation, but it’s nearly impossible to reuse code when all the variables start with the letter ‘i’ (i, i1, i2, ii, iii, i_3, and so on).

Related to code readability is code complexity. There is some beautifully written code that is so “reusable” that it’s extremely difficult to understand. Making things generic can lead to complicated logic that is unnecessary for a specific task.

Your willingness to put up with less-readable or less-understandable code will depend on the previous two considerations. If your team will be making dramatic modifications, consider how hard it will be for them to modify and maintain the code you’re evaluating. For cases when the code is poorly written and poorly documented, and it only solves part of your problem, it might be best to start from scratch.

4. Do you have to deliver the code?

If the software you are hoping to re-use was developed under the GPL or similar license, then you will have to make available the source for the modified GPL code plus any modules linked to it. Depending on your business requirements, releasing your code may or may not be a problem for you.

If you’d like to re-use GPL code but not release all of your product’s source code, there is a possible alternate approach. The GPL restriction only applies to the executable that modifies or links against the GPL’ed code. If you can isolate that functionality in its own executable that communicates to the rest of your software using various IPC mechanisms, you can insulate most of your code from this restriction. You may be content to give away the custom wrapper code if it means you can use the capabilities of the existing codebase. This amounts to trading possibly a month’s worth of development in exchange for several months’ worth. However, this option comes at the cost of added complexity because you have to synchronize and provide communication between separate executables.

 

Every project has different motivating forces, but all of them are tied to a deadline. Reusing existing software to shorten that timetable can be appealing during the planning phases, but saving time in the beginning can sometimes prove costly in the end when it counts most. Careful consideration of the issues involved in reuse can avoid or at least identify these potential problems while there’s still time to plan accordingly.

Cardinal Peak
Learn more about our Audio & Video capabilities.

Dive deeper into our IoT portfolio

Take a look at the clients we have helped.

We’re always looking for top talent, check out our current openings. 

Contact Us

Please fill out the contact form below and our engineering services team will be in touch soon.

We rely on Cardinal Peak for their ability to bolster our patent licensing efforts with in-depth technical guidance. They have deep expertise and they’re easy to work with.
Diego deGarrido Sr. Manager, LSI
Cardinal Peak has a strong technology portfolio that has complemented our own expertise well. They are communicative, drive toward results quickly, and understand the appropriate level of documentation it takes to effectively convey their work. In…
Jason Damori Director of Engineering, Biamp Systems
We asked Cardinal Peak to take ownership for an important subsystem, and they completed a very high quality deliverable on time.
Matt Cowan Chief Scientific Officer, RealD
Cardinal Peak’s personnel worked side-by-side with our own engineers and engineers from other companies on several of our key projects. The Cardinal Peak staff has consistently provided a level of professionalism and technical expertise that we…
Sherisse Hawkins VP Software Development, Time Warner Cable
Cardinal Peak was a natural choice for us. They were able to develop a high-quality product, based in part on open source, and in part on intellectual property they had already developed, all for a very effective price.
Bruce Webber VP Engineering, VBrick
We completely trust Cardinal Peak to advise us on technology strategy, as well as to implement it. They are a dependable partner that ultimately makes us more competitive in the marketplace.
Brian Brown President and CEO, Decatur Electronics
The Cardinal Peak team started quickly and delivered high-quality results, and they worked really well with our own engineering team.
Charles Corbalis VP Engineering, RGB Networks
We found Cardinal Peak’s team to be very knowledgeable about embedded video delivery systems. Their ability to deliver working solutions on time—combined with excellent project management skills—helped bring success not only to the product…
Ralph Schmitt VP, Product Marketing and Engineering, Kustom Signals
Cardinal Peak has provided deep technical insights, and they’ve allowed us to complete some really hard projects quickly. We are big fans of their team.
Scott Garlington VP Engineering, xG Technology
We’ve used Cardinal Peak on several projects. They have a very capable engineering team. They’re a great resource.
Greg Read Senior Program Manager, Symmetricom
Cardinal Peak has proven to be a trusted and flexible partner who has helped Harmonic to deliver reliably on our commitments to our own customers. The team at Cardinal Peak was responsive to our needs and delivered high quality results.
Alex Derecho VP Professional Services, Harmonic
Yonder Music was an excellent collaboration with Cardinal Peak. Combining our experience with the music industry and target music market, with Cardinal Peak’s technical expertise, the product has made the mobile experience of Yonder as powerful as…
Adam Kidron founder and CEO, Yonder Music
The Cardinal Peak team played an invaluable role in helping us get our first Internet of Things product to market quickly. They were up to speed in no time and provided all of the technical expertise we lacked. They interfaced seamlessly with our i…
Kevin Leadford Vice President of Innovation, Acuity Brands Lighting
We asked Cardinal Peak to help us address a number of open items related to programming our systems in production. Their engineers have a wealth of experience in IoT and embedded fields, and they helped us quickly and diligently. I’d definitely…
Ryan Margoles Founder and CTO, notion