4

I need advice fellow developers, am I stubborn?

So I lost an argument in my team regarding constant vs variable directly in a method for stored procedure names.

I separated names of procedures into their own StoredProcedureConstants file because it makes it very easy to see all procedures used in a project and refactor their names if necessary. Argument against was that you loose time creating a constant. Am I silly if I am alergic to seeing quotation marks stuff without its designated purpose throughout the code?
Their way is adding var procedureName = "cc.storeProcedureName" directly in a method. I just can't find my peace with it. To me this is a magic string.

Am I being unreasonable?

Comments
  • 1
    The needs of the many outweigh the needs of the few.
  • 3
    Code listing would explain your problem better.

    You are basically right. Having a constant is DRY - makes it easier to rename and, more importantly, find all usages. However, in my experience a file with a list of all possible constants is always a mess. A module in your db should easily map to a module in your other language.

    Ideally, what I would try to achieve is some kind of semi-language, where the objects representing your stored procedures, are somehow real objects/methods in the main language.

    Example techniques:

    Specification:
    new TheStoredprocedure(arg1, arg2)
    represents a term that evaluates to a call of the procedure.

    Meta programming:

    interface MyDatabase {
    @StoredProcedure(name=„my_procedure”)
    void myProcedure(arg1, arg2);
  • 0
    @matste Thanks for your recap. Idea of course was not to create a single godlike constants class for everything but constants for stored procedures independently in their own file. I'm just a little uneased with the fact that I actually have to remove it and replace everything with inline strings.
Add Comment