Skip to main content
deleted 39 characters in body
Source Link
BornToCode
  • 1.3k
  • 2
  • 13
  • 18

I had a debate with a friend and I'd likeI'm looking for a way to hear how can we resolve it and decide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input thatare added dynamically by the user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state, I add a new place in code that have to be maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

I had a debate with a friend and I'd like to hear how can we resolve it and decide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state, I add a new place in code that have to be maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

I had a debate with a friend and I'm looking for a way to resolve it and decide which approach is better for maintenance and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that are added dynamically by the user) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state, I add a new place in code that have to be maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

added 4 characters in body
Source Link
BornToCode
  • 1.3k
  • 2
  • 13
  • 18

I had a debate with a friend and I'd like to hear how can we resolve it and decide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state, I add a new place in code that have to be maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

I had a debate with a friend and I'd like to hear how can we resolve it and decide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state I add a new place in code that have to maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

I had a debate with a friend and I'd like to hear how can we resolve it and decide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state, I add a new place in code that have to be maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

added 10 characters in body
Source Link
BornToCode
  • 1.3k
  • 2
  • 13
  • 18

I had a debate with a friend and I'd like to hear proshow can we resolve it and cons to eachdecide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state I add a new place in code that have to maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

I had a debate with a friend and I'd like to hear pros and cons to each approach and whether there's some consensus about best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state I add a new place in code that have to maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

I had a debate with a friend and I'd like to hear how can we resolve it and decide which approach is better for maintenance in the long run and whether there's some consensus about a best practice regarding it:

If an application shows some data on the UI (for example order ids that some come from input that user is currently inserting) and there's a button which suppose to do some action with that data shown on the ui (e.g. send those ids to processing) - how should the data be fetched:

  • Is it better that the code handling the button click take the values directly from the UI by accessing the UI element?

    After all, UI changes the most often, so if I take the data from the UI it's more likely that the button click handling code will also have to be updated because how it consume the data from the UI might get broken.

  • Or should the data be taken from some variable that will save the state?

    But if I add a special variable just to save the state I add a new place in code that have to maintained on changes and that artificial state variable might not be 100% synchronized with the UI and cause bugs.

How to decide which approach to choose? Is adding a special variable just to save state considered a code smell?

removed resource request, organized question text for clarity
Source Link
amon
  • 135.9k
  • 27
  • 295
  • 386
Loading
Source Link
BornToCode
  • 1.3k
  • 2
  • 13
  • 18
Loading