# reusable code

Published articles for reusable code.

This is one page of public article previews, not the complete archive. Follow Next page to continue. Summaries are not the original full articles.

## When Duplicated Code Is the Better Tradeoff

DevFeed: [When Duplicated Code Is the Better Tradeoff](<https://devfeed.tech/articles/when-to-repeat-yourself-18209.md>)

Original publisher: [Read original article](<https://newsletter.francofernando.com/p/when-to-repeat-yourself>)

Author: Franco Fernando

Published: 2026-07-04T06:05:31Z

Content type: opinion

Language: en

Sources: [The Polymathic Engineer](<https://devfeed.tech/sources/the-polymathic-engineer.md>)

Topics: [Software Engineering](<https://devfeed.tech/topics/software-engineering.md>), [Code](<https://devfeed.tech/topics/code.md>), [distributed-systems](<https://devfeed.tech/topics/distributed-systems.md>), [Microservice](<https://devfeed.tech/topics/microservice.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [abstraction](<https://devfeed.tech/tags/abstraction.md>), [bugs](<https://devfeed.tech/tags/bugs.md>), [code](<https://devfeed.tech/tags/code.md>), [components](<https://devfeed.tech/tags/components.md>), [distributed](<https://devfeed.tech/tags/distributed.md>), [distributed-systems](<https://devfeed.tech/tags/distributed-systems.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>), [services](<https://devfeed.tech/tags/services.md>), [software](<https://devfeed.tech/tags/software.md>), [software-engineering](<https://devfeed.tech/tags/software-engineering.md>), [teams](<https://devfeed.tech/tags/teams.md>)

### AI overview

This article examines when following the DRY principle creates more cost than value. It argues that duplicated code can be reasonable when abstraction adds coordination overhead, tight coupling, or inflexibility, especially across distributed services and teams whose code may evolve differently.

### Source excerpt

When duplicated code is the better tradeoff.

## Managing State in Vue Applications: The Composable Provider Pattern

DevFeed: [Managing State in Vue Applications: The Composable Provider Pattern](<https://devfeed.tech/articles/managing-state-in-vue-applications-the-composable-provider-pattern-20035.md>)

Original publisher: [Read original article](<https://technology.doximity.com/articles/managing-state-in-vue-applications-the-composable-provider-pattern>)

Author: Doximity

Published: 2023-07-21T07:23:00Z

Content type: article

Language: en

Sources: [Doximity](<https://devfeed.tech/sources/doximity.md>)

Topics: [Vue.js](<https://devfeed.tech/topics/vue.md>), [Front end](<https://devfeed.tech/topics/frontend.md>), [Scalability](<https://devfeed.tech/topics/scalability.md>), [Nuxt.js](<https://devfeed.tech/topics/nuxt.md>)

Tags: [code-modularity](<https://devfeed.tech/tags/code-modularity.md>), [components](<https://devfeed.tech/tags/components.md>), [maintainability](<https://devfeed.tech/tags/maintainability.md>), [modularity](<https://devfeed.tech/tags/modularity.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>), [reuse](<https://devfeed.tech/tags/reuse.md>), [scalability](<https://devfeed.tech/tags/scalability.md>), [state-management](<https://devfeed.tech/tags/state-management.md>), [vue](<https://devfeed.tech/tags/vue.md>)

### AI overview

This article explains the Composable Provider pattern for state management in Vue applications. The approach combines the Vue Composition API with the Provide/Inject APIs to manage complex, feature-driven state, with benefits including scalability, maintainability, reusability, and reduced code duplication.

### Source excerpt

State management is a fundamental concept of front-end application design, and a critical aspect in building robust Vue applications. As Vue applications grow in complexity, managing state becomes an increasingly challenging task, especially when working with a large organization of engineers spread across various product teams. Fortunately, the Vue and Nuxt ecosystem provides a variety of state management solutions, each with its own trade-offs. In this blog post we will explore the Composable Provider pattern, which handles state management by combining the Vue Composition and Provide/Inject APIs, and why its clean and simple implementation is a powerful approach to handling complex, feature-driven state in modern Vue applications. Note: This article was originally intended as a reference for our internal engineering team, but given its potential general use among Vue application developers we are publishing it here. We hope you'll find this pattern helpful when designing your Vue application's state as we have here at Doximity! Why Efficient State Management Matters Efficient state management plays a crucial role in the development of Vue applications. As applications grow in complexity, the ways in which we manage and handle changes to state become increasingly important. Here are a few key reasons why managing state efficiently matters: Scalability: As Vue applications and the teams building them grow in size, the complexity and size of their state grow also. Efficient state management allows for better scalability by providing a structured and organized approach to handling state. It becomes easier to add new features, maintain existing functionality, and reason about the flow of data within the application. Code Maintainability: Well-managed state reduces code complexity and promotes code maintainability. When state is not encapsulated properly, it becomes challenging to understand and modify the application's behavior. By implementing sound state management

## Making Twig Macros Work Like Functions

DevFeed: [Making Twig Macros Work Like Functions](<https://devfeed.tech/articles/making-twig-macros-work-like-functions-31280.md>)

Original publisher: [Read original article](<https://nystudio107.com/blog/making-twig-macros-work-like-functions>)

Author: andrew@nystudio107.com (Andrew Welch)

Published: 2023-07-14T18:38:00Z

Content type: tutorial

Language: en

Sources: [nystudio107 | Articles on modern web development.](<https://devfeed.tech/sources/nystudio107-articles-on-modern-web-development.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [Development](<https://devfeed.tech/topics/development.md>), [reusable code](<https://devfeed.tech/topics/reusable-code.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [functions](<https://devfeed.tech/tags/functions.md>), [insights](<https://devfeed.tech/tags/insights.md>), [just](<https://devfeed.tech/tags/just.md>), [languages](<https://devfeed.tech/tags/languages.md>), [learn](<https://devfeed.tech/tags/learn.md>), [like](<https://devfeed.tech/tags/like.md>), [macros](<https://devfeed.tech/tags/macros.md>), [make](<https://devfeed.tech/tags/make.md>), [manipulate](<https://devfeed.tech/tags/manipulate.md>), [programming](<https://devfeed.tech/tags/programming.md>), [programming-languages](<https://devfeed.tech/tags/programming-languages.md>), [return](<https://devfeed.tech/tags/return.md>), [returning](<https://devfeed.tech/tags/returning.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>), [twig](<https://devfeed.tech/tags/twig.md>), [value](<https://devfeed.tech/tags/value.md>), [values](<https://devfeed.tech/tags/values.md>)

### AI overview

A tutorial on making Twig macros return values that can be manipulated like function results. It demonstrates a sales-calculation macro, whitespace control, and returning a value for further computations such as sales tax.

### Source excerpt

Learn how to make Twig macros return values you can manipulate, just like functions in other programming languages

## Generics vs. Interfaces

DevFeed: [Generics vs. Interfaces](<https://devfeed.tech/articles/generics-vs-interfaces-22185.md>)

Original publisher: [Read original article](<https://www.ardanlabs.com/blog/2022/12/generic-vs-interfaces.html>)

Published: 2022-12-16T00:00:00Z

Content type: tutorial

Language: en

Sources: [William Kennedy](<https://devfeed.tech/sources/william-kennedy.md>)

Topics: [Go Language](<https://devfeed.tech/topics/go-language.md>), [Binance](<https://devfeed.tech/topics/binance.md>), [backends](<https://devfeed.tech/topics/backends.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [adapter-pattern](<https://devfeed.tech/tags/adapter-pattern.md>), [api](<https://devfeed.tech/tags/api.md>), [api-server](<https://devfeed.tech/tags/api-server.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [decoding](<https://devfeed.tech/tags/decoding.md>), [decoupling](<https://devfeed.tech/tags/decoupling.md>), [encoding](<https://devfeed.tech/tags/encoding.md>), [function](<https://devfeed.tech/tags/function.md>), [generics](<https://devfeed.tech/tags/generics.md>), [go](<https://devfeed.tech/tags/go.md>), [go-api-server](<https://devfeed.tech/tags/go-api-server.md>), [gorm](<https://devfeed.tech/tags/gorm.md>), [http](<https://devfeed.tech/tags/http.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>), [solid](<https://devfeed.tech/tags/solid.md>), [solid-principles](<https://devfeed.tech/tags/solid-principles.md>), [transactions](<https://devfeed.tech/tags/transactions.md>), [video](<https://devfeed.tech/tags/video.md>)

### AI overview

A video explains how generic functions and adapter functions can reduce code duplication and decouple business logic from API server handlers in Go. It demonstrates HTTP handlers, GORM database transactions, performance evaluation with PPROF, and generic data encoding and decoding.

### Source excerpt

Introduction In this video, Paulo shows the benefit of leveraging generic functions to write less code that does more. He starts by walking you through an API server he initially wrote that makes use of Go's default HTTP handlers with a sprinkle of GORM to manage database transactions. He then refactors that code by introducing the concept of adapter functions. Paulo's approach consists of decoupling his business logic with his API code. To achieve this, he defines an adapter function that will establish a bridge between his business logic and API server handlers. This proves to be an effective way to abstract request processing and handling. This approach also promotes code reusability because the business logic is loosely coupled with the API service invoking it.

## Why Are There Functions?

DevFeed: [Why Are There Functions?](<https://devfeed.tech/articles/why-are-there-functions-32236.md>)

Original publisher: [Read original article](<https://bruceeckel.com/2022/09/29/why-are-there-functions/>)

Author: Bruce Eckel

Published: 2022-09-29T00:00:00Z

Content type: opinion

Language: en

Sources: [Bruce Eckel - Computing Thoughts](<https://devfeed.tech/sources/bruce-eckel-computing-thoughts.md>)

Topics: [Programming](<https://devfeed.tech/topics/programming.md>), [function](<https://devfeed.tech/topics/function.md>), [Assembly](<https://devfeed.tech/topics/assembly.md>), [Polymorphism](<https://devfeed.tech/topics/polymorphism.md>), [C](<https://devfeed.tech/topics/c.md>), [reusable code](<https://devfeed.tech/topics/reusable-code.md>)

Tags: [assembly](<https://devfeed.tech/tags/assembly.md>), [c](<https://devfeed.tech/tags/c.md>), [code](<https://devfeed.tech/tags/code.md>), [polymorphism](<https://devfeed.tech/tags/polymorphism.md>), [programming](<https://devfeed.tech/tags/programming.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>)

### AI overview

The article examines why programmers write functions, drawing on the author's experience with assembly language for embedded systems. It argues that functions reduce repeated code, memory use, duplicate debugging effort, and reliability risks, while enabling reusable code; C automates much of the calling work required in assembly language.

### Source excerpt

Returning from giving my Polymorphism Unbound presentation at StrangeLoop (not yet available on YouTube, but all the examples and presentation slides are on Github), I found myself dissatisfied. Part of this was certainly my failure to cram a 2-hour presentation into 40 minutes (after cutting it down from a day-long, workshop-length size). The bigger issue was my inability to answer the essential question at the end of the presentation: why are we writing polymorphic functions?

## Learning From npm's Rough Few Months

DevFeed: [Learning From npm's Rough Few Months](<https://devfeed.tech/articles/learning-from-npm-s-rough-few-months-36865.md>)

Original publisher: [Read original article](<https://shostack.org/blog/learning-from-npms-rough-few-months/>)

Author: Adam

Published: 2017-08-15T00:00:00Z

Content type: opinion

Language: en

Sources: [Shostack & Friends Blog](<https://devfeed.tech/sources/shostack-friends-blog.md>)

Topics: [npm](<https://devfeed.tech/topics/npm.md>), [Package manager](<https://devfeed.tech/topics/package-manager.md>), [JavaScript](<https://devfeed.tech/topics/javascript.md>), [Critical Infrastructure](<https://devfeed.tech/topics/critical-infrastructure.md>), [Security](<https://devfeed.tech/topics/security.md>), [reusable code](<https://devfeed.tech/topics/reusable-code.md>)

Tags: [critical-infrastructure](<https://devfeed.tech/tags/critical-infrastructure.md>), [javascript](<https://devfeed.tech/tags/javascript.md>), [npm](<https://devfeed.tech/tags/npm.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>), [security](<https://devfeed.tech/tags/security.md>)

### AI overview

This commentary examines npm's difficult recent period, what npm and other package managers could do, and what policy lessons may follow from treating package infrastructure as critical infrastructure.

### Source excerpt

[no description provided]

## MVVM-C A simple way to navigate

DevFeed: [MVVM-C A simple way to navigate](<https://devfeed.tech/articles/mvvm-c-a-simple-way-to-navigate-27947.md>)

Original publisher: [Read original article](<https://tech.trivago.com/post/2016-08-26-mvvmc/>)

Author: Susann Proszak Follow

Published: 2016-08-26T00:00:00Z

Content type: tutorial

Language: en

Sources: [Trivago](<https://devfeed.tech/sources/trivago.md>)

Topics: [iOS development](<https://devfeed.tech/topics/ios-development.md>), [mvc](<https://devfeed.tech/topics/mvc.md>), [Mobile](<https://devfeed.tech/topics/mobile.md>), [navigation](<https://devfeed.tech/topics/navigation.md>), [reusable code](<https://devfeed.tech/topics/reusable-code.md>)

Tags: [architectures](<https://devfeed.tech/tags/architectures.md>), [business-logic](<https://devfeed.tech/tags/business-logic.md>), [design-patterns](<https://devfeed.tech/tags/design-patterns.md>), [ios-development](<https://devfeed.tech/tags/ios-development.md>), [mobile](<https://devfeed.tech/tags/mobile.md>), [mvc](<https://devfeed.tech/tags/mvc.md>), [mvvm](<https://devfeed.tech/tags/mvvm.md>), [navigation](<https://devfeed.tech/tags/navigation.md>), [reusable-code](<https://devfeed.tech/tags/reusable-code.md>), [testing](<https://devfeed.tech/tags/testing.md>)

### AI overview

An introduction to the MVVM-C design pattern for iOS development. The article explains how coordinators handle application navigation and flow while view models contain business logic, using a small demo app to illustrate the approach.

### Source excerpt

When thinking about design patterns and architectures in iOS development, MVC might be the first thing that comes to mind for most of you. But throughout the last years, MVC got a really bad reputation. Probably a lot of you heard about MVC as the massive view controller.