Why? I'll give you that MS doesn't have a good native JSON parser, but don't most OS's that support JSON also have XML parsers? Java and Javascript both seem to have one. MS has made XML super easy on their platform.
Printable View
Poppa smiles... I guess it's the same reason they called their product Visual BASIC, "Let's call it BASIC, everybody's heard of BASIC... Go with the name everyone knows... It kinda looks like BASIC who cares that Beginners are really gonna struggle. It'll make us rich" !
Poppa.
Poppa,
As someone who creates code he has to maintain himself I like to leverage the heck out of classes.
They can do much more than simply hold data.
They can contain methods and events that will make them even more useful and intuitive.
For instance you can also add your data by modifying the 'New' constructor of the class.
In Use:Code:Public Class clsName
Public Property First As String = ""
Public Property Last As String = ""
Public Sub New(Firstname as string, Lastname as string)
First = Firstname
Last = Lastname
End Sub
End Class
So now there is nothing to remember about filling your class variable. You are prompted for your two strings when you initialize your class as an object.Code:Dim myName As New clsName("Mickey","Mouse")
Dim names As New List(Of Name)
Names.add(myName)
' Or add the content directly to the list without creating a separate variable.
Names.Add(New clsName("Donald","Duck")
If you wanted to make the process even easier you could also create a class that inherits List(of clsName) and overload the Add() Method.
so that it becomes even simpler.
If you know your list will always read and write the list to disk then perhaps you also add Open and Save methods to the class.Code:
Dim Names as new clsListOfNames
Names.Add("Casey","Jones")
MessageBox.Show(Names(0).First & " (World's best engineer) " Names(0).Last)
So in use.
The point here is that the supporting classes go into a file in your project with a relevant title where you can easily find it later.Code:
Dim Names as new clsListOfNames
Names.Open("C:\UserNames.txt")
'...
MessageBox.Show(Names(4).First)
Names(4).First = "Bob"
'...
Names.Save("C:\UserNames.txt")
If you build your classes well you may never have to open their source again.
For the record, if I see what I think is a bad answer then I'll say so because I don't want either the person giving or the person receiving the information to settle on something that is significantly suboptimal. As for why I wouldn't answer the original question, there may be any number of reasons. The three that come to mind off the bat are that I don't have the time it would take, that I don't know the best answer but I know a bad one when I see it and that I don;t think the question warranted asking in the first place.
Rest assured, I've provided my share of bad answers over time and I've been admonished for them on occasion too. I either ignored the response, apologised if I could see my error or made my case if I thought I was right. Regardless, I didn't stake my self-worth on what that person may or may not have thought of me and look at me now, doing admonishing of my own. :)
I know I don't come across as friendly on occasion. That's generally because I don't try to be, not because I try not to be. I'm not here to make friends but to convey information that I think will help people become better developers. With that in mind, there are times where I think a kick in the pants is exactly what people need because it will be quicker to come to mind the next time and help prevent them making similar mistakes.
I actually received a PM from someone recently who said they resurrected an account that they hadn't used in years specifically to thank me for doing that with them. They were pissed off with me at the time but soon came to realise what I was getting at and strove to improve themselves as a developer and succeeded as a result. I didn't make them what they are but I had a hand in their making that of themselves and that's what I'm here for. If there are a few casualties along the way then, to be honest, I can live with that.
I've never complained about your apparent attitude, I respect your advice too much to do that. It's just that...
... ok, a question wasn't worth an answer, nobody else's bothered to answer it so I'll try to help out. I write what I'd do under the stated circumstance. It often seems to me that you in particular, looking through the threads, spot that Poppa's answered a question... "Let's see what crap he's written this time".
I know this is a little paranoid, but that's how it comes across to me. I'd say because it is mainly you that jumps on my answer. My point is that if the original question was too infra dig to answer why is the answer worth bothering with?
I suggest that this is a case in point: -
Yes, I'm referring to the post which launched a thousand posts...
Ok I exaggerate...
And just for the record, I haven't had time to look at the up-date I was working on since this thread started, I'm spending all my time with this.
Poppa.
I like to poke fun at JM because he can come across as grumpy sometimes but I've also had enough exchanges with him in Chit chat to know he really isn't. Mostly he's just curt (in the main forums at least), he says what needs to be said and nothing more. Also, he has the cuddliest avatar in the whole of VBF:D
I do know what you mean about feeling put upon when someone corrects you on the forum though. When we post on here we put our egos on the line. None of us knows everything and, whether we're asking a question, providing help or just getting involved in a discussion, we stand the risk of exposing our own ignorance. That's quite daunting. Seriously, I've led teams of professional developers and I'm constantly exasperated at how difficult it is to get them to post on a forum for exactly this reason. They'd rather spend hours throwing random configurations at some undocumented bug than just ask a question and get an answer.
The trick, I think, is just not to get too precious about it. Remember that none of us know everything. We're all ignorant of something and we'll all get corrected from time to time. But the absolute worst thing you could do, for yourself and for the rest of us, is to stop contributing. Even when you get it wrong you add value because you provide something to correct.
On the file format issue, I'd argue for CSV every time when my data is flat. It's easy to read and a highly efficient format for a computer to cope with. When my data's hierarchical the choice between xml and json really comes down to whether efficiency is more important to me than expliciteness (is that a word) and readability. Json is more efficient but xml is more explicit and readable IMO. I don't worry too much about the parsers because I known there's decent ones for either format. Also, the transformation and policing provided by xslt and xsd can be a huge boon for XML which Json lacks.
On SOAP vs REST, again, I think it depends. SOAP is definitely heavier but it also comes with a whole load of stuff built in. The most obvious thing is a robust security framework.
Poppa smiles... :)
Mine's made of wood!
I wondered what language 'IMO' was for a moment. :blush:
I'd've recognised 'IMHO' because that's the more common in the UK, I don't use text-speak, not only because I'm not lazy, nor am I trying to keep below a SMS 'Page Stage' but because I'm quite likely to get it wrong!
Poppa.
Poppa smiles... :)
Mine's made of wood!
I wondered what language 'IMO' was for a moment. :blush:
I'd've recognised 'IMHO' because that's the more common in the UK, I don't use text-speak, not only because I'm not lazy, nor am I trying to keep below a SMS 'Page Stage' but because I'm quite likely to get it wrong!
Poppa.
"IMO" is used by the Goth compiler... It's the language of the Dark Web.
-tg
*pulls tongue out of cheek*
I can't use IMHO. My O has never been H :bigyello:
You'll notice that I said to use a "collection" and Sitten Spynne said that noone uses a "Collection". We're both 100% right. I was using the general term while SS was referring to a specific type. The Microsoft.VisualBasic.Collection class is a holdover from VB6 and noone should ever use it unless they are upgrading VB6 code that already uses a VB6 Collection.
In .NET, a "collection" is literally any type that implements the ICollection interface. That means that arrays are collections, an ArrayList is a collection, a List(Of T) is a collection, as is a Queue, a Queue(Of T), a Hashtable, a Dictionary(Of TKey, TResult), etc, etc. A collection is simply a way you collect multiple objects of the same type together. As I said, the Items property of a ListBox is a collection so if you were using a "hidden" ListBox you were actually already using a collection via that property but you had a useless control weighing it down.
So as to help you avoid misinterpreting what I post like this again, please note that I ALWAYS use correct casing for type names and the like. If I post "collection" then I'm definitely not referring to a type because I would always begin a type name with the upper-case letter that it deserves.
This could turn into a thread. In outline form:
- XML is good enough I won't push for a program that already uses it to switch, but if I'm starting from scratch I prefer JSON.
- Some of this is because XML is very verbose: in general 25-50% of an XML file is end tags, equal signs, indentation, and other bits of syntax that make my customers with spotty 3G and expensive data plans very sad.
- XML gives the user a little too much freedom. For any given class hierarchy, there are a number of different ways to represent the class that grows exponentially with the number of properties. Think: Is this property an attribute? An element? Does it use CDATA? etc. For any object, there is exactly one JSON representation.
- The moment a customer's XML starts using a redefined default namespace, or namespaces at all, the complexity of your XML parser goes up by an order of magnitude. I don't know what the heck MS was thinking in any of their parsers' implementations of namespaces.
- Parsing XML is very heavyweight: either you have to write a state machine for a SAX parser, or you have to pay the memory costs of the DOM parser. If going from JSON->Objects is a 1x memory hit. Going from XML->DOM->Objects is at least 2x.
- XML parsers exist for every language, but support varies. I've used parsers in Python, Ruby, Perl, and LabVIEW, and what bugs me is for each language I have to learn a new set of parsers. JSON parsers, in general, consist of the same two methods on every platform and in every language.
Really it comes down to: I can think of good arguments to use JSON over XML, but not many to use XML over JSON. So I reach for JSON when I can.
There's a discussion about validation where JSON falls flat. There's some people who wanted to make a JSON schema specification, but it didn't grow legs. Most people agree if they want very strong validation as part of their text format, they'll use XML and either DTDs or schemas. I don't tend to use formats that need/use schemas, so JSON's adequate enough for me.
With respect to JMC's post:
"Collection" both the type and the word were very unfortunate choices spawned of the same "Microsoft does things different for the sake of doing things different" attitude I complained about above. What pre-.NET VB called a 'collection', everyone else called a 'property pag', or "associative array", or "hashtable", or "dictionary". I'm not aware of any other language calling that a Collection.
Given the number of concepts VB intentionally names differently than other languages/Computer Science as a whole, I'm getting the feeling MS intentionally created this cognitive dissonance. If VB developers 'grow up' learning a different name for things, it makes other languages seem all the more confusing. That makes them less likely to try or stick with new languages. And that guarantees more developers who only buy MS tools.
I'd stop short of that but I do think there was a large dollop of hubris. "We know best and surely the rest of the software world will eventually come to recognise that. And if they don't... stuff 'em"Quote:
I'm getting the feeling MS intentionally created this cognitive dissonance
MS was the biggest player in the park for a loooong time but they weren't the smartest. Issues like this are the fallout of that.
I think one thing that may be getting forgotten in this talk about naming is that VB was specifically supposed to be the programming language for non-programmers so if things are done a bit differently in VB than the rest of computer science then it comes as no surprise to me.
It may be the case that JSON is better in every possible way, but there is no doubt that there is a lot of data that is available publicly that is XML, though some of it not so friendly. Maybe the reason for that is because Microsoft was (is?) so dominant for so long. If Microsoft produced a decent .Net JSON implementation I would be more inclined to use it as opposed to XML.