开发者

How do you name your query string variables? Short or long? Why?

In our code we have query string variables with very short names such as cId, iId, isA and u. It is very hard to tell what this variables are from their names. I want to use more descriptive names such as customerId, itemId, isA开发者_高级运维nonymous and user.

I want to know the disadvantages of using long names in query strings if there are any.

Thanks


Another argument I've heard for short variable names in the query string is to somewhat obfuscate the variables to try to prevent your users from "getting creative" and trying to access stuff they shouldn't by editing the URL. I'm not sure I agree with this unless you're doing something crazy like setting IsAdminUser=false somewhere in the URL - but if you're doing that you may have deeper issues with your code. ;)


I would keep variable names short, as the limit tends to be about 2,047 characters, but other browsers can handle more. There's a good explanation here: http://www.asp101.com/tips/index.asp?id=102

Just because Nija sees 4,000 in one of his, is definitely not a good idea to assume that will work for you.


You have a limit of 255 characters for GET operations, so you really need to be sparing in your names there. For POST operations, there's no need to worry about verbosity.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