Skip to main content
replaced http://programmers.stackexchange.com/ with https://softwareengineering.stackexchange.com/
Source Link

Ok, I know the title of this question is almost identical to When should I use event based programming?When should I use event based programming? but the answers of said question have not helped me in deciding whether I should use events in the particular case I'm facing.

I'm developing a small application. It's a simple app, and for the most part its functionality is basic CRUD.

Upon certain events (when modifying certain data) the application must write a local copy of said data in a file. I'm not sure about what's the best way to implement this. I can:

  • Fire events when the data is modified and bind a response (generate the file) to such events. Alternatively, implement the observer pattern. That seems like unnecessary complexity.
  • Call the file-generating code directly from the code that modifies the data. Much simpler, but it seems wrong that the dependency should be this way, that is, it seems wrong that the core functionality of the app (code that modifies data) should be coupled to that extra perk (code that generates a backup file). I know, however, that this app will not evolve to a point at which that coupling poses a problem.

What's the best approach in this case?

Ok, I know the title of this question is almost identical to When should I use event based programming? but the answers of said question have not helped me in deciding whether I should use events in the particular case I'm facing.

I'm developing a small application. It's a simple app, and for the most part its functionality is basic CRUD.

Upon certain events (when modifying certain data) the application must write a local copy of said data in a file. I'm not sure about what's the best way to implement this. I can:

  • Fire events when the data is modified and bind a response (generate the file) to such events. Alternatively, implement the observer pattern. That seems like unnecessary complexity.
  • Call the file-generating code directly from the code that modifies the data. Much simpler, but it seems wrong that the dependency should be this way, that is, it seems wrong that the core functionality of the app (code that modifies data) should be coupled to that extra perk (code that generates a backup file). I know, however, that this app will not evolve to a point at which that coupling poses a problem.

What's the best approach in this case?

Ok, I know the title of this question is almost identical to When should I use event based programming? but the answers of said question have not helped me in deciding whether I should use events in the particular case I'm facing.

I'm developing a small application. It's a simple app, and for the most part its functionality is basic CRUD.

Upon certain events (when modifying certain data) the application must write a local copy of said data in a file. I'm not sure about what's the best way to implement this. I can:

  • Fire events when the data is modified and bind a response (generate the file) to such events. Alternatively, implement the observer pattern. That seems like unnecessary complexity.
  • Call the file-generating code directly from the code that modifies the data. Much simpler, but it seems wrong that the dependency should be this way, that is, it seems wrong that the core functionality of the app (code that modifies data) should be coupled to that extra perk (code that generates a backup file). I know, however, that this app will not evolve to a point at which that coupling poses a problem.

What's the best approach in this case?

Tweeted twitter.com/StackProgrammer/status/708797918283751424
Source Link
abl
  • 471
  • 3
  • 12

Event-driven programming: when is it worth it?

Ok, I know the title of this question is almost identical to When should I use event based programming? but the answers of said question have not helped me in deciding whether I should use events in the particular case I'm facing.

I'm developing a small application. It's a simple app, and for the most part its functionality is basic CRUD.

Upon certain events (when modifying certain data) the application must write a local copy of said data in a file. I'm not sure about what's the best way to implement this. I can:

  • Fire events when the data is modified and bind a response (generate the file) to such events. Alternatively, implement the observer pattern. That seems like unnecessary complexity.
  • Call the file-generating code directly from the code that modifies the data. Much simpler, but it seems wrong that the dependency should be this way, that is, it seems wrong that the core functionality of the app (code that modifies data) should be coupled to that extra perk (code that generates a backup file). I know, however, that this app will not evolve to a point at which that coupling poses a problem.

What's the best approach in this case?