fornjot icon indicating copy to clipboard operation
fornjot copied to clipboard

Replace builder API with partial object API

Open hannobraun opened this issue 3 years ago • 1 comments

As part of my work on #1079, I've introduced a new [partial object API]. Please follow that link to learn more about it, there's quite a bit of documentation. This API grew out of the builder API and is designed to replace it. But so far, only some parts of the builder API have been converted into the partial object API. I expect that parts of the builder API will still exist when I finish #1079.

Eventually, all of the builder API should be migrated over. The following list reflects the current progress:

  • [x] CurveBuilder
  • [x] GlobalCurveBuilder
  • [x] GlobalEdgeBuilder
  • [x] GlobalVertexBuilder
  • [x] HalfEdgeBuilder
  • [x] SurfaceVertexBuilder
  • [x] VertexBuilder
  • [x] CycleBuilder (https://github.com/hannobraun/Fornjot/pull/1169)
  • [ ] FaceBuilder
  • [ ] ShellBuilder
  • [ ] SketchBuilder
  • [ ] SolidBuilder

If anyone is interested in taking a look, here's the process I've been using to migrate parts of the builder API:

  1. Copy a sub-module from builder to partial::objects.
  2. Update the builder structs to match the style and capability of the partial object structs:
    • Change their name.
    • Make sure all of their fields are optional and reflect the fields of their full object variant.
    • Add with_ methods for all of their fields.
    • Replace all of their build_ methods with as_ and from_ methods.
    • Give them a single build methods that is the only code that has access to Stores.
  3. Integrate them into partial object infrastructure (Partial, HasPartial, MaybePartial).

If in doubt, use the existing partial object API as a template, and always feel free to ask questions here.

hannobraun avatar Sep 28 '22 11:09 hannobraun

I've replaced CycleBuilder with PartialCycle in #1169 and updated the list in the issue description.

hannobraun avatar Oct 05 '22 12:10 hannobraun

~~That this isn't finished is causing me some trouble with other work. I'm going to start finishing this now.~~

Oops, this is the wrong issue. Please disregard.

hannobraun avatar Oct 21 '22 13:10 hannobraun