When encapsulating some general methods, it is better to add more methods or to distinguish them by configuration.

is it better to add more methods or pass parameters when encapsulating some general methods?
for example, I re-encapsulate the ajax of jq.
the first method is as follows. The request method is put in the parameters. For example, type can be post or GET

.
request({
    type:POST,
    url:xxxx,
    data:{}
})

the second method is as follows, and a separate method is added

request.get({
    url:xxxx,
    data:{}
})

  request.post({
    url:xxxx,
    data:{}
})

the above is a simple example, which is roughly what it means. Which of these two methods is better?

Mar.18,2021

the second method is more intuitive and readable, but it does not have good expansibility. Look at your own business requirements, such as ajax method, there are only a few, and there will be no more, so I think the second method is better


this is not necessarily, it depends on the specific situation of method use and definition.
is more about implementation conventions.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e390a6-444f7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e390a6-444f7.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?