# Best practice to support multiple implementations

**URL:** <https://discourse.julialang.org/t/best-practice-to-support-multiple-implementations/74240>\
**Category:** New to Julia\
**Tags:** multidispatch\
**Created:** [January 8, 2022, 1:58pm UTC](https://discourse.julialang.org/t/best-practice-to-support-multiple-implementations/74240 "2022-01-08T13:58:14Z")\
**Posts on this page:** 1\
**Showing post:** 11

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [January 9, 2022, 1:56pm UTC](https://discourse.julialang.org/t/best-practice-to-support-multiple-implementations/74240/11 "2022-01-09T13:56:23Z")

</div>

> [@roh\_codeur](#):
>
> ```julia
> Base.@kwdef struct UrlDownloader <: Downloader
> url::String = "some--url"
> token::String = "my-token"
> process::Function = () -> downloadFromUrl(url)
> end
> 
> ```

Don’t try to emulate OOP syntax this way. The `process` [field is abstractly typed](https://docs.julialang.org/en/v1/manual/performance-tips/#man-performance-abstract-container), which basically prevents the compiler from doing type inference or inlining anything when you call this function. It’s also not idiomatic Julia style.

(Function-call performance may not matter in this particular example, or in any example where the body of the function takes so much time that everything else is negligible, but it’s a bad habit.)

As I said, the analogue of OOP’s `downloader.process()` [UFC](https://en.wikipedia.org/wiki/Uniform_Function_Call_Syntax) syntax in Julia is `process(downloader)`. i.e. write:

```julia
function process(x::UrlDownloader)
    # do something
end

function process(x::CsvDownloader)
    # do something else
end

function run(downloader::Downloader)
    println("Running $(typeof(downloader))")
    process(downloader)
end

```

See also [Allowing the object.method(args...) syntax as an alias for method(object, args ...)](https://discourse.julialang.org/t/allowing-the-object-method-args-syntax-as-an-alias-for-method-object-args/62051)

---

_[View the full topic](https://discourse.julialang.org/t/best-practice-to-support-multiple-implementations/74240)._
