Skip to content
This repository has been archived by the owner on Feb 14, 2024. It is now read-only.

Type aliases as used here don't provide value, type safety #69

Open
tv42 opened this issue May 24, 2021 · 2 comments
Open

Type aliases as used here don't provide value, type safety #69

tv42 opened this issue May 24, 2021 · 2 comments
Labels
code review Code Review

Comments

@tv42
Copy link

tv42 commented May 24, 2021

https://github.com/bpxe/bpxe/blob/0828554a14ebbdc2c38b7564443c0036b0f05ab0/pkg/bpmn/schema.go#L19-L29

type QName = string
type Id = string

This lets callers intermingle the types freely, removing any benefit of using the types. Should use

type QName string
type Id string

and so on.

https://play.golang.org/p/k8vgBkqdmwr

package main

import (
	"fmt"
)

type Foo = string
type Bar = string

func demo(b Bar) {
	fmt.Printf("i'm happy to have receiver a bar: %v\n", b)
}

func main() {
	var f Foo = "i'm a foo"
	demo(f)
}

Also, ID not Id: https://github.com/golang/go/wiki/CodeReviewComments#initialisms

@yrashk
Copy link
Contributor

yrashk commented May 24, 2021

The type safety point is great indeed, I didn't think much when I did this first piece, just needed to get something out quickly at first :) Thanks for bringing me there. Working on an update...

@yrashk yrashk added the code review Code Review label May 24, 2021
@yrashk
Copy link
Contributor

yrashk commented May 24, 2021

This is starting to uncover some interesting questions.

BPMN schema defines tSequenceFlow type that has sourceRef and targetRef that are typed as xsd:IDREF (non-qualified name):

https://github.com/bpxe/bpxe/blob/master/schemas/Semantic.xsd#L1436-L1437

However, it uses QName (qualified name) in FlowNode's incoming and outgoing that are linking back to sequence flows:

https://github.com/bpxe/bpxe/blob/master/schemas/Semantic.xsd#L718-L721

I am wondering if this makes sense. If a FlowNode refers to a SequenceFlow in a different namespace, is the IDREF reference declared there in that namespace or the original one? Something to think about the intention of this type discrepancy here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
code review Code Review
Projects
None yet
Development

No branches or pull requests

2 participants