3 ms·
When you put stuff in namespaces you need to remember in which namespace it is (and which library to refrence). Number.parseInt is not that bad but I'll take t
by scotty79 11y ago
When you put stuff in namespaces you need to remember in which namespace it is (and which library to refrence).
Number.parseInt is not that bad but I'll take to_json() global function instead of (new System.Web.Script.Serialization.JavaScriptSerializer()).Serialize() (or was it Newtonsoft.Json.JsonConvert.SerializeObject()?) any day.
Sure, names of PHP functions look arbitrary and inconsistent but when you know the name of the function you know everything you need (apart from how to use it which you can quickly and unambigously check like: http://php.net/file_get_contents http://php.net/file_get_contents )
- rjbwork 11y agoI just type JsonConvert and hit Alt-Enter. #JustReSharperThings
- scotty79 11y agohttps://www.jetbrains.com/resharper/buy/ https://www.jetbrains.com/resharper/buy/ But thanks. I was looking for thing that would import me proper namespace and reference proper dependancy. Doesn't help you that much though when Microsoft releases new version of its web stack, naming different things with same class names as before just putting them in different namespace. I still need to guess which of the namespaces I actually need when I'm trying to get running something that I found on the internet.
- taspeotis 11y agoThe basic functionality (given type X import namespace Y) is built into Visual Studio since who-knows-when [1]. In my opinion if you are doing a lot of commercial .NET development then ReSharper isn't an optional extra. Rather, it's money well spent. You get more complete functionality: ReSharper 8 added the smarts to look for NuGet packages in your solution and reference the correct NuGet package. (This is ALT+ENTER and it basically gets the right type and dependency first time around.) ReSharper 9 goes further and allows you to find types in any package on NuGet - JetBrains maintains their own index of NuGet packages for this purpose [2]. [1] http://stackoverflow.com/a/186920/242520 http://stackoverflow.com/a/186920/242520 [2] https://www.jetbrains.com/resharper/whatsnew/whatsnew_9.html#nuget https://www.jetbrains.com/resharper/whatsnew/whatsnew_9.html...
- aikah 11y ago> Number.parseInt is not that bad but I'll take to_json() global function instead of (new System.Web.Script.Serialization.JavaScriptSerializer()).Serialize() any day. It doesn't have to be one or the other. In fact, array functions could just be under the same static class, like Array::TheFunction() . It would be acceptable and limit chances of namespace collision .
- scotty79 11y ago> It doesn't have to be one or the other. Sure there's a spectrum. But even with one level I'm still guessing whether it was String.toInteger or Integer.toString, or String.parseInt or Integer.parseInt or Number.parseInt or whatever ... and since I need to check I don't mind finding out it's a global function named str2int or even int() that takes whatever.
- jsjohnst 11y agoIf you have to look it up anyway, what difference does it make if it's a global or namespaces? If you don't know, you don't know. As such, your point as stated doesn't counteract why polluting global namespaces is a bad thing. There are arguments that could be made (PHP VM specific), but "I didn't ever RTFM and/or retain it" doesn't fly to me personally.
- scotty79 11y ago> what difference does it make if it's a global or namespaces? I feel that it's often easier to remember short unique name like str2int than long, deceivingly reasonable name like: System.Web.Script.Serialization.JavaScriptSerializer.Serialize I agree though that array_uniq is same as Array::uniq > why polluting global namespaces is a bad thing. Why is that bad for language wide utility functions? I though global is bad mostly in your own custom code or you application specific libraries because it's accessible from everywhere which hides the dependencies (no to mention global mutable state which makes "action at distance" prevalent).
- 11y ago
- untog 11y agoNumber.parseInt is not that bad but I'll take to_json() global function instead of (new System.Web.Script.Serialization.JavaScriptSerializer()).Serialize() (or was it Newtonsoft.Json.JsonConvert.SerializeObject()?) any day. Or, to keep with the JS example: JSON.stringify() Not exactly that bad.
- estefan 11y ago> When you put stuff in namespaces you need to remember in which namespace it is (and which library to refrence). This is comedy gold! I almost didn't spot the sarcasm :-D