# gorm

Published articles for gorm.

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

## 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.