Replies: 3 comments
-
|
I've added |
Beta Was this translation helpful? Give feedback.
-
|
In #53 I inined the newly deprecated methods so they're not called anywhere in the Bosk codebase itself. I'll ship a release with this change, so that users can pull in that release and inline the methods in their own code before upgrading to a version without them. |
Beta Was this translation helpful? Give feedback.
-
|
Alright, this was completed in #54 has shipped in version 0.0.94. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
In recent work on #22 I've had an idea.
Background
Problems
There are two separate birds here we might be able to kill with one stone.
Problem 1: Plethora of reference creation methods
There are three different ways to create references right now:
Bosk.buildReferencesBoskreference factory methodsReference.thenmethods1 is recommended wherever it's applicable. 2 and 3 are meant for dynamic situations where the path isn't known at development time.
Given that most applications should be using 1 only, it seems odd that 2 and 3 are so prominent in the API, comprising fourteen methods in five classes (
Bosk,Reference, and threeReferencesubtypes), while 1 is just one simple method.It's also not clear in the design which methods are the fundamental "primary" ones and which are "helpers". It turns out
Bosk.referenceis the fundamental one, and the rest ultimately call that method.It would be nice to have a clean design with just enough helpers to make things convenient for users.
Problem 2: Passing
BosktoDriverFactoryOne of the things the
Boskclass does is to act as a factory forReferenceobjects. This is ... okay I guess. TheBoskclass has a lot of responsibilities, and is a bit of a god class, but it works ok in practice, so I've procrastinated on trying to get systematic about the reference factory functionality.The one place where this is really weird is when we're calling the
DriverFactoryfunction in theBoskconstructor. We want drivers to be able to create references, so theDriverFactoryaccepts aBoskobject as an argument; however, at this point, theBoskobject is not yet fully initialized because its constructor is still running. Again, this works ok in practice, but it is a bit weird to hand someone an object that won't entirely work yet.It would be nice to have a cleaner way to allow
DriverFactoryimplementations to create references that does not involve passing them a half-bakedBoskobject.Side note: Specialized reference types
We already have several specialized
Referencesubtypes for convenience in certain cases:CatalogReference<E>is equivalent toReference<Catalog<E>>ListingReference<E>is equivalent toReference<Listing<E>>SideTableReference<K,V>is equivalent toReference<SideTable<K,V>>Each of these subtypes offers two conveniences:
thenmethod that doesn't throwInvalidTypeException, andbindmethods that return the same subtype.The intent is to eliminate unneeded
catch (InvalidTypeException ...)code in situations where a type error is known to be impossible. (In a world withbuildReferences, it's not clear this benefit is worth the complexity, but perhaps that is a question for another time.)The idea
Create a new
Referencesubtype calledRootReferencerepresenting the reference whose path is/. This object would be the canonical reference factory. AllBoskreference-creating methods, with the exception ofrootReference, would move to theRootReferenceclass, includingbuildReferences. TheRootReferenceclass would havethenmethods that acceptPathobjects, allowing arbitrary references to be created dynamically.RootReferencewould act like our reference factory. TheBoskobject itself wouldn't do this anymore.Change
DriverFactoryto accept aRootReferenceinstead of aBosk.Caveats
There are some downsides to removing the
Boskargument toDriverFactory:Boskfunctionality that they can currently use, likeinstanceID()orname().Boskobject. It's unclear whether this is a bug or a feature.Beta Was this translation helpful? Give feedback.
All reactions