coding style - Deciding whether or not a run a function, which way is better? -


I have some data loaded from the server, but there is no guarantee that when the UI starts, Display is the tick function in every frame when the new data is received, the flag is set, so I know that it is time to load it in my data structure. Which of the following is a more sensible way of deciding to actually run the function?

  AddNewStuffToList () {// clear the list and reload it with new data} Foo_Tick () {if (Updated) AddNewStuffToList (); // tick function}  

versus:

  AddNewStuffToList () {if (updated) {// clear the list and return it with new data Load}} Foo_Tick () {AddNewStuffToList (); // ticker function}  

I have left the irrelevant details for example.

IMHO first separates this version:

  • Data updates To (Foo_Tick)

FROM

  • How to Load Data (AddNewStuffToList)

The second option is simply shaking all things together.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -