In this thread, Jeremy David Giesbrecht (@SDGGiesbrecht) did a great breakdown of the difference between SPM's targets and modules:
Having understood that, I'm still not sure how to apply those definitions towards structuring my code. My codebase has been growing, and I'm looking to modularize it and get more serious about enforcing architectural boundaries. I have several different components I've identified:
- UI helpers (UI code that could be reused in other apps)
- UI (UI code that's fairly specific to my one app, often a concrete use of the helpers in #1)
- System utilities, extensions/wrappers to platform features, etc.
- Several networking "gateways" that wrap third party web APIs
- A datastore service that isolates
- Generic data structures/algorithms
And so on, you get the point.
Ultimately, these will all be used by my one Mac App, but I would still like to enforce clean interfaces around them, so I can reduce some of the interdependence (a fancy word for spaghetti code ). In a sense, I'm trying to get back some of the access control that Java packages got me used to.
Should "components" like these be targets within one package, or independent packages (each with one target)?