Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create a small data class for the return type of Optic.get*Shapes() #167

Closed
zepumph opened this issue Aug 4, 2021 · 7 comments
Closed
Assignees

Comments

@zepumph
Copy link
Member

zepumph commented Aug 4, 2021

I think it would be a bit more clear if instead of returning an object literal of shape keys, there was a private class that was a data type that stored those fields, and then the return type could be that class.

Something like OpticShapeCollection or OpticShapeStorage or ShapesForOptic. Up to you if you want to do this.

@zepumph
Copy link
Member Author

zepumph commented Aug 4, 2021

#154

@zepumph
Copy link
Member Author

zepumph commented Aug 4, 2021

Up to you if you want to do this.

Actually, now that I see

// @public {Property.<Object>} shapes (fill and outline) of the optical element
this.shapesProperty = new DerivedProperty( [
this.radiusOfCurvatureProperty,
this.diameterProperty,
this.curveProperty ],
( radius, diameter, curve ) => {
return this.getShapes( radius, diameter, curve );
} );
, I would say definitely do this IMO.

@veillette
Copy link
Contributor

I agree.

@veillette
Copy link
Contributor

I created an OpticShapeCollection class that hosts all the shapes for rendering and ray hitting. In the process, I realized that the middleShape was unused and was therefore removed (see #171).

Overall, that is a nice improvement, that simplifies the optic class.
Assigning back to @zepumph for review.

@veillette veillette assigned zepumph and unassigned veillette Aug 5, 2021
zepumph added a commit that referenced this issue Aug 5, 2021
@zepumph
Copy link
Member Author

zepumph commented Aug 5, 2021

This is really excellent. I wasn't even thinking of being able to factor out the shape creation functions. This is a great divide of responsibility! Nice work.

  • I would recommend setting all instance variables to null in the constructor, and documenting which of them may actually be set to null (not have a shape) after construction, and for which optic type that may occur.
  • Optic.shapesProperty could be optionally renamed to Optic.shapeCollectionProperty. A bit clearer to go with the rename.

Thanks!

@zepumph zepumph assigned veillette and unassigned zepumph Aug 5, 2021
@pixelzoom pixelzoom assigned pixelzoom and unassigned veillette Sep 16, 2021
@pixelzoom
Copy link
Contributor

pixelzoom commented Sep 16, 2021

Looks like these still a bit of work to be done here, as suggested in #167 (comment). So self assigning.

@pixelzoom
Copy link
Contributor

All recommendations have been implemented. Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants