Is it good way to define constants as a top level ...
# getting-started
a
Is it good way to define constants as a top level declaration with
internal
key word eg
Copy code
internal const NAME_FOO:String = " "
class Foo{
}
a
IMHO, if you’re not in a multi module project/library project, the
internal
marker is functionally a code noise
a
Its not used any where except its class declaration,and test
t
internal
marks visibility to the entire module, so every other file in the same module would have access to it, disregarding other forms of packaging. I think that is what Amirul means, if you have a single module,
internal
practically means
public
(and in kotlin everything is
public
by default)
👍 2
in your case, it should be privare imo, but that is my preference, I don't reuse constants in test if possible, as changing them will not break tests most probably (I got burned in the past with constant used for http path, changed the path inadvertently, nothing signaled me the error, broke qa environment)