BHoM / admin

Repository for raising central issues and questions; Regarding governance, process and multi-repo and framework compliance
GNU Lesser General Public License v3.0
0 stars 0 forks source link

Unified strategy for GUID, Hash, and Copy/DeepCopy #9

Closed alelom closed 3 years ago

alelom commented 4 years ago

We need a unified strategy as title. In light of the meeting tomorrow morning, we should go through the following points:

Instructions for the changes on Clone methods can be found on this comment below: https://github.com/BHoM/admin/issues/9#issuecomment-709032648

adecler commented 3 years ago

I'll create the list of methods calling DeepClone and ShallowClone soon.

adecler commented 3 years ago

First, here's the list of methods that contain Clone in their name and are called by at least on non-clone method:

BH.oM.Base.BHoMObject.GetShallowClone
BH.Engine.Base.Query.DeepClone
BH.oM.Base.IBHoMObject.GetShallowClone
BH.Engine.Geometry.Query.Clone
BH.Engine.Geometry.Query.IClone
BH.Engine.Base.Query.ShallowClone

The ShallowClone methods could probably do with a bit of clearing.

adecler commented 3 years ago

Here's the list of Modify methods that are calling one of the Clone methods above:

Full list

``` BH.Engine.Adapters.ETABS.Modify.SetDiaphragm(Panel panel, Diaphragm diaphragm) BH.Engine.Adapters.ETABS.Modify.SetPier(Panel panel, Pier pier) BH.Engine.Adapters.ETABS.Modify.SetShellType(ISurfaceProperty property, ShellType shellType) BH.Engine.Adapters.ETABS.Modify.SetSpandrel(Panel panel, Spandrel spandrel) BH.Engine.Adapters.Filing.Modify.AddContent(FSFile file, List content) BH.Engine.Adapters.Filing.Modify.ChangeDirectory(IFSContainer fileOrDir, FSDirectory to) BH.Engine.Adapters.Filing.Modify.RemoveContent(FSFile file) BH.Engine.Adapters.Filing.Modify.Rename(IFSContainer fileOrDir, String name) BH.Engine.Adapters.GSA.Modify.SetAnalysisType(LoadCombination loadcombination, AnalysisType analysisType, Int32 stage) BH.Engine.Adapters.IES.Modify.RepairOpening(Opening opening, Panel host, List panelsAsSpace) BH.Engine.Adapters.IES.Modify.RepairOpening(Opening opening, Panel hostPanel, PanelType hostType) BH.Engine.Adapters.Plaxis.Modify.ApplyPlaxisStiffnessModifier(ConstantThickness thicknessProperty, Double e1Factor, Double e2Factor, and 4 more inputs) BH.Engine.Adapters.Plaxis.Modify.ApplyPlaxisStiffnessModifier(Panel panel, Double e1Factor, Double e2Factor, and 4 more inputs) BH.Engine.Adapters.Revit.Modify.AddParameterLinks(ParameterMap parameterMap, and 2 more inputs) BH.Engine.Adapters.Revit.Modify.AddParameterLinks(ParameterSettings parameterSettings, Type type, and 2 more inputs) BH.Engine.Adapters.Revit.Modify.AddParameterMaps(ParameterSettings parameterSettings, IEnumerable parameterMaps, Boolean merge) BH.Engine.Adapters.Revit.Modify.Append(FamilyLibrary familyLibrary, String directory, Boolean topDirectoryOnly) BH.Engine.Adapters.Revit.Modify.Append(FamilyLibrary familyLibrary, String path) BH.Engine.Adapters.Revit.Modify.Move(ModelInstance modelInstance, Vector vector) BH.Engine.Adapters.Revit.Modify.RemoveIdentifiers(IBHoMObject bHoMObject) BH.Engine.Adapters.Revit.Modify.RemoveParameterLinks(ParameterMap parameterMap, IEnumerable propertyNames) BH.Engine.Adapters.Revit.Modify.RemoveParameterLinks(ParameterSettings parameterSettings, Type type, IEnumerable propertyNames) BH.Engine.Adapters.Revit.Modify.RemoveParameterMaps(ParameterSettings parameterSettings, IEnumerable types) BH.Engine.Adapters.Revit.Modify.SetFamilyLibrary(FamilyLoadSettings familyLoadSettings, FamilyLibrary familyLibrary) BH.Engine.Adapters.Revit.Modify.SetFamilyLibrary(RevitSettings revitSettings, FamilyLibrary familyLibrary) BH.Engine.Adapters.Revit.Modify.SetMapSettings(RevitSettings revitSettings, ParameterSettings mapSettings) BH.Engine.Adapters.Revit.Modify.SetRevitParameter(IBHoMObject bHoMObject, String paramName, Object value) BH.Engine.Adapters.Revit.Modify.SetRevitParameters(IBHoMObject bHoMObject, List paramNames, List values) BH.Engine.Adapters.Revit.Modify.SetTag(IBHoMObject bHoMObject, String tag) BH.Engine.Adapters.Revit.Modify.UpdateCustomDataValue(IBHoMObject bHoMObject, String name, Object value) BH.Engine.Adapters.TAS.Modify.SetTag(IBHoMObject bHoMObject, String tag) BH.Engine.Adapters.TAS.Modify.UpdateCustomDataValue(IBHoMObject bHoMObject, String name, Object value) BH.Engine.Analytical.Modify.SetElements0D(ILink link, List newElements0D) BH.Engine.Analytical.Modify.SetGeometry(IEdge edge, ICurve curve) BH.Engine.Analytical.Modify.SetGeometry(ILink link, ICurve curve) BH.Engine.Analytical.Modify.SetGeometry(INode node, Point point) BH.Engine.Analytical.Modify.SetInternalElements2D(IPanel panel, List openings) BH.Engine.Analytical.Modify.SetOutlineElements1D(IOpening opening, IEnumerable edges) BH.Engine.Analytical.Modify.SetOutlineElements1D(IPanel panel, IEnumerable edges) BH.Engine.Analytical.Modify.SetOutlineElements1D(IRegion region, IEnumerable outlineElements) BH.Engine.Architecture.Modify.CleanRoom(Room room, Double angleTolerance, Double minimumSegmentLength) BH.Engine.Architecture.Modify.SetGeometry(Grid grid, ICurve curve) BH.Engine.Architecture.Modify.SetGeometry(Room room, Point locationPoint, ICurve perimeterCurve) BH.Engine.Architecture.Modify.SetOutlineElements1D(Room room, List outlineElements1D) BH.Engine.Audience.Modify.Cut(SeatingBay seatingBay, List cutters, Boolean keepOutside, and 1 more inputs) BH.Engine.Audience.Modify.Cut(Stand stand, List cutters, Boolean keepOutside, and 1 more inputs) BH.Engine.Audience.Modify.MapProfile(TierProfile originalSection, Vector scale, Point source, and 2 more inputs) BH.Engine.Audience.Modify.ReorderBays(SeatFrontPlan seatFrontPlan, Int32 shift) BH.Engine.Audience.Modify.ReorderBays(VenueSeating venueSeating, Int32 shift) BH.Engine.Audience.Modify.SeatingBayRows(SeatingBay seatingBay) BH.Engine.Base.Modify.AddFragment(IBHoMObject iBHoMObject, IFragment fragment, Boolean replace) BH.Engine.Base.Modify.RemoveFragment(IBHoMObject iBHoMObject, Type fragmentType) BH.Engine.CableNetDesign.Modify.SetNbCables(GravityCableNet cableNet, Int32 nbTensionRingCables, Int32 nbRadialCables) BH.Engine.CableNetDesign.Modify.SetPrestress(Bar bar, Double prestress, Boolean keepExactForce) BH.Engine.CableNetDesign.Modify.SetSlackLength(Bar bar, Double slackLength, Boolean keepExactForce) BH.Engine.CableNetDesign.Modify.SetSlackLengthScale(Bar bar, Double slackLengthScale, Boolean keepExactForce) BH.Engine.CableNetDesign.Modify.SizeCable(Bar bar, BarForce force, Double factorOfSaftey, and 2 more inputs) BH.Engine.CableNetDesign.Modify.SizeCables(GravityCableNet cableNet, Double factorOfSafety, Double contingency, and 1 more inputs) BH.Engine.CableNetDesign.Modify.SizeCableSection(CableSection section, BarForce force, Double factorOfSafety, and 2 more inputs) BH.Engine.Diffing.Modify.SetHashFragment(T obj, DiffConfig diffConfig) BH.Engine.Diffing.Modify.SetHashFragment(T obj, String hash) BH.Engine.Environment.Modify.AddAdjacentSpace(Panel panel, String spaceName) BH.Engine.Environment.Modify.AddOpening(Panel panel, Opening opening) BH.Engine.Environment.Modify.AssignGenericConstructions(Opening opening) BH.Engine.Environment.Modify.AssignGenericConstructions(Panel panel, Boolean assignOpenings) BH.Engine.Environment.Modify.ChangeAdjacentSpace(Panel panel, String spaceNameToChange, String replacementSpaceName) BH.Engine.Environment.Modify.Copy(Panel panel) BH.Engine.Environment.Modify.FixNormal(List> panelsAsSpaces) BH.Engine.Environment.Modify.RemoveOpening(List panels) BH.Engine.Environment.Modify.RemoveOpeningsByName(List panels, String openingName) BH.Engine.Environment.Modify.SetAdjancentSpaces(Panel panel, List spaceNames) BH.Engine.Environment.Modify.SetGeometry(Edge edge, ICurve curve) BH.Engine.Environment.Modify.SetGeometry(Node node, Point point) BH.Engine.Environment.Modify.SetGeometry(Opening opening, ICurve curve) BH.Engine.Environment.Modify.SetGeometry(Panel panel, ICurve curve) BH.Engine.Environment.Modify.SetGeometry(Space space, Point locationPoint) BH.Engine.Environment.Modify.SetInternalElements2D(Panel panel, List internalElements2D) BH.Engine.Environment.Modify.SetOpeningType(List openings, OpeningType openingType) BH.Engine.Environment.Modify.SetOutlineElements1D(Opening opening, List outlineElements1D) BH.Engine.Environment.Modify.SetOutlineElements1D(Panel panel, List outlineElements1D) BH.Engine.Environment.Modify.SetOutlineElements1D(Space space, List outlineElements1D) BH.Engine.Environment.Modify.Split(List panels) BH.Engine.Environment.Modify.Split(Panel panel, List cuttingLines) BH.Engine.Environment.Modify.Split(Panel panel, Panel cuttingPanel) BH.Engine.Environment.Modify.SplitOpeningByGeometry(Opening opening, List polylines) BH.Engine.Environment.Modify.SplitPanelByGeometry(Panel panel, List polylines) BH.Engine.FormFinding.Modify.AddBoundaryCondition(RelaxSystem system, IBoundaryCondition bc, Double tolerance) BH.Engine.FormFinding.Modify.AddForceObject(RelaxSystem system, IForceObject forceObject, Double tolerance) BH.Engine.FormFinding.Modify.MergeUnaryForces(RelaxSystem system) BH.Engine.Geometry.Modify.CollapseToPolyline(Polyline curve, Double angleTolerance, Int32 maxSegmentCount) BH.Engine.Geometry.Modify.Flip(NurbsCurve curve) BH.Engine.Geometry.Modify.Normalise(Vector vector) BH.Engine.Geometry.Modify.Offset(Arc curve, Double offset, Vector normal, and 2 more inputs) BH.Engine.Geometry.Modify.Offset(Circle curve, Double offset, Vector normal, and 2 more inputs) BH.Engine.Geometry.Modify.Project(Circle circle, Plane p) BH.Engine.Geometry.Modify.ProjectAlong(Circle circle, Plane plane, Vector vector) BH.Engine.Geometry.Modify.SetGeometry(Arc curve, ICurve newCurve) BH.Engine.Geometry.Modify.SetGeometry(Circle curve, ICurve newCurve) BH.Engine.Geometry.Modify.SetGeometry(Ellipse curve, ICurve newCurve) BH.Engine.Geometry.Modify.SetGeometry(Grid grid, ICurve curve) BH.Engine.Geometry.Modify.SetGeometry(Line curve, ICurve newCurve) BH.Engine.Geometry.Modify.SetGeometry(NurbsCurve curve, ICurve newCurve) BH.Engine.Geometry.Modify.SetGeometry(Point point, Point newPoint) BH.Engine.Geometry.Modify.SetGeometry(PolyCurve curve, ICurve newCurve) BH.Engine.Geometry.Modify.SetGeometry(Polyline curve, ICurve newCurve) BH.Engine.Geometry.Modify.SortCurves(PolyCurve curve, Double tolerance) BH.Engine.Geometry.Modify.SplitAtPoints(Arc arc, List points, Double tolerance) BH.Engine.Geometry.Modify.SplitAtPoints(Circle circle, List points, Double tolerance) BH.Engine.Geometry.Modify.SplitAtPoints(Line line, List points, Double tolerance) BH.Engine.Geometry.Modify.SplitAtPoints(PolyCurve curve, List points, Double tolerance) BH.Engine.Geometry.Modify.SplitAtPoints(Polyline curve, List points, Double tolerance) BH.Engine.Geometry.Modify.Translate(Circle curve, Vector transform) BH.Engine.Geometry.Modify.Translate(Extrusion surface, Vector transform) BH.Engine.Geometry.Modify.Translate(Plane plane, Vector transform) BH.Engine.MEP.Modify.SetGeometry(IFlow obj, ICurve curve) BH.Engine.MEP.Modify.SetGeometry(Node node, Point point) BH.Engine.ModelLaundry.Modify.SnapToElements(IElement0D element0D, IEnumerable refElements, Double maxDistance, and 1 more inputs) BH.Engine.Physical.Modify.SetGeometry(IFramingElement framingElement, ICurve curve) BH.Engine.Physical.Modify.SetInternalElements2D(ISurface surface, List internalElements2D) BH.Engine.Physical.Modify.SetOutlineElements1D(IOpening opening, List outlineElements1D) BH.Engine.Physical.Modify.SetOutlineElements1D(ISurface surface, List outlineElements1D) BH.Engine.Reflection.Modify.PropertyValue(BHoMObject obj, String propName, Object value) BH.Engine.Representation.Modify.SetRendermesh(IBHoMObject bHoMObject, IGeometry representation, String customDataKey) BH.Engine.Spatial.Modify.SetInternalElements2D(IElement2D element2D, List newElements2D) BH.Engine.Structure.Bridges.Modify.SetProperties(Ladder ladder, ISectionProperty primaryMember, ISectionProperty crossMember, and 3 more inputs) BH.Engine.Structure.Bridges.Modify.SetProperties(Truss truss, ISectionProperty topChord, ISectionProperty bottomChord, and 4 more inputs) BH.Engine.Structure.Elements.Modify.SetCutback(IFramingElement framingElement, Double start, Double end) BH.Engine.Structure.Elements.Modify.SetEndNormals(IFramingElement framingElement, Vector start, Vector end) BH.Engine.Structure.Modify.AddReinforcement(ConcreteSection section, and 1 more inputs) BH.Engine.Structure.Modify.ApplyModifiers(ISectionProperty prop, Double area, Double iy, and 4 more inputs) BH.Engine.Structure.Modify.ApplyModifiers(ISurfaceProperty prop, Double fxx, Double fxy, and 8 more inputs) BH.Engine.Structure.Modify.Flip(Bar bar) BH.Engine.Structure.Modify.Flip(Edge edge) BH.Engine.Structure.Modify.OrientTowards(FEMesh mesh, Point orientationPoint) BH.Engine.Structure.Modify.SetElements0D(Bar bar, List newElements0D) BH.Engine.Structure.Modify.SetGeometry(Bar bar, ICurve curve) BH.Engine.Structure.Modify.SetGeometry(Edge edge, ICurve curve) BH.Engine.Structure.Modify.SetGeometry(Node node, Point point) BH.Engine.Structure.Modify.SetGeometry(Surface strSurface, ISurface geoSurface) BH.Engine.Structure.Modify.SetInternalElements2D(Panel panel, List openings) BH.Engine.Structure.Modify.SetLocalOrientation(FEMeshFace face, FEMesh mesh, Vector localX) BH.Engine.Structure.Modify.SetLocalOrientation(Panel panel, Vector localX) BH.Engine.Structure.Modify.SetLocalOrientations(FEMesh mesh, Vector localX) BH.Engine.Structure.Modify.SetMaterial(Bar bar, IMaterialFragment material) BH.Engine.Structure.Modify.SetNormal(Bar bar, Vector normal) BH.Engine.Structure.Modify.SetOutlineElements1D(Opening opening, List edges) BH.Engine.Structure.Modify.SetOutlineElements1D(Panel panel, List edges) BH.Engine.Structure.Modify.SetReinforcement(ConcreteSection section, and 1 more inputs) BH.Engine.Structure.Modify.SetStructuralFragment(Material material, IMaterialFragment structuralFragment) ```

