Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

mobile-design-patterns

БесплатноБез исполняемых скриптовНе проверен

Chooses and implements design patterns in Kotlin, Java, Swift and Dart mobile code: Repository, Factory, Strategy, Observer, Adapter, Decorator, Facade, State…

ahmadhussain0335от ahmadhussain0335242 установки в других каталогах

Об этом скилле

Mobile design patterns

Pick the smallest structure that solves a real problem in Android, iOS or Flutter code, implement it idiomatically for the language, and remove patterns that only add indirection.

When to use

  • Structuring a new feature, data source, SDK wrapper, device protocol or navigation flow.
  • Refactoring long when / switch chains, boolean state flags, god classes or copy-pasted wrappers.
  • Reviewing code full of *Manager, *Factory, *Builder, *Impl names and deciding which ones earn their place.
  • Modelling a lifecycle (BLE connection, upload, onboarding, checkout) as an explicit state machine.
  • Deciding between thrown exceptions and typed results at a layer boundary.

Not for: whole-app architecture (use mobile-mvvm, mobile-mvi, mobile-mvc) or security design (use mobile-security).

Workflow

  1. Write the problem in one sentence before naming a pattern: "X changes independently of Y because Z". No sentence, no pattern.
  2. Check whether the language already solves it: named and default arguments, by delegation, function types, sealed types, Flow / AsyncSequence / Stream, protocol extensions. Prefer the language feature.
  3. Find the problem in the selection table and read the matching rule, including its "Skip when" line.
  4. Load the language reference for full implementations: Kotlin, Swift, Dart, Java.
  5. Implement the smallest version. Add an interface or protocol only for a second implementation, a test seam or a module boundary.
  6. Wire collaborators through constructor injection, never through globals.
  7. Unit test what the pattern isolates: transitions, strategies, mappers, decorators, command ordering.
  8. When reviewing, name the cost of a misused pattern (extra files, indirection, test burden) and show the simpler alternative.

Pattern selection

Problem Pattern Mobile example Skip when
UI must not know if data comes from network, database or cache Repository Room or Core Data as source of truth, API refreshes it One read-only source, no mapping, no caching
Concrete type depends on runtime input Factory Exporter per format, message type from JSON Only one type, or DI already builds it
Many optional parameters Named / default args (Builder only in Java) Notification spec, request options Kotlin, Swift, Dart: almost always skip Builder
One shared instance DI scope (@Singleton, app container) HTTP client, database, BLE manager Never hand-roll a mutable global
Interchangeable algorithm Strategy, often just a function Retry backoff, sort order, image compression Only one algorithm and no test need
React to changing values Observer via platform streams Connection state, database queries One-shot value: use a suspend / async function
Foreign API does not fit your interface Adapter Callback SDK to suspend / async, DTO to domain You own both sides: change the interface
Add caching, logging, retry or metrics without editing a class Decorator Timed or caching repository It belongs on every call: put it in the class or an HTTP interceptor
Multi-step subsystem used from many places Facade DeviceSession.open() hides connect, MTU, discovery, notifications It starts holding UI state: split it
Behaviour depends on phase; some transitions are illegal State machine BLE connection, upload, onboarding Two states a single Boolean models correctly
Operations must be queued, serialized, retried or undone Command GATT operation queue, undoable edits Fire-and-forget call with no ordering needs
Flow logic spread across screens Coordinator / Router Onboarding, deep links, auth gate One push from list to detail
Expected failures are part of the API Result / sealed errors / typed throws Network, validation, pairing errors Programmer errors: let them crash
Reuse behaviour or call back to an owner Delegation Kotlin by, CBCentralManagerDelegate Inheritance is not involved and a lambda suffices

Rules

1. An abstraction needs a reason

Kotlin:

// BAD: interface + Impl with one implementation, no fake, same module
interface DateFormatter { fun format(i: Instant): String }
class DateFormatterImpl : DateFormatter { ... }

// GOOD: a plain class until a second implementation, a test fake or a module boundary appears
class DateFormatter(private val zone: ZoneId) { fun format(i: Instant): String = ... }

Valid reasons for an interface or protocol: a fake in ViewModel tests, a domain module that must not see the data module, multiple real implementations, a platform split (KMP expect / actual).

2. Repository: one source of truth, domain types out

// BAD: ViewModel talks to Retrofit and Room directly and exposes DTOs
class DevicesViewModel(private val api: DeviceApi,
Полный SKILL.md на ClawHub

Установить mobile-design-patterns в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

FAQ

Что делает скилл mobile-design-patterns?

Chooses and implements design patterns in Kotlin, Java, Swift and Dart mobile code: Repository, Factory, Strategy, Observer, Adapter, Decorator, Facade, State machine, Command, Coordinator, Result types and Delegation, with a selection table and over-engineering warnings. Use when picking a pattern, refactoring god classes or flag-driven state, wrapping an SDK, or when a design feels over-abstracted.

Как установить скилл mobile-design-patterns?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл mobile-design-patterns запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить mobile-design-patterns с