Constants vs Database

Certified Lead Developer

Hi all,

I am developing an application that contains a questionnaire with around 20 questions. There are also around 10 sections to display help. 

Both questions and help can be updated by the users. 

I dont know if I should create 30 constants or store the data in the DB.

For performance reasons I think is better to use constants but for memory management and scalability I think the DB makes more sense.

Is there any recommendation about this?

  Discussion posts and replies are publicly visible

Parents Reply Children
  • So, here's the thing: at one extreme of the thought spectrum is: "If a requirement isn't written down it doesn't exist!"...and at the other there's the "I just KNOW you're going to ask for this 3 months down the line...and even if you don't I'm going to make this as flexible as possible because that's just the best design!". That's the role of the Consultant, to make decisions based upon educated guesses and informed by (sometimes hard!) experience.

    I try ONLY to use Constants where the value is "one-dimensional" - that is, it has a single value & there are no associated or related attributes - and is genuinely static - that is I KNOW it'll (almost) never change.

    Otherwise it goes into the DB. Yes, there's a performance overhead (because you don't get something for nothing - that's a fundamental law of the Universe, don't argue with me, take it up with Einstein!)...but I've found that mostly the overhead IS NOT MATERIAL! That is, hey it takes 10 times as long, but the difference is between 0.01s and 0.1s (your mileage may vary here!) So does that really matter?!? And isn't what you're buying for this worth it? Those are the considerations that should be brought to bear when deciding which way to go. And with Appian the speed of delivery (and ease of maintenance) can and should reduce the resistance to opting for the more "complex, flexible, maintainable" options.