5 ms·
Does anybody get anything from his writing? I have seen several posts of his here and they all are either trivial and/or give a fancy name to some standard codi
by maxxxxx 10y ago
Does anybody get anything from his writing? I have seen several posts of his here and they all are either trivial and/or give a fancy name to some standard coding construct. I think what he is describing here is the advantages of immutability which anyone who has heard only a little about FP knows already.
- mattmanser 10y agoHis book on refactoring was one of the most revelatory programming books I've ever read, and was a major influence on how I program. I'm sure if I re-read it today I'd raise a few eyebrows at sections, but it's 17 years old now. I've no idea how good it is now, given how much we've moved on, but it was very good back in the day. He's had some real hits. But I must admit, I find this article a bit silly. He's had some stinkers too. Worse still, this is an obvious problem because the solution's been in other languages for decades, overloading equivalence, it's just not in javascript. It's just not a common programming problem outside of certain domains. And, he knows it. So I really do not understand the point of that post. There was a time when every single one of the "learn .Net 1.0 in 28 days" books would have at least a paragraph about overloading Equals and GetHashCode. This is from 2005, for example, and even uses the same example: https://msdn.microsoft.com/ru-ru/library/ms173147(v=vs.80).aspx https://msdn.microsoft.com/ru-ru/library/ms173147(v=vs.80).a... The blog post seems a decade too late.
- wwwigham 10y agoIMO, The issue with this article is that it conflated a desire for immutable record types (as you'd see in a functional language) with something which requires equivalence overloading in a language which does not support them (as you'd find in a heavy OO language). I think while he presented _A_ solution to the specific issue he encountered (wanting to compare algebraic types as cohesive units in Java), it is not the _best_ general solution to the issue - in fact, it's really not the best solution in any language without built-in record types, as it can lead to costly hidden comparison times and unneeded memory growth (which most design patterns I would say should discourage this kind of hidden performance issue). This is a data structure problem which should be attacked much like how a compiler implementer would attack it - by being lazy and doing at little work as possible. Instead of making similar objects appear equivalent - make identical objects be references to the same object! Since we already decided to let records be immutable, it actually turns out quite nicely in JS, as I have written elsewhere - and I'm confident that the same cached-reference/object interning strategy could be used in Java, too.
- jowiar 10y agoKey points in here: - Thinking differently about Values vs. References (which you may or may not be used to depending on your language) - Mutable "values" are dangerous (and it might be worth thinking about what constitutes a "value") - Translating incoming low-level numbers and strings into proper "values" helps avoid errors.
- swanson 10y agoA concise explanation of a pattern that developers of newly every level can understand and link to? Nope, no value there! /s
- maxxxxx 10y agoIt just seems that this has been discussed to death already. The only new thing is that he calls it "ValueObject". I already dread people talking about "ValueObjects" and I will have no idea what this is. I thought "immutable objects" is the standard term.
- nightski 10y agoIt makes more sense in the context of domain driven design (ddd) but I don't believe he references this at all in the article. But based on his other articles I think that is what he is getting at.
- macspoofing 10y ago>The only new thing is that he calls it "ValueObject". That's not a new name. It's been around forever.
- jdlshore 10y agoThis isn't about immutability, this is about the power of introducing value objects to a system. (Immutability is just a property of good value objects.) Most code I read does not use value objects. It's more common for me to see primitive obsession [1], data clumps [2], arbitrary structs, or the "struct + service" antipattern (looking at you, Angular 1). Granted, I'm not working with FP languages. When you migrate code to use value objects, then follow up by moving associated behavior into the value object, there are significant knock-on benefits to your design. Value objects may be simple, but they're not obvious. If they were, more code would use them. [1] http://www.jamesshore.com/Blog/PrimitiveObsession.html http://www.jamesshore.com/Blog/PrimitiveObsession.html [2] http://www.martinfowler.com/bliki/DataClump.html http://www.martinfowler.com/bliki/DataClump.html
- Silhouette 10y agoValue objects may be simple, but they're not obvious. If they were, more code would use them. To the extent that the concept is relevant, the difference is obvious unless you only ever use languages that are ambiguous about reference/value semantics. If you use a language like C or C++ or even assembly, where pointers and taking an address are explicit and fundamental concepts, there's mostly no problem. Your data is a value by default, and if you want a reference (pointer) instead, you just make one, explicitly. The exception is arrays, and in not entirely unrelated news, array semantics in C and C++ are a significant source of bugs. If you use a functional programming language, again data is typically immutable unless you explicitly use some sort of reference type, so again no problem. I have long maintained that one of the worst of Java's many design flaws was using the exact same syntax to represent two distinct but related concepts, depending on whether you were referring to a primitive or a class-based type. At least with the static typing you can see which you've got, though. I can't fathom why you'd deliberately design a language to work like JS or Python, where not only can the exact same syntax mean two completely different things but which you get depends on dynamic typing information that you can't even see until runtime, or even on the exact values you're using rather than their types, in a case like Python's handling of small integers. I shudder to think how much productivity has been lost by now to bugs caused by mixing up .equals() with == in Java, == with === in JS, and == with `is` in Python.
- 10y ago
- hota_mazi 10y agoAgreed. This post is the kind of centithread we were having on Java mailing-lists fifteen years ago, talking about EJB's, DTO, the dangers of mutability, and the like. It's all established knowledge. Every programmer worth their salt understands the difference between value and reference equality and is proficient in how their language of choice supports these concepts. Also, for perceived thought leaders, all these people have completely failed to update their knowledge with modern technologies and languages. All you see from the Fowler and Uncle Bob of the world is Java and Javascript. How about some Rust, ELM, Kotlin, which encompass the more modern trends of programming and which address the kinds of problems described in this article in one liners? Also, I still chuckle at the fact that Fowler's web site (which he developed himself and called a "bliki", blog + wiki) is still incapable of supporting article titles with spaces in them, hence "ValueObject". That's not exactly a resounding endorsement of software engineering abilities.
- icebraining 10y agoAlso, I still chuckle at the fact that Fowler's web site (which he developed himself and called a "bliki", blog + wiki) is still incapable of supporting article titles with spaces in them, hence "ValueObject". That's not exactly a resounding endorsement of software engineering abilities. http://www.martinfowler.com/bliki/BimodalIT.html http://www.martinfowler.com/bliki/BimodalIT.html
- deleted 10y ago[deleted]
- gutnor 10y agoHe has been doing a bit of summarising both sides of an argument too, more as a sort of not to biased Software Development journalist. That can be useful, maybe not when you are in the thick of it, but for newcomer or people that have missed the great ideological battles of the last 6 months.
- peeters 10y agoSure, I find his articles are often "duh" to an experienced programmer. But on the other hand, it's a great resource to be able to point junior devs to. Instead of say explaining why value objects should usually be immutable, you can give a brief summary and then say "read this". I find it really similar to stuff in Effective Java. Sure there's nothing too revolutionary in that book, but in the aggregate it makes up my best coding practices, and when somebody questions one small piece of those coding practices, I can send them to a brief, to-the-point item in Effective Java.
- nickbauman 10y agoYou would be surprised how many people get ValueObject wrong. Most of the time the wrongness is due to how value objects are implemented as such. The concept of instances that are consistent with equals (immutability) comes later in most people's career. It doesn't help that hugely popular languages like Java seem to push people away from immutability.
- hughw 10y agoAs someone told me in college as we watched some Saturday morning cartoons: They don't need to make new cartoons because they keep making new kids.
- bshimmin 10y agoI felt like this quite strongly about his "Collection Pipeline" article (http://martinfowler.com/articles/collection-pipeline/ http://martinfowler.com/articles/collection-pipeline/) - he's definitely guilty of fancy name syndrome in that one (I think "Value Object" is a fairly well-known term, though - certainly one I was using a decade ago). On the other hand, both this article and the "Collection Pipeline" one contain a lot of useful information, concisely and informatively expressed, which would be beneficial to a junior developer as a general introduction to the subject.