Search Results

Search found 3 results on 1 pages for 'berry120'.

Page 1/1 | 1 

  • Would an immutable keyword in Java be a good idea?

    - by berry120
    Generally speaking, the more I use immutable objects in Java the more I'm thinking they're a great idea. They've got lots of advantages from automatically being thread-safe to not needing to worry about cloning or copy constructors. This has got me thinking, would an "immutable" keyword go amiss? Obviously there's the disadvantages with adding another reserved word to the language, and I doubt it will actually happen primarily for the above reason - but ignoring that I can't really see many disadvantages. At present great care has to be taken to make sure objects are immutable, and even then a dodgy javadoc comment claiming a component object is immutable when it's in fact not can wreck the whole thing. There's also the argument that even basic objects like string aren't truly immutable because they're easily vunerable to reflection attacks. If we had an immutable keyword the compiler could surely recursively check and give an iron clad guarantee that all instances of a class were immutable, something that can't presently be done. Especially with concurrency becoming more and more used, I personally think it'd be good to add a keyword to this effect. But are there any disadvantages or implementation details I'm missing that makes this a bad idea?

    Read the article

  • Dealing with video (DVDs, .avi .mkv) in Java

    - by berry120
    After looking around for a decent library for playing videos in Java, I've come unstuck. Everyone around is screaming not to use JMF because it's outdated, old and requires the user to install it, other alternatives such as VLCJ seem good if they work but are still relatively unstable and rely on hefty amounts of native code, and as for dealing with DVDs, I haven't found a single option available! Weighing up my options at the moment, it seems like realistically it's either JMF (despite its disadvantages) or waiting until JavaFX 2.0 comes out and then using that. VLCJ just seems too unstable which isn't really something I can live with. Are there any sensible options other than the ones I've listed above, and what would you go for? I'm not against native code per-se, but it has to be reliable and work on Windows, Mac and Linux.

    Read the article

  • Are instance initializers good or bad?

    - by berry120
    I personally quite like instance initializers - I use them to assign default values to things such as collections so when writing constructors I don't have to remember to assign them the same default values each time. It seems quite elegant to me - avoids annoying NPE's popping up and avoids duplicate code. A private method doesn't seem as nice because a) it can't assign values to final fields, b) it could be run elsewhere in code and c) the method still needs to be explicitly called at the start of each constructor. However, the flip side with others I have spoken to is that they're confusing, some people reading the code might not understand what they do or when they're called and thus they could cause more problems than they solve. Are proper use of these initializers something to be encouraged or avoided? Or is it an "each to their own" case?

    Read the article

1