Replies: 7 comments 6 replies
-
Trying to categorise those methods: Already return voidso ahead of anyone else 😄
Returning a List while input is an objectthose don't feel like
Returning a List while input is an IEnumerableThat one is pretty straightforward to fix.
The Geometry methodsI have kept then in the summarized form to keep things easier to read. Some are debatable and clearly the best illustration of our current problem:
Some just need fixing because they don't need a different input:
One feels very much like a
The odd ones
That's a
We could solve this one by using a
Not sure why the return type is different on this one to be honest
This is a
Hum, @alelom ? |
Beta Was this translation helpful? Give feedback.
-
So, to summarise, we are left with only five methods that are a bit tricky:
Unless I missed something ? @IsakNaslundBh ? |
Beta Was this translation helpful? Give feedback.
-
I think it is very important to make it clear why we are even doing this in the first place. So let me try to put a bit more clarity: In the very early days of the BHoM, we decided that a The problem is that a lot of So this That obviously leaves us with the few methods that were using the |
Beta Was this translation helpful? Give feedback.
-
Great - really useful. and agreed with above. In terms of clarifying approach for the tricky cases - reading and musing on historic definitions https://github.com/BHoM/documentation/wiki/BHoM_Engine-Classes got me thinking. The rules for "Modify" returning same return type have always been clear, however, I think the impact this has had on our code organisation has been to put too much emphasis on "Compute" methods. Compute I feel has always been a bit of a catch all - a place to put methods that do not have a good home elsewhere. Indeed even our explanation in the Wiki for "Compute" has two very different and discrete cases. https://github.com/BHoM/documentation/wiki/BHoM_Engine-Classes#compute So below is a first/new attempt at more precise classification. Part of the problem with Modify I feel is - often we _want to not put the code in the compute soup, as feels linguistically more logical for the method to sit in Modify. In this way the new Transform could help? BHoM_Engine Classes
1 Not applicable as method is not an extension method, so no primary input type to reference |
Beta Was this translation helpful? Give feedback.
-
Thanks guys, great comments ! Personally, I feel that the key to solve this is Looking at it with fresh eyes, it still feels like there is no great categorisation solution to this. So allow me to throw a curve ball just to force us to see things from a different perspective. I think that the reason why all our tricky cases are in public class NurbsCurve : ICurve
{
/***************************************************/
/**** Properties ****/
/***************************************************/
public virtual List<Point> ControlPoints { get; set; } = new List<Point>();
public virtual List<double> Weights { get; set; } = new List<double>();
public virtual List<double> Knots { get; set; } = new List<double>();
public virtual CurveType Type { get; set; } = CurveType.NurbsCurve;
}
public enum CurveType
{
NurbsCurve,
Polyline,
Line,
Arc,
Ellipse,
Circle
} Then use the I am not saying we should do this (or should we ? 😉 ) but I think that, to solve this problem, we need to have a good understanding of its causes. And this might be one pointer. |
Beta Was this translation helpful? Give feedback.
-
Alternative idea: Allowing Modify methods to have two options for the return type would help inform the code user what to expect:
|
Beta Was this translation helpful? Give feedback.
-
Thanks all - great conversations. As discussed on call with @adecler @alelom @IsakNaslundBh et al. have updated summary table with new columns. To summarise:
1 Not applicable as method is not an extension method, so no primary input type to reference |
Beta Was this translation helpful? Give feedback.
-
As discussed recently within the framework of BHoM/admin#9 and BHoM/admin#11, some
Modify
methods are still a cause for headache due to the fact that they have to return a different type than its first input. This is generally caused by the need for those methods to combine aConvert
with aModify
. For exampleProject
on aCircle
can return anEllipse
.With the need to better handle the paradigm of a mutable C# code vs an Immutable UI script, this problem becomes even more urgent to address once and for all. For the last few days, we believed we had reached a nice solution by keeping the cloning isolated in the UI and forcing ALL
Modify
methods to directly modify the input object itself. By having allModify
methods returning void, we would then make it very clear what their purpose is.Sadly, some of the current
Modify
methods are proving difficult to fit into that model. Which leads to another round of brainstorming. Personally, I strongly believe that a solution needs to come at the level of the framework (the same way we handle cloning in the UI component instead of in each method). I don't have a ready-made solution though. Hence the need for this discussion.In order to help better understand the exceptions we currently have, here's the list of
Modify
methods that have an output type different than their first input type:Full list
To make this a bit more digestable, here's the same set of just namespace and method name:
@al-fisher , @alelom , @IsakNaslundBh , @FraserGreenroyd , @pawelbaran, @rolyhudson , FYI
Beta Was this translation helpful? Give feedback.
All reactions