Skip to content

Instantly share code, notes, and snippets.

View StevenACoffman's full-sized avatar

Steve Coffman StevenACoffman

View GitHub Profile

Clean Architecture (2022 H2)

Good architecture:

  • good architecture = allow changes w/ flexibility + delay decision

Business rules:

  • Entities: pure; small sets of critical business rules. Should be most independent & reusable. Can be an object with methods or data structures & functions
  • Use case: not as pure; is an object. contains data elements & operations.
  • Entities are lower level than (don’t depend on) use cases since use cases are closer to inputs/outputs.
  • Entities & use cases are 2 layers
@StevenACoffman
StevenACoffman / CommandPatternInGo.md
Created March 20, 2025 17:28
CommandPatternInGo.md

If you have several tools that are very closely related, you can make them easier to use, discover, and distribute by combining them into a single tool (and a single executable binary artifact).

If you’ve got a tool that’s sufficiently complex, you can reduce its complexity by making a set of subcommands. This is also useful for sharing stuff—global flags, help text, configuration, storage mechanisms.The above guidance doesn’t help you to decide when something is unrelated and should be separated, BTW.

It is worth comparing this advice to the Command Pattern from the “Gang of Four” “Design Patterns” book, where you encapsulate an an action or a request as an object that can be parameterized. Usually, in the Command Design Pattern the invoker doesn’t know anything about the implementation details of the command or it’s receiver, it just knows the command interface and its only responsibility is to invoke the command and optionally do some bookkeeping of what commands are possible and/or valid. There are

@StevenACoffman
StevenACoffman / workload_federation_dwd.go
Created January 30, 2025 01:24 — forked from salrashid123/workload_federation_dwd.go
Access GCP and workspace APIs using GCP Workload Identity Federation usign Domain Delegation
package main
import (
"fmt"
"log"
"context"
"cloud.google.com/go/storage"
@StevenACoffman
StevenACoffman / dwd.go
Created January 29, 2025 18:23 — forked from salrashid123/dwd.go
Gsuites domain wide delegation/impersonation
package main
import (
"fmt"
"io/ioutil"
"log"
"context"
"cloud.google.com/go/storage"
@StevenACoffman
StevenACoffman / numbers-to-words.go
Created January 6, 2025 21:45 — forked from knadh/numbers-to-words.go
Simple algorithm for converting numbers to English words (Golang)
package main
import (
"fmt"
)
var (
ones = []string{
"zero", "one", "two", "three", "four",
"five", "six", "seven", "eight", "nine",
package main
import (
"fmt"
"go/ast"
"go/parser"
"go/token"
)
func main() {
@StevenACoffman
StevenACoffman / room.go
Last active October 20, 2024 19:57
Four Digit room code to integer
// https://go.dev/play/p/CxJf4Jf9rDZ
package main
import (
"fmt"
"strings"
)
const ZZZZ = 18279 + 456975