mxcl / Cake

A delicious, quality‑of‑life supplement for your app‑development toolbox.
Apache License 2.0
537 stars 15 forks source link

Consider "Sources•Modules" rather than "Sources•Model" #48

Open gcox opened 5 years ago

gcox commented 5 years ago

First, 👏thank you👏 for taking a shot at fixing the problem you're trying to solve! I'm frustrated by the tooling standing in the way of modularizing Swift codebases all day long every day. So, I really hope this tool takes off. 🎉


I may not be understanding everything (or much at all) so I'll break this up into my assumptions, my use case, and then my suggestion(s)...all based on those assumptions 😄

Assumptions

Use case

For my situation, micro modules would offer just as much benefit to my application-specific code as my domain/model code. In fact, my UI code would probably benefit even more. That is where I find myself using nested types for the sole purpose of faking namespaces more frequently than anywhere else. Nested types are fine, but I've found that Xcode/SourceKit/Something-else-in-the-tool-chain falls over after a certain depth and all I see is <<error type>> in Xcode's autocomplete dialogs.

Suggestions

  1. Add support for limiting which platforms a specific module is built for. Maybe that takes the form of a Cakefile in a module's directory, or platform-specific "Sources•Modules•[platform]" directories...which could be auto generated using the platforms setting in the root Cakefile. The goal being platform-specific-modules in a multi-platform project.
  2. Rename "Sources•Model" to "Sources•Modules"

To be clear, this is only necessary for a multi-platform project. What I'm wanting to do is already totally doable for a single-platform project.

mxcl commented 5 years ago

Hi, thanks for the thorough write up. I think what we should do is allow specification of the location of module hierarchies and allow multiple hierarchies. Something like:

import Cakefile

let base = moduleHeirarchies[0]  // defaults to standard base, ie. Sources/Model
base.path = "Sources/Modules"    // if you like

var iOS = ModuleHeirarchy()
iOS.path = "Sources/iOS.Modules"
iOS.platforms = [.iOS ~> 12]
iOS.dependencies = [base]
moduleHeirarchies.append(iOS)

let tvOS = ModuleHeirarchy(path: /*…*/, platforms: /*…*/, dependencies: [base])
moduleHeirarchies.append(tvOS)

This is not a trivial change, but would be pretty useful, I could already use this in several apps.