Consider splitting into two language options for different use cases
- Dominant language
- TypeScript
- Stars
- 154
- Forks
- 57
- Avg merge
- 1m
- Merged PRs (30d)
- 1
Description
I could imagine two variants of the codegen: one optimized for programmer-friendliness, the other optimized for performance. Take this class for example:
``` csharp
public class DataRequirementSort : Element {
[JsonProperty("direction")]
public string Direction { get; set; }
[JsonProperty("_direction")]
public Element _Direction { get; set; }
[JsonProperty("path")]
public string Path { get; set; }
[JsonProperty("_path")]
public Element _Path { get; set; }
}
```
For developer-friendliness, it might look like this:
``` csharp
public class DataRequirementSort : Element
{
[JsonProperty("direction")]
public Element Direction { get; set; }
[JsonProperty("path")]
public Element Path { get; set; }
}
internal class Element
{
public Element Id { get; set; }
public Extension[] Extensions { get; set; }
public T Value { get; set; }
}
```
For server-side performance, it might look more like this, given that extensions on primitive types are probably exceedingly rare:
``` csharp
internal class DataRequirementSort : Element
{
private Dictionary _primitiveElements;
[JsonProperty("direction")]
public string Direction { get; set; }
[JsonProperty("_direction")]
public Element _Direction
{
get => GetPrimitiveElement(0);
set => SetPrimitiveElement(0, value);
}
[JsonProperty("path")]
public string Path { get; set; }
[JsonProperty("_path")]
public Element _Path
{
get => GetPrimitiveElement(0);
set => SetPrimitiveElement(0, value);
}
private Element GetPrimitiveElement(int id)
{
Element value = null;
_primitiveElements?.TryGetValue(id, out value);
return value;
}
private void SetPrimitiveElement(int id, Element value)
{
(_primitiveElements ?? (_primitiveElements = new Dictionary()))[id] = value;
}
}
```
_Originally posted by @johnstairs in https://github.com/microsoft/fhir-codegen/pull/2#issuecomment-652995071_
Contributor guide
Assessment
This issue has not been assessed yet.