Hi everyone,
Can anyone explain the purpose of using constant ? I know that constant is literal values, and it can be resued in multiple objects. Is there any purpose of using constant ? Moreover, when we will create constant in application ?
Thanks!
Discussion posts and replies are publicly visible
Generally we use constants where otherwise we'd need to hardcode values that could change in the future. Imagine implementing a new system from scratch, and there's a business term / Buzzword used in interfaces, processes, and other types of logic all over the system - and at the start of the project build-out, you're only ~90% sure that the term you're using will be the final version. When care is taken to use the constant instead of manually referring to that buzzword everwhere, and it eventually changes (even just a subtle change - imagine a tweak of how the word is spelled or even just capitalized), then the only thing that needs to be done is to change the value of the constant, instead of potentially hours of manual rework sifting through the system and changing its spelling in all sorts of places.
Also for some things we'd like to refer to occasionally, it's either impossible or really difficult to hardcode a value even if we wanted to. That can be references to a specific folder or document, or a process model, or a data store entity (among other things). Constants make it quick and easy to pass such things into queries, components, subprocess calls, or whatever is needed.