java - The cleanest way to avoid multiple if-statements - object creation dependent on many params -
i'm looking cleanest way determine value without using multiple if-statements (or switch-case).
for example, have following mapping table: 
as see, need consider 5 variables before able determine exact value.
using if-statements leads embedded ifs nightmare.
i have 2 solutions in mind:
very dirty - map of maps of maps of maps, etc. :
map<string, map<string, map<string,...>>> mymappings; involving lot of code: factory sub-factories leading final value - practically better readability, still if-statements encapsulated in classes.
what ideas?
personally, i'd rather keep value in table , consider final value obtain simple sql query. can chose other options should keep mapping in external source (table, properties file...) modify if requirements change.
Comments
Post a Comment