Data-Driven Programming Data driven progamming is a programming model where the data itself controls the flow of the program and not the program logic. It is a model where you control the flow by offering different data sets to the program where the program logic is some generic form of flow or of state-changes. set1: DOWN - STOP - START - STOP - UP - STOP set2: UP - DOWN - UP - DOWN For example if you have program that has four states: UP - DOWN - STOP - START You can control this program by offering input (data) that represents the states: The program code stays the same but data set (which is not of a dynamic input type but statically given to the computer) controls the flow. Although there are more than a few ideas as to what data driven programming is, allow me to give an example using a data structure and a function. Non data driven example: data_lloyd = {'name': 'Lloyd', 'lives': 'Alcoy } data_jason = {'name': 'Jason', 'lives':...
LOOK UP TABLE
Định nghĩ đơn giản
Trong lập trình, bảng tra cứu (look up table), còn được gọi là LUT, là một mảng chứa các giá trị cần được tính toán theo cách khác. Bảng có thể được điền theo cách thủ công khi chương trình được viết hoặc có thể điền vào bảng các giá trị khi nó tính toán chúng. Khi có các giá trị cần thiết chương trình có thể tra cứu chúng sau này và giúp tiết kiệm tài nguyên CPU, tăng tốc độ xử lý.
Look Up Table
const char *currency[] = {
"VND","USD","YEN","BRD"
}
const int TABLE_SIZE = (sizeof(currency)/sizeof(char *))
void print_table(size_t curr){
for (int i=1; i<TABLE_SIZE; i++){
printf("%s - %d\n", currency[i], i);
}
}