|
BELL END posted:I've never understood the big hullabaloo about this. Personally, I think a lot of "rules" like that are established in schools so that novice programmers learn to keep code easier to read and it's an unwritten rule that once you have a serious justification for it that all those old "rules" are irrelevant. That's kinda how I view rules in general, but unfortunately I keep getting flack for violating the "don't kill the mailman" rule because apparently I don't have enough experience killing people in general yet to justify killing the mailman.
|
# ¿ Mar 19, 2008 02:28 |
|
|
# ¿ Apr 28, 2024 04:38 |
|
Is there any way to create localizable annotations? The problem with annotations to me is that they're embedded in with the class and can't be localized easily. It's kind of a bitch having to use resource bundles at the moment to basically duplicate my comments in code externally, and I see myself repeating things a lot such that I'd rather just have a reference to a resourcebundle property within my annotations. I don't want to write property files any more, mommy
|
# ¿ Jun 26, 2008 20:30 |
|
Most of the time when I write stuff, I treat a null string and empty string as the same thing. That is, it's the exception more than the norm that null and empty are distinguishable to me (but these days I'm not doing any SQL stuff, so I imagine that's the real reason to distinguish typically). And really, an annotation for that? Wouldn't a straight-up method call to some static isNullOrEmpty method be faster anyway?
|
# ¿ Oct 22, 2008 17:38 |
|
Idran posted:Oh, you're right, I didn't even think about that. I always forget to check for null until it ends up biting me down the line, so that didn't even occur to me. Cool, I'll have to remember that convention, then.
|
# ¿ Dec 1, 2008 17:05 |
|
Fehler posted:Does anybody know where I could find sample code for comparing two WAV audio streams in Java? I need a function that returns some kind of "score" telling me how well the two streams match. From what I found on Google it looks like I need to do a Fourier Transformation, but I'm not really sure how to implement that and how to use it. hexadecimal posted:I am wondering how I can make my webservice return data without XML? That is I want the response to HTTPRequests to my webservice to just contain whatever the function returned, and no stupid XML wrapping that information.
|
# ¿ Jan 5, 2009 05:16 |
|
hexadecimal posted:Is there a way to configure Axis2 such that bugs in my webservice don't gently caress up the whole axis2 service?
|
# ¿ Jan 7, 2009 02:57 |
|
hexadecimal posted:I have some bugs in my webservice, that are probably threading related. However when it becomes unresponsive it blocks all other webservices. How can I make sure that my buggy webservice doesn't make other webservices and axis2 cry, besides the obvious "fix the bugs in the program"? hexadecimal posted:Stuff about RMI, SOAP, and HTTPRequests in Java On the other hand, what you're looking for has been done before, but the whole thing kinda makes me want to scream obscenities at all the useless compliance guys and standards-for-the-sake-of-standards attitude prevalent in so many organizations.
|
# ¿ Jan 11, 2009 01:12 |
|
So has anyone else messed around with dependency injection frameworks / libraries in Java? Google Guice seems to be fine for the jobs we've got, but we've got ourselves a home-brew dependency injection framework that is extremely clunky and I'm trying to get a better grasp on other options before overhauling the clunkiness we've got. I'm trying to keep it simple, but I do know I'm going to have to write a code generator to use any framework since what I'm working with is generated code that would take basically forever to perform the bindings manually. There aren't any dependency injectors that load class files and generate code for found classes according to some rules by chance, are there?
|
# ¿ Jan 28, 2009 23:52 |
|
TRex EaterofCars posted:Spring has a DI framework and I've found it decently powerful. With annotations it's not too bad to use, and configuration with Groovy is pretty easy. TRex EaterofCars posted:To answer your last question, do you have an example of what you're trying to do? If I understand you correctly, you want to do something similar to what Grails does. Grails (uses Spring) will load (and reload) arbitrary classes based on className by introspecting all classes in a given location. The "rules" are basically that the classes have to exist in a certain location. I'm sure you could do something similar. ==Scenario== We have N classes with some similar looking method signatures: pre:package foo1; public class A { public foo1.TypeA method1(..){..} public foo1.TypeB method2(..){..} } package foo2; public class B { public foo2.TypeA method1(..){..} // method2 from A is not here } We (try to) generate an interface with an offline code generator: pre:public interface IAB { public ITypeA method1(..){..} // invokes either A or B's method1 and returns an object that implements ITypeA, namely foo1.TypeA or foo2.TypeB public ITypeB fromA_method2(..){..} // } pre:public class AB { public IAB newInstance(int version){ switch (version){ case VERSION_A: return newInstanceof_A_via_reflection(); case VERSION_B: return newInstanceof_B_via_reflection(); default: throw new FuckinNoobException(); } } } pre:public static void main(String[] args) { int version = Integer.parseInt(args[0]); IAB foo = AB.newInstance(version); foo.method1(..); if (version == WEIRD_VERSION) foo.fromA_method2(..); } } We're currently running a reflection service that resolves type references across multiple packages, resolves dependencies, creates interfaces to union them per roughly congruent class (we supply corresponding classes via canonical names), and generates factory classes and methods that have the sort of usage (poorly) shown above. I'm looking for something more elegant, documented, and flexible than what we have. If you're curious about what beast might warrant all this, I'm trying to wrap an API that is evolving and I can never get rid of old versions nor their previous behaviors but somehow must provide access to all of them from a single API without incurring massive maintenance problems and to provide something concrete to quantify to other API developers how unstable their APIs are for their customers (political leverage on top of technical reasons - what's not to gain?). As new versions come up, we'd like to make adding support for the new API version's methods easier and to minimize memory footprint that would come with statically loading all the classes. So during runtime I pass the version number to be used to a factory that classloads the appropriate version of the library from disk and runs the underlying method or screams "not available in this version" if it's been idiotically removed. We'd like to have some compile-time verification of our unified API as well. Furthermore, I have maybe 10 or so of these API petting zoo collections to maintain... and growing. zootm posted:it'll enforce all (I think) of Java's type constraints so you don't get the exciting runtime problems due to erasure that you get with Spring XML
|
# ¿ Jan 29, 2009 19:49 |
|
TRex EaterofCars posted:Is there any reason you can't just bundle revisions of the APIs in individual jars and dynamically classload them depending on the version? You could then introspect the classes made available by that classloader (I found a particulary neat way of doing this just now), and make your interfaces that way. Then you don't have to play traffic cop. Or perhaps I still don't get it My job is to review APIs, package them into a unified API convention system, test the bejesus out of them, and play traffic cop among the different API versions and for different API categories. Imagine you're trying to keep every copy of PHP since 2.0, remove / delegate away redundant functions, and make a single API that you call the "golden version" of PHP that's distributed to PHP developers. Given how lovely PHP's APIs are, this has some value to anyone that must use PHP but hates its APIs. Oh, I took a look at Spring and it won't suffice for what we're trying to do - we'd have to generate XML instead of Java code like we do now basically. We're too far in the realm of "Java sucks for us, let's rewrite it" territory for it to work probably anyway.
|
# ¿ Jan 30, 2009 01:40 |
|
Struts and Tapestry are still wanted but are unlikely to be used in projects getting off the ground these days. Weblogic, JBoss, and Tomcat are still kings for "enterprise" application servers IMO. Never got a request for anything else besides Apache from my customers. For educational purposes, Stripes is certainly worth a shot - it looks quite fun, which is frankly a bit rare in the Java world to me. Is there any professional value besides educational ones in messing with Glassfish? I don't know of any prominent organization that's used GlassFish to serve their applications, but maybe I'm missing someone huge that's used it. It may turn out like Django in the Python world though and take off after another year or so. As far as jobs, it looks like few give a crap about your Java skills until you've spent 3+ years with Spring, Hibernate, Jboss, Tomcat, J2EE-specific frameworks, and a major DB or two. Otherwise, it's purely entry level it seems.
|
# ¿ Feb 9, 2009 17:54 |
|
csammis posted:Which of course begs the question of why streams were engineered to throw exceptions on close in the first place, since you're right and there's basically nothing to be done at that point. Sometimes I think monadic I/O is more sane than wrangling ridiculous try/catch/finally blocks that recursive expand into more try/catch/finally blocks.
|
# ¿ Apr 15, 2009 23:13 |
|
Sylink posted:I think facebook uses java because it loads up the Java machine or w/e with the big coffee logo, unless javascript does that as well? The most likely case of Java applets being used on Facebook is probably not from Facebook itself but some stupid ad. I can't really think of a good reason why image uploading would need Java on the client end unless you're adding some crazy stuff like photoshop-like features in your web browser. Image upload functions are typically heavy on the server side, which Javascript doesn't apply to (unless you count stuff like HaXe). So you're probably looking at using a language like PHP, Python, Java, C#, and so forth on the backend to read off your images or zip / rar file that's uploaded. After you pick your language, pick your appropriate megathread and off you go.
|
# ¿ May 27, 2009 15:10 |
|
You're correct to look at jProfiler first to address basic performance problems of any sort. The only stuff beyond that would be things similar to Rational's Purify software, which is mostly of use to C/C++ developers and which could arguably be made mostly useless via use of Electric Fence. Code analyzers can be a bit misleading if you try to turn them into metrics generators or something. The best analyzers to me spit out run-time statistics of objects and suggest items that could be turned static for better refactoring (there was a custom in-house tool I had before to do this, there's probably a commercial one around). One thing to watch out for when messing with the fun that is garbage collection is to actually understand what the metrics of garbage collection mean and to avoid tweaking. Holly Cummins from IBM had a pretty comprehensive overview of garbage collection at a talk I watched online a while ago, and at the very least you should remember some quick points that will help you avoid a lot of common pitfalls.
|
# ¿ Jun 2, 2009 16:59 |
|
Also, let's not forget that objects are objects and so require memory, and if you're running a heavily loaded system with this happening often enough, it can cause performance issues. But frankly, throwing exceptions is one of the last places to look for improving application performance, and if there is a problem, it's always been an I/O bottleneck that gets hit due to the exceptions (20k exceptions? Try 4TB of exception stacktrace data thrown / day to a single disk). If you find little hope in the job you've got, it's in everyone's interest for you to move on. Don't think you're doing anyone a favor by staying. Just go. Even though the economy sucks, people are still hiring - several of my coworkers have left in the past 4 months and are obviously getting jobs, for instance.
|
# ¿ Aug 19, 2009 23:53 |
|
Due to the limitations of hardware (and software), at present there is no (consumer-available) system that can address the full 64 bit range of memory on our current 4KB page standard x86 addressing model. What we do have, however, are systems that can do 40, 48, and etc. bits of physical memory and so we can have enough memory addressable for the foreseeable future while hardware can catch up to the needs of such software. In some sense, we already had 40-bit memory systems a long time ago due to how addresses work in modern "32-bit" x86 systems, but the 8 bits weren't usable for anything that JVM designers would want to expand. The reason you would care about a 64-bit JVM is if your Java application needs more than 3GB or so total of memory and you cannot distribute the data across multiple nodes in a distributed execution model. Also, due to fragmentation issues, you may require a 64-bit JVM even if you're not that close to 3GB of memory required.
|
# ¿ Sep 21, 2009 16:57 |
|
Tulenian posted:Does the Sun 32-bit hotspot JVM actually support 3GB of memory? I've never been able to get it to allocate more than ~1.5GB. Any more and it just refuses to start.
|
# ¿ Sep 22, 2009 16:14 |
|
zootm posted:Of course you could consider scaling out instead of up with something like Terracotta, which to me looks like black magic.
|
# ¿ Oct 10, 2009 19:44 |
|
Parantumaton posted:Being interested in dynamic clustering, how does Terracotta scale in practice, do I have to bring the whole cluster down to add more nodes or can I dynamically pour more resources into it, what are the limits/caveats you've hit at with it etc?
|
# ¿ Oct 12, 2009 17:03 |
|
Parantumaton posted:If your desired range is 1...7 billion and you can get to 2 billion, why not just do that one to three times, add those three together and then add another billion?
|
# ¿ Nov 24, 2009 14:36 |
|
The funny part is that the bytecode changed in other areas anyway, which means they might as well have let them change it. I've always thought the worst thing about Java isn't the language but the JSR and JCP.
|
# ¿ Feb 10, 2010 00:05 |
|
fletcher posted:Looking for a way to generate some charts in Java and output to an image. JFreeChart looks pretty sweet, anything else I should check out before diving in?
|
# ¿ Feb 12, 2010 23:34 |
|
I should add a note that there is nothing in the Iterator specification that says that you must return the same item order for the same collection every time. It could be completely different each time even though nothing's happened to the data since the last time. It just so happens that people count from 0 to the end of the list for arrays and lists, for example, and we're all used to arrays returning the same thing every time as a silent, implied convention. This idea breaks down when you get into hash tables and data structures that have several intuitive ways to travel through all the elements.
|
# ¿ Mar 4, 2010 19:52 |
|
rawstorm posted:Wow, this is really weird. I had Firefox open, and then I opened the program and it was running fine. Then I opened a new blank tab in Firefox and the program kept running fine. Then I went to https://www.cnn.com in the new tab, switched quickly back to my program, and it ran at normal speed for about 2 seconds and then suddenly started going really fast. What the hell is going on !?
|
# ¿ May 10, 2010 07:11 |
|
So I like python decorators. Is there a Java library that can provide some of the sugar to do something like it? I've realized that what I've written to strip a lot of boilerplate in my class hierarchies is better expressed in that manner. I'm not terribly familiar with Spring, but maybe I could use method injection in libraries like Guice or Tie to do something like a Python decorator in reuse of code through an annotation. DI is so awesome but it's hard to design with DI in mind sometimes and you'd rather wait until you actually need DI before your unit tests and mock objects get out of hand. So I'd try to make sure whatever solution I use doesn't conflict with Guice or Spring annotations. Last I remember both libraries do some bytecode weaving and the thought of breaking tools like that scares me.
|
# ¿ Aug 12, 2010 08:09 |
|
|
# ¿ Apr 28, 2024 04:38 |
|
I'd still prefer to get RAII / RAII-like conventions like C#'s using, although Closeables could be turned into syntactic sugar like for ( : ) loops, but given the history of the JSRB, I only expect after Always hoped to have something like a synchronized block become an arbitrary block reflecting the scope of an object's lifetime with the end of the block automatically invoking the finalize method. But... garbage collection and
|
# ¿ Aug 26, 2010 09:25 |