Investigation - Objects standard for Financial Objects Working Group
Requirements
This document describes different solutions that have been investigated on behalf of the FINOS Financial Objects Working Group to:
- Define object definitions, currently documented on this Wiki page, which includes
- Field names
- Field types
- Object inheritance and peer relationships
- Comments and documentation
- Build a micro site that can contain:
- General purpose documentation
- Comments and technical docs that are extracted from object definitions
- Generate language-specific bundles (or packages, or artifacts) for easy consumption for , ordered by priority:
- TypeScript definitions for NodeJS
- C# objects for .NET
- Java Beans for Java
- Classes for Python
- Setup a continuous build process that allows to:
- separate object definitions (aka source code) to language-specific bundles
- Implement a collaboration workflow on source code using a distributed code management tool like GitHub (and Pull Requests)
Latest feedback from the Financial Objects Working Group remarked that:
- Human readable documentation is very important
- Discoverability, look-up and search for objects will help avoiding duplicates
- Developers must be able to adopt it easily
- Tooling should allow representing the stage of an object (ie approved, in review, proposed, …)
- Agnostic from the technology/language used to adopt it
The most challenging requirement is #3, since:
- All the others are already implemented within the FDC3 program activity, using TypeScript, TypeDoc and GitHub Pages as solution, read more on ODP Wiki page
- There is no standard approach for “DSL for object definitions that binds into all (main) languages (mentioned above on #3)”
- TypeScript, which is, by far, the most adopted language within FINOS for this purpose, doesn’t provide transpiling features into many other languages; there are several libraries that tackle 1:1 transformations, but none of them seem to be widely adopted or be supported by a solid open source community.
Solutions
The solution space is basically split in 2, language-driven and data-driven solutions.
Language-driven
Adopt a programming language to define objects and rely on the language compilers/transpilers to produce language-specific bindings (ie an NPM or JAR package)
- Protocol Buffers (from Google) is a strong solution for defining objects (and implementation) that comply with RPC semantics using the strongly-typed binary data format (of protocol buffers); for this reason, generated objects and interfaces comply with a custom data format, they are not plain old objects. Another peculiarity is the lack of support for object inheritance or the removal of field optional/required from version 2 to 3. We've been playing around with some object definitions taken from the FDC3 ContextData codebase, while collecting questions that are still open for debate
- Which version to use? 3 or 2?
- Any best practice to work around inheritance absence?
- Style guide: does the default one suffice, or needs to be extended?
- Nested types: what are the use cases where nested types are better than simple composition?
- Kotlin is a JVM-based programming language, so it’s natively compatible with Java, which provides Interop capabilities for Javascript, C, Swift and others. For Typescript, there’s a Gradle plugin that allows Typescript generation from Kotlin, although it’s maintained by a humble community (3 contributors). Kotlin is also the most trending language in 2018, with a growth of 260% on GitHub public repositories.
- Haxe, similar to Kotlin, but with a wider support for language bindings; the downside is that there is some custom coding needed in order to bind to TypeScript, which is - by far - the most important binding to deliver
Data-driven
Define a format, using a general purpose markup language (like YAML), that allows to define object definitions (as described on #1) and build custom solution to generate site documentation and language-specific bindings.
The solution would be delivered in form of:
- A YAML (or similar) format to define object structure, relations between objects and (fine-grained) documentation (#1)
- A language-specific binding generation process - continuously invoked - that reads the format and generates language-specific bindings; this can be achieved in different ways:
- Using TypeScript as reference implementation; other language bindings will be added when requested. This approach probably doesn’t satisfy entirely requirement #3
- Translating YAML to JSON first, then use QuickType to generate language-specific bundles; the main objective of QuickType seems to fit well with FO requirements, but needs some further testing using real specifications and testing integration with FDC3 definitions
- Using language-specific libraries, for example jsonschema2pojo for Java Beans, MakeTypes for Typescript definitions and JsonCSharpClassGenerator for .NET classes
- A YAML to HTML (or MarkDown) generation to produce documentation content
Need help? Email help@finos.org
we'll get back to you.
Content on this page is licensed under the CC BY 4.0 license.
Code on this page is licensed under the Apache 2.0 license.