views:

18

answers:

0

I wanna refactoring my code. Now, this function is very mass cause it modified and modified several years to support multiple resolutions & multiple concept of UI design. So, one function for display has over then 10K lines. It need to be refactoring.

At first, I've concern about seperate functions for each resolution and UI design type. On this case, there will be about 30-somthing functions for one object. If there will be on problem, I would update 30 functions. It's terrible.

Second idea is that make one function and use enum & #define carefully to support all resolutions. In this case, there will be 3 or 4 functions for each UI design. But it will be very hardworking. I have experience of this. (It's why old function became so large and mass.)

What do you think about that? What should I do? First or Second? Actually, I need the Third silver bullet.

I write with C. And the function structure is like this.

#if defined (128X160)
  X_Position = 1;
#elif defined (176X220)
  X_Position = 3;
#elif defined (240X320)
  X_Position = 5;
#endif

int Display(void)
{
#if defined (Touch)
 /* display routine */
#elif defined (Horizontal)
 /* display routine */
#elif defined (Qwerty)
 /* display routine */
#else
 /* display routine */
#endif
}