adecler commented 3 years ago

Here's the list of non-Modify methods calling one of the clone methods:

Full list

``` BH.Engine.Adapters.Revit.Query.Duplicate(IBHoMObject bHoMObject) BH.Engine.Adapters.SAP2000.Query.JoinRigidLink(List linkList) BH.Engine.Adapters.SAP2000.Query.SplitRigidLink(RigidLink link) BH.Engine.Architecture.Query.NewElement1D(Room room, ICurve curve) BH.Engine.Audience.Query.PlaceSeats(Row row, Double unitWidth, Cartesian world, and 1 more inputs) BH.Engine.CableNetDesign.Compute.Equilibrate(GravityCableNet cableNet, EquilibrateMethod method) BH.Engine.CableNetDesign.Compute.FixPlanRelaxationByMinHeight(GravityCableNet cableNet, EquilibrateMethod settings) BH.Engine.CableNetDesign.Compute.RelaxCables(GravityCableNet cableNet, EquilibrateMethod settings) BH.Engine.Diffing.Compute.DiffGenericObjects(IEnumerable pastObjects, IEnumerable currentObjects, DiffConfig diffConfig, and 1 more inputs) BH.Engine.Diffing.Compute.Diffing(IEnumerable pastObjs, IEnumerable followingObjs, DiffConfig diffConfig, and 1 more inputs) BH.Engine.Diffing.Compute.DiffingHash(Object obj, DiffConfig diffConfig) BH.Engine.Diffing.Compute.DiffOneByOne(IEnumerable pastObjects, IEnumerable currentObjects, DiffConfig diffConfig, and 1 more inputs) BH.Engine.Diffing.Compute.DiffWithCustomId(IEnumerable pastObjects, IEnumerable currentObjects, String customdataIdKey, and 1 more inputs) BH.Engine.Diffing.Compute.DiffWithFragmentId(IEnumerable pastObjects, IEnumerable currentObjects, Type fragmentType, and 2 more inputs) BH.Engine.Diffing.Query.DifferentProperties(Object obj1, Object obj2, DiffConfig diffConfig) BH.Engine.Environment.Query.NewElement1D(Opening opening, ICurve curve) BH.Engine.Environment.Query.NewElement1D(Panel panel, ICurve curve) BH.Engine.Environment.Query.NewElement1D(Space space, ICurve curve) BH.Engine.Geometry.Compute.BooleanDifference(Line line, Line refLine, Double tolerance) BH.Engine.Geometry.Compute.BooleanDifference(List lines, List refLines, Double tolerance) BH.Engine.Geometry.Compute.BooleanIntersection(Line line, Line refLine, Double tolerance) BH.Engine.Geometry.Compute.BooleanIntersection(List lines, Double tolerance) BH.Engine.Geometry.Compute.BooleanUnion(Line line, Line refLine, Double tolerance) BH.Engine.Geometry.Compute.ClusterCollinear(List lines, Double tolerance) BH.Engine.Geometry.Compute.RowEchelonForm(Double[,] imatrix, Boolean reduced, Double tolerance) BH.Engine.Geometry.Convert.ToNurbsCurve(NurbsCurve curve) BH.Engine.Geometry.Query.Area(PolyCurve curve) BH.Engine.Geometry.Query.Bounds(BoundingBox boundingBox) BH.Engine.Geometry.Query.ExternalEdges(Extrusion surface) BH.Engine.Geometry.Query.InternalEdges(Extrusion surface) BH.Engine.Geometry.Query.IsClockwise(Polyline polyline, Vector normal, Double tolerance) BH.Engine.Geometry.Query.IsCoplanar(Polyline curve1, Polyline curve2, Double tolerance) BH.Engine.Geometry.Query.LineIntersection(Line line1, Line line2, Boolean useInfiniteLines, and 2 more inputs) BH.Engine.Geometry.Query.LineIntersections(Arc arc, Line line, Boolean useInfiniteLine, and 1 more inputs) BH.Engine.Geometry.Query.LineIntersections(Circle circle, Line line, Boolean useInfiniteLine, and 1 more inputs) BH.Engine.Geometry.Query.LineIntersections(PolyCurve curve, Line line, Boolean useInfiniteLine, and 1 more inputs) BH.Engine.Geometry.Query.LineIntersections(Polyline curve, Line line, Boolean useInfiniteLine, and 1 more inputs) BH.Engine.Graphics.Query.AutoRange(GradientOptions gradientOptions, IEnumerable allValues) BH.Engine.Graphics.Query.CenterGradientAsymmetric(Gradient gradient, Double from, Double to) BH.Engine.Graphics.Query.CenteringOptions(GradientOptions gradientOptions) BH.Engine.Graphics.Query.DefaultGradient(GradientOptions gradientOptions, String defaultGradient) BH.Engine.ModelLaundry.Query.LineIntersections(IElement1D element1D, Line line, Boolean useInfiniteLine, and 1 more inputs) BH.Engine.ModelLaundry.Query.LineIntersections(IElement2D element2D, Line line, Boolean useInfiniteLine, and 1 more inputs) BH.Engine.Structure.Compute.ShearAreaPolyline(Polyline pLine, Double momentOfInertia, Double tol) BH.Engine.Structure.Query.ControlPoints(Bar bar) BH.Engine.Structure.Trusses.Compute.InternalPoints(List points, Polyline polyline, Int32 internalDivsions) BH.Engine.Structure.Trusses.Compute.IterateBracing(List bracingList, List intersectionPoints, BracingOrientation bracingOrientation, and 6 more inputs) BH.oM.Architecture.Theatron.ProfileOrigin.ProfileOrigin(Point origin, Vector direction) BH.oM.Architecture.Theatron.TheatronFullProfile.TheatronFullProfile(List parameters) BH.oM.Architecture.Theatron.TheatronFullProfile.TheatronFullProfile(List parameters, Point focalPoint, ProfileOrigin sectionOrigin) BH.oM.Architecture.Theatron.TheatronFullProfile.TheatronFullProfile(List parameters, TheatronPlan planGeometry) BH.oM.Architecture.Theatron.TierProfile.TransformProfile(TierProfile originalSection, Vector scale, Point source, and 2 more inputs) BH.oM.Dimensional.IElement1D.NewElement1D(IOpening surface, ICurve curve) BH.oM.Dimensional.IElement1D.NewElement1D(ISurface surface, ICurve curve) BH.oM.Dimensional.IElement1D.NewElement1D(Opening opening, ICurve curve) BH.oM.Dimensional.IElement1D.NewElement1D(Panel panel, ICurve curve) BH.oM.Dimensional.IElement2D.MultiStoreyWalls(List levels, List centrelines, List openingsAllLevels, and 2 more inputs) BH.oM.Geometry.Plane.Plane(Point p1, Point p2, Point p3) BH.oM.Humans.ViewQuality.Audience.Audience(Audience audienceToCopy) BH.oM.Structure.Buildings.MultiStorey.MultiStorey(List levelElevations, List floorOutlines, List wallCurves, and 5 more inputs) ```

