Skip to main content
added 69 characters in body
Source Link
Dynamic
  • 5.8k
  • 9
  • 48
  • 74

We have a new developer inon our team. He seems to be a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements inon the project (MVC3 web application using javascript - jqueryJavascript with jQuery and knockoutKnockout).

Let's say we have two values:

A - quite complex calculation    
C - constant    
B = A + C

On the screen there is value B and user can change it (normal texbox). When B changes, A changes as well because C is constant. So there is linear dependency between A and B.

Now, all the calculations are done in the backendback-end, but we need to recalculate A as user changes B (in jsJavascript, I would use knockout). I thought about storing old A and B and when B changes by 10 then we know that new A will be old A + 10. He says this is dirty, because it's duplication of code (we make use of the fact that they are dependent and according to him that should be only in one place in our app). I understand it's not ideal, but making AJAX request after every key press seems a bit too much.

It's a really small thing and I would not post if we haven't had long discussion about it. How

How do you deal with such problems? Also I can imagine that using knockout implies lots of calculations on the client side, which very often leads to duplication of the same calculations from the backendback-end. Does anyone have links to some articles/thoughts on this topic?

We have a new developer in our team. He seems a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements in the project (MVC3 web application using javascript - jquery and knockout).

Let's say we have two values:

A - quite complex calculation    
C - constant    
B = A + C

On the screen there is value B and user can change it (normal texbox). When B changes, A changes as well because C is constant. So there is linear dependency between A and B.

Now, all the calculations are done in the backend, but we need to recalculate A as user changes B (in js, I would use knockout). I thought about storing old A and B and when B changes by 10 then we know that new A will be old A + 10. He says this is dirty, because it's duplication of code (we make use of the fact that they are dependent and according to him that should be only in one place in our app). I understand it's not ideal, but making AJAX request after every key press seems a bit too much.

It's a really small thing and I would not post if we haven't had long discussion about it. How do you deal with such problems? Also I can imagine that using knockout implies lots of calculations on the client side, which very often leads to duplication of the same calculations from the backend. Does anyone have links to some articles/thoughts on this topic?

We have a new developer on our team. He seems to be a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements on the project (MVC3 web application using Javascript with jQuery and Knockout).

Let's say we have two values:

A - quite complex calculation    
C - constant    
B = A + C

On the screen there is value B and user can change it (normal texbox). When B changes, A changes as well because C is constant. So there is linear dependency between A and B.

Now, all the calculations are done in the back-end, but we need to recalculate A as user changes B (in Javascript, I would use knockout). I thought about storing old A and B and when B changes by 10 then we know that new A will be old A + 10. He says this is dirty, because it's duplication of code (we make use of the fact that they are dependent and according to him that should be only in one place in our app). I understand it's not ideal, but making AJAX request after every key press seems a bit too much.

It's a really small thing and I would not post if we haven't had long discussion about it.

How do you deal with such problems? Also I can imagine that using knockout implies lots of calculations on the client side, which very often leads to duplication of the same calculations from the back-end. Does anyone have links to some articles/thoughts on this topic?

edited tags
Link
Grant Palin
  • 1.7k
  • 2
  • 14
  • 29
Source Link
Michal B.
  • 341
  • 1
  • 3
  • 9

Duplication of code (backend and javascript - knockout)

We have a new developer in our team. He seems a smart guy (he just came in so I cannot really judge). He started with implementing some small enhancements in the project (MVC3 web application using javascript - jquery and knockout).

Let's say we have two values:

A - quite complex calculation    
C - constant    
B = A + C

On the screen there is value B and user can change it (normal texbox). When B changes, A changes as well because C is constant. So there is linear dependency between A and B.

Now, all the calculations are done in the backend, but we need to recalculate A as user changes B (in js, I would use knockout). I thought about storing old A and B and when B changes by 10 then we know that new A will be old A + 10. He says this is dirty, because it's duplication of code (we make use of the fact that they are dependent and according to him that should be only in one place in our app). I understand it's not ideal, but making AJAX request after every key press seems a bit too much.

It's a really small thing and I would not post if we haven't had long discussion about it. How do you deal with such problems? Also I can imagine that using knockout implies lots of calculations on the client side, which very often leads to duplication of the same calculations from the backend. Does anyone have links to some articles/thoughts on this topic?