#Visitor pattern using Ballerina
1 messages · Page 1 of 1 (latest)
It is possible. Check this example: https://gist.github.com/hasithaa/47861aa8f2c8acf4f0e94ef31adf9bb8.
One downside to this approach is that everything must be modeled as objects. This might work or be suitable for your needs. However, without evaluating your requirements and model, I cannot definitively say that this is the best pattern to solve your problem.
thank you @grave wigeon
@grave wigeon actually I want to visit a set of records. Not objects.
in such cases, are there any best practices to implement visitors?
We can change it to something like this if you have multiple visitors. https://gist.github.com/hasithaa/5a50ad63dfc2624647a8ceaaaa5dfdcd/e904c5809de71342dee0c54a5be6b1036b064331
If it is just one, we can do simply. https://gist.github.com/hasithaa/5a50ad63dfc2624647a8ceaaaa5dfdcd