adecler commented 3 years ago

I have summarised the two lists above per namespace so we can tick them as they get fixed:

  • [x] BH.Engine.Adapters.ETABS.Modify @IsakNaslundBh
  • [x] BH.Engine.Adapters.GSA.Modify @IsakNaslundBh
  • [ ] BH.Adapter.File @alelom
  • [x] BH.Engine.Adapters.IES.Modify @FraserGreenroyd
  • [x] BH.Engine.Adapters.Plaxis.Modify @IsakNaslundBh
  • [x] BH.Engine.Adapters.Revit.Modify @pawelbaran
  • [x] BH.Engine.Adapters.Revit.Query @pawelbaran
  • [x] BH.Engine.Adapters.SAP2000.Query @IsakNaslundBh
  • [x] BH.Engine.Adapters.TAS.Modify @FraserGreenroyd
  • [ ] BH.Engine.Analytical.Modify @al-fisher
  • [x] BH.Engine.Architecture.Modify @rolyhudson
  • [x] BH.Engine.Architecture.Query @rolyhudson
  • [x] BH.Engine.Architecture.Theatron.Create @rolyhudson
  • [x] BH.Engine.Audience.Modify @rolyhudson
  • [x] BH.Engine.Audience.Query @rolyhudson
  • [x] BH.Engine.Base.Modify @alelom
  • [ ] BH.Engine.CableNetDesign.Compute @IsakNaslundBh
  • [ ] BH.Engine.CableNetDesign.Modify @IsakNaslundBh
  • [x] BH.Engine.Diffing.Compute @alelom
  • [x] BH.Engine.Diffing.Modify @alelom
  • [x] BH.Engine.Diffing.Query @alelom
  • [x] BH.Engine.Environment.Modify @FraserGreenroyd
  • [x] BH.Engine.Environment.Query @FraserGreenroyd
  • [x] BH.Engine.FormFinding.Modify @IsakNaslundBh
  • [x] BH.Engine.Geometry.Compute @LMarkowski / @adecler
  • [x] BH.Engine.Geometry.Convert @LMarkowski / @adecler
  • [x] BH.Engine.Geometry.Create @LMarkowski / @adecler
  • [x] BH.Engine.Geometry.Modify @LMarkowski / @adecler
  • [x] BH.Engine.Geometry.Query @LMarkowski / @adecler
  • [ ] BH.Engine.Graphics.Query @alelom
  • [x] BH.Engine.Humans.ViewQuality.Create @rolyhudson
  • [x] BH.Engine.MEP.Modify @FraserGreenroyd
  • [x] BH.Engine.ModelLaundry.Modify @LMarkowski / @pawelbaran
  • [x] BH.Engine.ModelLaundry.Query @LMarkowski / @pawelbaran
  • [ ] BH.Engine.Physical.Create @al-fisher
  • [ ] BH.Engine.Physical.Modify @al-fisher
  • [x] BH.Engine.Reflection.Modify @adecler
  • [x] BH.Engine.Representation.Modify @alelom
  • [x] BH.Engine.Spatial.Query @LMarkowski
  • [ ] BH.Engine.Structure.Bridges.Modify @peterjamesnugent
  • [ ] BH.Engine.Structure.Compute @IsakNaslundBh
  • [ ] BH.Engine.Structure.Create @IsakNaslundBh
  • [ ] BH.Engine.Structure.Elements.Modify @IsakNaslundBh
  • [ ] BH.Engine.Structure.Generative.Create @IsakNaslundBh
  • [ ] BH.Engine.Structure.Modify @IsakNaslundBh
  • [ ] BH.Engine.Structure.Query @IsakNaslundBh
  • [ ] BH.Engine.Structure.Trusses.Compute @IsakNaslundBh
