algorithm - How to Reduce gap between business in paper and code -


i have business scenario below.

i adding rows of possible (key, value) pairs.(country, climate) 1 below.

in image 2 whole scenario valid , invalid (key, value) given.


possible keys - country, india, australia, america, england

possible values - climate, hot, dry, rainy, cold, humid


for example

if (all country, climate) chosen first pair (england, hot) should not chosen second pair

if (all country, hot) chosen first pair (india, hot) should not chosen second pair

if (america, climate) chosen first pair (america, hot) should not chosen second pair

where

if (india, hot) chosen first pair (india, humid) shall chosen second pair

if (america, climate) chosen first pair (england, climate) shall chosen second pair

if (america, climate) chosen first pair (india, humid) shall chosen second pair

image 1

image1


image 2

enter image description here

question

1.is there better way represent business scenario in paper other this.

2.what best implementation of transferring matrix in paper code business in paper , code have close relation.

in other way scenarios can answered using if else statements in code. doing way logic interpreted in paper doesn't hold close relation in code.

one way lookup table. table can presented in way makes easy non-programmer understand , modify contents of table. example, in c programming language, declare structure, , put defines in header file this

combo.h

#define all_country 1 #define one_country 0  #define all_climate 1 #define one_climate 0  #define yes 1 #define no  0  typedef struct {     int oldcountry;     int oldclimate;     int newcountry;     int newclimate;     int isvalid; } stcombination;  extern stcombination combinations[]; 

then table non-programmers see this

combo.c

#include "combo.h"  stcombination combinations[] = { //    1st country  1st climate    2nd country  2nd climate   valid?     { all_country, all_climate,   one_country, one_climate,    no  },     { all_country, all_climate,   one_country, all_climate,    no  },     { all_country, all_climate,   all_country, one_climate,    no  },     { all_country, all_climate,   all_country, all_climate,    no  },      { one_country, one_climate,   one_country, one_climate,   yes  },     { one_country, one_climate,   one_country, all_climate,   yes  },     { one_country, one_climate,   all_country, one_climate,   yes  },     { one_country, one_climate,   all_country, all_climate,    no  },      { all_country, one_climate,   one_country, one_climate,   yes  },     { all_country, one_climate,   one_country, all_climate,    no  },     { all_country, one_climate,   all_country, one_climate,   yes  },     { all_country, one_climate,   all_country, all_climate,    no  },      { one_country, all_climate,   one_country, one_climate,   yes  },     { one_country, all_climate,   one_country, all_climate,   yes  },     { one_country, all_climate,   all_country, one_climate,    no  },     { one_country, all_climate,   all_country, all_climate,    no  }, }; 

table lookup done linear search, or computing index based on 4 bits of information.


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -