views:

25

answers:

1

I'm building a web app with a lot of ajax calls to be made.

Should I be trying to keep a small number of methods, and just pass in information about what type of request it is, and then switch based on that type inside the method

or

Many smaller methods, so don't have to pass in type, but more code to write setting up each method.

Currently I'm passing type from the id of the element being interacted with in the html, and then this tells me what I'm trying to do

row-action-data-id (I then split this in the functions, to work out what needs doing)

Are there any best practices for patterns like this?

+1  A: 

its a judgement call. you always want to refactor out any duplicate code as much as possible but its important that your code is readable and maintainable.

ooo