adecler commented 3 years ago

Just to confirm: the DeepClone and ShallowClone methods are returning an object with the same Guid already:

image

Agreed we should get rid of the other clone methods (including the geometry ones)

adecler commented 3 years ago

GetShallowClone from the oM and GeometryClone methods will be removed completely. So the onyl two remaining Clone methods are Engine.Base.Query.DeepClone() and Engine.Base.Query.ShallowClone()

Instructions:

  • Replace calls to Geometry.Clone and Geometry.IClone to calls to Engine.Base.DeepClone(). Feel free to use Engine.Base.ShallowClone() where you feel appropriate.
  • Replace calls to GetShallowClone with calls to Engine.Base.ShallowClone()
  • Remove the as X conversion after the cloning since casting is not necessary anymore

See the PR on the Geometry engine for an example: https://github.com/BHoM/BHoM_Engine/pull/2070

To be actioned as soon as convenient. Can be done separately but need to be done by the end of sprint 4.

Once all the calls to Clone methods have been cleaned, I will delete the four clone methods mentioned above.

@al-fisher , @adecler , @alelom , @IsakNaslundBh , @FraserGreenroyd , @pawelbaran , @LMarkowski , @peterjamesnugent , @rolyhudson , FYI

IsakNaslundBh commented 3 years ago

