# factory function

A programming technique in which a function returns new objects, often supporting parameterization, composition, and encapsulated state.

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

## How to use generics to avoid duplications and make your code better

DevFeed: [How to use generics to avoid duplications and make your code better](<https://devfeed.tech/articles/how-to-use-generics-to-avoid-duplications-and-make-your-code-better-32291.md>)

Original publisher: [Read original article](<https://domenicoluciani.com/2025/04/11/how-to-use-generics-to-avoid-duplications-and-make-your-code-better.html>)

Author: Domenico Luciani

Published: 2025-04-10T22:00:00Z

Content type: tutorial

Language: en

Sources: [Domenico Luciani](<https://devfeed.tech/sources/domenico-luciani.md>)

Topics: [generics](<https://devfeed.tech/topics/generics.md>), [Go Language](<https://devfeed.tech/topics/go-language.md>), [interfaces](<https://devfeed.tech/topics/interfaces.md>), [JSON:API](<https://devfeed.tech/topics/json-api.md>), [factory function](<https://devfeed.tech/topics/factory-function.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [create](<https://devfeed.tech/tags/create.md>), [generics](<https://devfeed.tech/tags/generics.md>), [go](<https://devfeed.tech/tags/go.md>), [how-to](<https://devfeed.tech/tags/how-to.md>), [interfaces](<https://devfeed.tech/tags/interfaces.md>), [like](<https://devfeed.tech/tags/like.md>), [refactor](<https://devfeed.tech/tags/refactor.md>)

### AI overview

A Go tutorial explains how generics can reduce duplicated method implementations when multiple response structs must satisfy the same interfaces. It demonstrates applying a reusable generic response to JSON:API-formatted responses and adding a factory function for readability.

### Source excerpt

I recently worked on a project that had a lot of code duplication due to repeated implementations of the same interfaces. I quickly realized it was a great opportunity to refactor...

## How derivedStateOf Works in Jetpack Compose's Snapshot System

DevFeed: [How derivedStateOf Works in Jetpack Compose's Snapshot System](<https://devfeed.tech/articles/how-derivedstateof-works-a-deep-d-er-ive-30529.md>)

Original publisher: [Read original article](<https://blog.zachklipp.com/how-derivedstateof-works-a-deep-d-er-ive/>)

Author: Zach Klippenstein

Published: 2024-07-16T16:58:52Z

Content type: tutorial

Language: en

Sources: [Zach Klippenstein's Blog](<https://devfeed.tech/sources/zach-klippenstein-s-blog.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [reactive](<https://devfeed.tech/topics/reactive.md>), [Library](<https://devfeed.tech/topics/library.md>), [factory function](<https://devfeed.tech/topics/factory-function.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [code](<https://devfeed.tech/tags/code.md>), [compose](<https://devfeed.tech/tags/compose.md>), [compose-state-series](<https://devfeed.tech/tags/compose-state-series.md>), [function](<https://devfeed.tech/tags/function.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [reactive](<https://devfeed.tech/tags/reactive.md>), [snapshots](<https://devfeed.tech/tags/snapshots.md>), [state](<https://devfeed.tech/tags/state.md>)

### AI overview

This tutorial explains how derivedStateOf works within Jetpack Compose's reactive snapshot system. It introduces the returned object, related concepts such as restartable functions and state dependencies, and the role of state-derived calculations, using Compose source code and examples.

### Source excerpt

Compose's snapshot system is really neat. Once you know how it works, you can do some cool tricks with it, and derivedStateOf is a rich example

## Composed modifiers in Jetpack Compose

DevFeed: [Composed modifiers in Jetpack Compose](<https://devfeed.tech/articles/composed-modifiers-in-jetpack-compose-27464.md>)

Original publisher: [Read original article](<https://jorgecastilloprz.github.io/composed-modifiers-in-jetpack-compose>)

Author: Jorge Castillo

Published: 2022-04-04T10:00:00Z

Content type: tutorial

Language: en

Sources: [👨💻 Jorge Castillo](<https://devfeed.tech/sources/jorge-castillo.md>)

Topics: [Jetpack Compose](<https://devfeed.tech/topics/jetpack-compose.md>), [ui](<https://devfeed.tech/topics/ui.md>), [context](<https://devfeed.tech/topics/context.md>), [factory function](<https://devfeed.tech/topics/factory-function.md>), [Library](<https://devfeed.tech/topics/library.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [compose](<https://devfeed.tech/tags/compose.md>), [compose-ui](<https://devfeed.tech/tags/compose-ui.md>), [context](<https://devfeed.tech/tags/context.md>), [extension-function](<https://devfeed.tech/tags/extension-function.md>), [factory-function](<https://devfeed.tech/tags/factory-function.md>), [jetpack](<https://devfeed.tech/tags/jetpack.md>), [jetpack-compose](<https://devfeed.tech/tags/jetpack-compose.md>), [modifiers](<https://devfeed.tech/tags/modifiers.md>), [state](<https://devfeed.tech/tags/state.md>), [stateful](<https://devfeed.tech/tags/stateful.md>), [stateless](<https://devfeed.tech/tags/stateless.md>)

### AI overview

This tutorial explains the difference between standard and composed modifiers in Jetpack Compose. Standard modifiers use extension functions and are stateless, while composed modifiers support state and access to composition context by creating them within a Composition.

### Source excerpt

Learn about composed modifiers and compare those to standard ones.

## Kotlin Delegated Properties for Designing a Simple Android Library API

DevFeed: [Kotlin Delegated Properties for Designing a Simple Android Library API](<https://devfeed.tech/articles/delightful-delegate-design-27043.md>)

Original publisher: [Read original article](<https://web.archive.org/web/20200513142755/https://blog.autsoft.hu/delightful-delegate-design/>)

Author: Márton Braun

Published: 2019-04-11T19:00:00Z

Content type: tutorial

Language: en

Sources: [zsmb.co](<https://devfeed.tech/sources/zsmb-co.md>)

Topics: [API](<https://devfeed.tech/topics/api.md>), [Kotlin](<https://devfeed.tech/topics/kotlin.md>), [Library](<https://devfeed.tech/topics/library.md>), [implementation](<https://devfeed.tech/topics/implementation.md>), [Android](<https://devfeed.tech/topics/android.md>), [properties](<https://devfeed.tech/topics/properties.md>), [factory function](<https://devfeed.tech/topics/factory-function.md>)

Tags: [android](<https://devfeed.tech/tags/android.md>), [api](<https://devfeed.tech/tags/api.md>), [api-design](<https://devfeed.tech/tags/api-design.md>), [delegates](<https://devfeed.tech/tags/delegates.md>), [factory-function](<https://devfeed.tech/tags/factory-function.md>), [implementation](<https://devfeed.tech/tags/implementation.md>), [kotlin](<https://devfeed.tech/tags/kotlin.md>), [library](<https://devfeed.tech/tags/library.md>), [properties](<https://devfeed.tech/tags/properties.md>)

### AI overview

This tutorial explains API design choices in the Krate Android SharedPreferences wrapper. It shows how Kotlin delegated properties can encapsulate reusable logic, persist values across application restarts, and hide concrete implementations behind a simple interface and factory function.

### Source excerpt

When developing a library, designing an easy to use API while hiding unnecessary implementation details from clients is fundamental. Let's look at some API design choices we've made for our library Krate, an Android SharedPreferences wrapper.