Replace conditional statement with Polymorphism
mostyn at platformis.net
Sat Jul 2 17:32:42 UTC 2022
object oriented programming requires a complete mind shift from procedural (Omnis Classic) programming. More than that, it is a multidimensional or rather multi layered mind shift. This transition took me about 18 months to get some 20 years ago. I am sure you are somewhere along the curve yourself but I/we cannot tell how far.
My suggestion is that you focus on a class / subclass hierarchy to address, or at least partially address your challenge. The solution will most likely be a combination of the two methods.
Are your conditional statements implementing change in behaviour, change in business logic, change in presentation or change on … whatever?
To answer your question properly requires a good understanding of your code base which you have and we don’t, so Its difficult to answer your questions succinctly.
Other may chip in with a more academic response.
> On 1 Jul 2022, at 20:45, Martin Obongita via omnisdev-en <omnisdev-en at lists.omnis-dev.com> wrote:
> Hi Listers,
> I have an academic question about object-oriented programming.How is "polymorphism" implemented in Omnis Studio?
> I have many conditional statements in my code: if...else if, switch...case that keeps breaking whenever I make a change in a related method elsewhere.Is there a sample library in the HUB which best described how to work with code that can take many forms?
> Kind regards,Martin O.
> Manage your list subscriptions at https://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en