Remove any reference to any clone method in the Modify namespace. If there is a good reason to keep it, please mention it here

Would be a bit careful with this, especially for any modify methods that are related to the IElement workflows. A lot of the methods that target IElement currently relies on the objects being cloned at modify. For example splitting something assumes that you can just call SetGeometry() twice with different geometries and get two of objects back that have different geometries but all other properties maintained exactly the same.

Can definitely get behind getting rid of GetShallowClone() by the end of sprint 4, but getting rid of cloning in every single modify method I would be a bit more careful with for the reasons stated above. For each method we basically need to check the implications it has on methods calling it, which can be non-trivial as the methods calling it might be in another toolkit, and even more so, called via some interface via RunExtensionMethod.

al-fisher commented 3 years ago

Understood - we need to understand the scale of the work. Perhaps worth a session specifically on this again next week after individuals have looked a specific cases? Can we link to some specific methods and how they might need to be tackled? I know @adecler was going to look at some of the reflection and geometry cases over the next few days to look a concrete issues for other also to watch out for.

As you say - priority, as I see it, is to remove all use of BH.oM.Base.BHoMObject.GetShallowClone. If that means replacing with BH.Engine.Base.Query.ShallowClone that is fine. Removal of BHoMObject.GetShallowClone is of course important in the needed reliance of GUID and use of Hash.

