# Struct as subtype of multiple types

**URL:** <https://discourse.julialang.org/t/struct-as-subtype-of-multiple-types/52357>\
**Category:** Internals & Design\
**Tags:** type, dispatch, struct\
**Created:** [December 25, 2020, 2:27am UTC](https://discourse.julialang.org/t/struct-as-subtype-of-multiple-types/52357 "2020-12-25T02:27:04Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)\
**Post date:** [December 25, 2020, 4:13am UTC](https://discourse.julialang.org/t/struct-as-subtype-of-multiple-types/52357/2 "2020-12-25T04:13:34Z")

</div>

First of all, welcome to our community, 🎊

Second, are you aware that you can have [parametrized abstract types](https://discourse.julialang.org/t/parametric-abstract-types/25651/2)? So you do not need to manually create a different type for each number of dimensions?

Second, it seems like a case for the [Holy Traits](https://ahsmart.com/pub/holy-traits-design-patterns-and-best-practice-book/) pattern.

Third, why you need these abstract types? You will dispatch on them? Note that you have the following problem: if you have a function `f` that has a fallback method for the `abstract GeometricEntity2D` and another for the `AbstractPoint` but no method for the concrete `Point2{T}` then which of these two fallback functions should be called? I would suggest considering the following alternative: you can simply create a lot of fallback functions inside modules to simulate “interfaces”, i.e., `module GeometricEntity2D` has all basic functions that a `GeometricEntity2D` should implement, i.e., any types that are particular cases of that concept should extend these functions for their concrete type. And then your functions that use `GeometricEntity2D` types to do more advanced stuff will take generic parameters (not even restricting to`GeometricEntity2D`) and just call the function the concrete type should have implemented (and if it failed to do so, then an error will be thrown).

---

_[View the full topic](https://discourse.julialang.org/t/struct-as-subtype-of-multiple-types/52357)._
