Live data from Hacker News

Arguments against JSON-driven development

okigiveup.net

61–70 of 306 posts

Re: Arguments against JSON-driven development

#61

> If an object is just there to store data and no behaviour, then that's fine - don't add behaviour if it doesn't need it. In that case, you want values rather than objects. Alas, Python doesn't have compound values.

Please stop it. Every single time anything so much as slightly related comes up, you talk about compound object. Incessantly. And then you act superior when nobody knows what you mean, or cares about compound values. They're not really relevant to this discussion anyways, as storing data as desribed in GPP is perfectly reasonable. The worst part is, your definition of "value" and "object" in this context is so far ou…

It's relevant. If it weren't, there wouldn't be a debate regarding the usefulness of behaviorless objects.

Re: Arguments against JSON-driven development

#62
post #51

I'm not entirely in agreement. Use of object-oriented programming paradigms here would merely distribute the logic that is necessary to achieve the desired mapping over multiple points in the code. The example function presented is only marginally too complicated. I'd split it in two: one to obtain the book list given the same arguments as the example function, and one taking the result as its only argument to build…

With the added benefit that you can reuse these functions for new data shapes more often than I expected when switching to this style.

Re: Arguments against JSON-driven development

#63
post #43

I agree with this and I've raised it several times in Objective-C codebases that can some times end up littered with NSDictionary:s everywhere taking no advantage of the Objective-C type mechanics. I don't think it's necessarily as bad in python or javascript. This is because these languages are dynamically typed and that diminishes the benefits of deserializing json to a native model. It's still valuable because you…

It's good to use lots of NSDictionary's in Objective C, in my opinion. The alternative is to create lots of different object types that takes much more code, and very little benefit for that extra code. If you're just shifting data around then there's no need to define objects for them.

Re: Arguments against JSON-driven development

#65

Earlier quoted context omitted.

...And outside FP, nobody cares, or uses that definition of value. As noted in my above post.

It's useful when writing Prolog programs too.

Logic programming's actually pretty close to FP.

Re: Arguments against JSON-driven development

#66

Earlier quoted context omitted.

Please stop it. Every single time anything so much as slightly related comes up, you talk about compound object. Incessantly. And then you act superior when nobody knows what you mean, or cares about compound values. They're not really relevant to this discussion anyways, as storing data as desribed in GPP is perfectly reasonable. The worst part is, your definition of "value" and "object" in this context is so far ou…

It's relevant. If it weren't, there wouldn't be a debate regarding the usefulness of behaviorless objects.

Well than FFS express yourself clearly.

Re: Arguments against JSON-driven development

#67
post #7

Earlier quoted context omitted.

When using parsers like e.g. Jackson or Gson for Java, this process is completely transparent and does not require any active thought from the developer - well, maybe if there's very specific formats that don't map 1:1 with the class that should be instantiated or generated from the json object. It's a bit more tricky in JS, both client-side and node. You can't work with the json string there, but after that you work…

I've never had good experiences with automated serialisation -- even though it sounds like other people do it with success. What's the secret? To give you a flavour of the kind of poblem: In C# (or rather .net) json.net reads JSON and calls setters from the target class. That means the setters have to be public, and you don't know what order they will be called in, and you have no real signal about when it is all don…

It sounds like you're parsing the JSON straight into your business objects, which is the source of the problem. You need an intermediate class which represents a strongly-typed version of the JSON message. So JSON.net goes from a JSON string into this message object, then you write your own code (or, if it works for you, use a tool like automapper), to go from that into your business classes.

Re: Arguments against JSON-driven development

#70

Earlier quoted context omitted.

It's useful when writing Prolog programs too.

Logic programming's actually pretty close to FP.

Not really. Prolog is first-order. Functional languages, just like object-oriented ones, are higher-order.
Post reply on HN