3 ms·
Dude stuff goes in and out fashion faster than anything in tech. Orms went in, Orms went out, then in again(Django, rails) then out. Just need to stop being zea
by UK-AL 14y ago
Dude stuff goes in and out fashion faster than anything in tech. Orms went in, Orms went out, then in again(Django, rails) then out. Just need to stop being zealots following the latest trend and get things working.
People take the immutable route, then some other guy tells you your being silly. Trust me I've been programming long enough.
Besides you don't need Mutability for ejb. The majority of ejbs are just used to access the db.
- eropple 14y agoNo, thank you, I won't trust you on this. I've been a fairly loud critic of ORMs since the first time I was exposed to them (Hibernate, as it happens)--having seen them in practice hasn't changed that a bit. The conventional opinion on them may have changed, but mine never has; mutable data structures increase code complexity and greatly increase the surface area for state changes in places it wasn't (or shouldn't have been) intended. And you may not need mutability for EJB, but it's almost always the case that you have it--it's partly a side effect of having to deal with people like you who consider it "not a big deal" and partly because JavaBeans are completely misused[1]. (For those following along at home, who might not be familiar with the culture of Java programmers, mutability in absolutely bizarre places eventually ruins your day at least once. See, for example, the Date[2] class, which for some very Java-y reason is completely and totally mutable. Questions related to the Date class are among my favorites for determining whether a Java programmer has any concept of mutability, and why "do you use Joda Time?" is a decent barometer of basic not-going-to-kill-your-project competence.) . Seriously, though: is "just get it working" the entirety of your defense for diverging from good practices? This isn't just me calling it "good practices," this is what Bloch says in head-shrinking detail in Effective Java and what pretty much everybody else who's had to write Java in anger eventually agrees with. This[3] isn't the best thing in the world on the topic, because I'm not going to quote Effective Java at length, but if you can read that and then come back with "just get it working," I'm gonna have to go light a candle for whoever inherits your code down the line because I've been there (still am there, in the day job) and it's hell. [1] http://www.javapractices.com/topic/TopicAction.do?Id=84 http://www.javapractices.com/topic/TopicAction.do?Id=84 [2] http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Date.html http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Date.... [3] http://www.javapractices.com/topic/TopicAction.do?Id=29 http://www.javapractices.com/topic/TopicAction.do?Id=29
- UK-AL 14y agoI'm a functional programmer I know what immutable is. However if you've programmed a game in a functional programming language you know it also requires the code to become more complex in various situations. You have to introduce reactive programming to do it properly. No longer can you simply change to coords of an entity to change a position. In that situation I would recommend introducing mutability, trying avoid mutability would make it more complex. Date api is one broken things about java. Everyone knows it is broken. There about ten billion versions of good practise, I could quote them and say you are diverging from good practise? I also recommend you keep things immutable, but not if it makes things difficult.
- eropple 14y ago> if you've programmed a game in a functional programming language you know it also requires the code to become more complex in various situations Irrelevant. A game is not a web application. A game has a claim to require mutability for performance concerns, but mutable state is generally safer in such a use case. A game is likely to have a few threads, each with a dedicated task or set of tasks, whereas a web application is not so constrained and any request may effectively duplicate another. Web applications that are cavalier about mutable state literally-literally invariably decompose to "synchronized blocks for all the things!" and, seriously, who wants to have anything to do with that? > I can also find lots literature about following java bean convention as good practise. Your just cherry picking literature. I'm not "cherry-picking" a Goddamned thing: I'm referring to one of the major, canonical sources of Java convention. You may find shitty Apress books that say "sure, use JavaBeans everywhere!", but that's why they're shitty Apress books. Effective Java is the book that literally-literally every competent Java programmer I have ever met has read and fully digested. There are areas of style where not everyone I've met agrees with Bloch, but immutable-by-default is very widely accepted except in areas (such as game development, though that is, again, irrelevant to the topic at hand) where performance becomes a legitimate concern. But, except for those edge cases (and they really are edge cases, they certainly don't apply to web development) you are not going to find someone of significant credibility and stature in the Java community who is going to say "follow JavaBean convention". You just aren't. (If you were, you already would have.)