adecler commented 3 years ago

I think it is important to stress the fact that Modify methods are now ment to always modify the input object. This will be reinforced by later making the return type of ALL Modify method void (see https://github.com/BHoM/admin/issues/11).

The idea behind this is simple:

  • Objects in C# are always mutable (this is how C# wants to work by default)
  • Objects in UI scripts are always immutable (this is how UIs like Grasshopper want to work by default)

The BHoM_UI is already taking care of handling the discrepancy between the two realms by handling the cloning when appropriate.

This means that

  • Modify methods should remove the step of first cloning the input object
  • Modify methods that were creating a new object should modify the input object instead
  • Modify methods that were returning a new type of object are not compliant and should move to either Query or Compute as they are already breaking the compliance rules.

This is why I really like @alelom 's idea of having the Modify methods returning null because it leaves you no choice but to be compliant on top of being far more intuitive when deciding how to use those methods πŸ˜„ . We will, however, enforce the output to be void on a second phase to avoid too much mess.

I hope that makes the intent a bit more clear and helps you when you take on the tasks above. I will try to share my experience of fixing the Modify methods for the Geometry engine as much as possible but happy to have other meeting for those that still find this change confusing.

IsakNaslundBh commented 3 years ago

I think it is important to stress the fact that Modify methods are now ment to always modify the input object. This will be reinforced by later making the return type of ALL Modify method void (see #11).

Yeah, understand this ofc. All I am saying is that we can not simply look at the methods in isolation. You need to find all calls in the code, in all toolkits that can reach that method and evaluate if the implicit cloning mechanism that we have up until this point enforce was used by any of the methods.

I do not know how widespread this is, but as stated in the previous comment, I know it happens in quite a few cases for the IElements

adecler commented 3 years ago

Yeah, understand this ofc. All I am saying is that we can not simply look at the methods in isolation. You need to find all calls in the code, in all toolkits that can reach that method and evaluate if the implicit cloning mechanism that we have up until this point enforce was used by any of the methods.

Exactly, that what I meant by

Check all methods calling a method with a deleted call to Clone to make sure they don't rely on the object being cloned.

Fun, isn't it ? πŸ˜‰

What I recommend is to first fix all Modify methods in isolation and then check all calling methods. Not only will you naturally solve the problem for Modify methods calling other Modify methods but it will also help you stay focus on the first part of the task without running around in the code too much.

adecler commented 3 years ago

FYI, I have started a discussion around the Modify methods with an output type different than their first input type here: https://github.com/BHoM/BHoM/discussions/1031

adecler commented 3 years ago

All,

I have updated the instructions for correcting the calls to Clone methods (https://github.com/BHoM/admin/issues/9#issuecomment-709032648) base on our recent discussions. The purpose is now really focused on two things:

  • Guarantee the BHoMGuid is kept identical after cloning (GetShallowClone was allowing for it to be replaced)
  • Get rid of the four Cloning methods that we agreed were redundant.

This means that making the required changes has now become extremely simple and fast to execute πŸ˜„ πŸŽ‰

FraserGreenroyd commented 3 years ago

I believe my parts of this are done so I'm unassigning myself - please shout if I missed anything!

adecler commented 3 years ago

@alelom , @al-fisher , @IsakNaslundBh , gentle reminder that this is still pending.

al-fisher commented 3 years ago

Thanks @adecler - PRs raised for Analytical and Physical

al-fisher commented 3 years ago

@alelom - I have just raised a new issue https://github.com/BHoM/BHoM/issues/1259 - which we should now aim to close out.

A quick Ctrl-F of "GetShallowClone" in particular critical for above, but also "IClone" - shows a few GetShallowClones are still there/crept back in over the last 6 months!

As per the new issue on the BHoMObject just raised - worth us crowding round and quickly putting this to bed - with priority cleaning up the Base.BHoMObject 🌟 @adecler @IsakNaslundBh FYI

adecler commented 3 years ago

@alelom , you can find all the methods calling GetShallowClone using something like this:

image

FraserGreenroyd commented 3 years ago

@alelom to capture PR comments - MEP Engine and Facade Engine PRs do not match the files they claim to change, MEP Engine PR was dealing with Physical Engine files, and Facade Engine PR was dealing with Structure Engine.

Those two engines might need reinvestigating?

FraserGreenroyd commented 3 years ago

Ok all sorted now by the looks of it, thanks @alelom

FraserGreenroyd commented 3 years ago

@alelom I've merged all your PRs for you. The one on XML needs to be done in coordination with the one on BHoM, same branch, etc. - lemme know when you want to do that.

alelom commented 3 years ago

Wonderful! Thanks @FraserGreenroyd

alelom commented 3 years ago

The method GetShallowClone has now been removed from the base BHoMObject: https://github.com/BHoM/BHoM/pull/1265.

alelom commented 3 years ago

Final action on the unified strategy for the Cloning is to get rid of the last remaining Clone method: BH.Engine.Geometry.Query.Clone and BH.Engine.Geometry.Query.IClone.

All calls those two methods will be replaced with calls to Engine.Base.DeepClone(). This is actioned here: https://github.com/BHoM/BHoM_Engine/pull/2585

FraserGreenroyd commented 3 years ago

Ok we've merged that today as well now @alelom - does that conclude this issue?

alelom commented 3 years ago

With https://github.com/BHoM/BHoM/pull/1265 and https://github.com/BHoM/BHoM_Engine/pull/2585 merged we now are left with a unified strategy for cloning. In other words, now BHoM only defines two cloning methods: BH.Engine.Base.DeepClone() and BH.Engine.Base.ShallowClone() – both relying on the open source library DeepCloner.

This removes any ambiguity on how to clone objects in BHoM. Monitoring for performance should continue as well as logging for features we may need from the DeepCloner library.

al-fisher commented 3 years ago

Fantastic! This is great @alelom @FraserGreenroyd πŸ‘