|
Slime posted:So I've got an object which contains an object which contains a 2D array of objects that each have an object that has a vector that the top object needs to get stuff from. It's kinda lovely, any recommendations on handling this in a way that doesn't suck? You'll probably have to be more specific to get a better answer. Is it just that the code seems messy when you do those accesses? Is performance or memory an issue? Do each of these objects just exist to store the next object you mention or do they do other important things? You could amortize those accesses a little by giving the top object a vector of vectors and going through each object and getting references to what you need and stuffing them in there, but I'm not sure what that would really accomplish in terms of memory use or complexity reduction, just make the code a little cleaner when you go to look through the vectors.
|
# ? Apr 16, 2015 19:27 |
|
|
# ? May 18, 2024 21:27 |
|
I recently inherited a webapp that uses Spring, and every so often in the logs I see messages like this:code:
|
# ? Apr 16, 2015 19:33 |
|
carry on then posted:You'll probably have to be more specific to get a better answer. Is it just that the code seems messy when you do those accesses? Is performance or memory an issue? Do each of these objects just exist to store the next object you mention or do they do other important things? The objects do other things than just store the next object, yeah. It's mostly just a case of the code seem messy and hard to read, if it's affecting performance or memory use I haven't seen any real problems yet. Since the list of variables I'm accessing is pretty small, I might just write a method in the top object that basically acts as shorthand. That would at least improve user readability, even if it doesn't truly tidy up the code.
|
# ? Apr 16, 2015 19:35 |
|
Slime posted:The objects do other things than just store the next object, yeah. It's mostly just a case of the code seem messy and hard to read, if it's affecting performance or memory use I haven't seen any real problems yet. Since the list of variables I'm accessing is pretty small, I might just write a method in the top object that basically acts as shorthand. That would at least improve user readability, even if it doesn't truly tidy up the code. That's about all you can do, short of restructuring everything based on how you're using those objects, but that might be worse overall if it makes some other common task messier in exchange.
|
# ? Apr 16, 2015 19:37 |
|
carry on then posted:That's about all you can do, short of restructuring everything based on how you're using those objects, but that might be worse overall if it makes some other common task messier in exchange. Yeah, I thought that'd be the case. Restructuring everything really isn't worth the time, and like you said it'll probably just introduce problems elsewhere. It just bothered me because it seems like a kludge solution. There's no such thing as perfectly structured code, you're always going to run into places where your structure is making something kinda messy.
|
# ? Apr 16, 2015 19:42 |
|
Slime posted:Yeah, I thought that'd be the case. Restructuring everything really isn't worth the time, and like you said it'll probably just introduce problems elsewhere. It just bothered me because it seems like a kludge solution. There's no such thing as perfectly structured code, you're always going to run into places where your structure is making something kinda messy. This is where "don't prematurely optimize" starts to make sense. It seems like a problem to you as you go, but it's probably best to write it out, and look back and see whether you have performance or memory problems, or the code is excessively buggy, and then start looking for ways to address those issues. You'll probably find it's not that big of a deal after all and your first pass is fine, or you might discover a better solution altogether.
|
# ? Apr 16, 2015 19:48 |
|
I have an extra credit assignment that involves rewriting a server I've already implemented via thread pools and selectors with Asynchronous IO. My professor intimated that I'd want to take a look at AsynchronousSocketChannels - but our textbook doesn't mention them at all. Anyone have any recommendations on where to find a quick-and-dirty introduction to network IO with Asynchronous Sockets and how it differs from selector-based IO?
|
# ? Apr 16, 2015 23:37 |
|
VegasShirtGuy posted:Did you change the socket to non-blocking at some point while troubleshooting? If so put it back to blocking mode. I think I figured out why it was happening. When I changed the reader to being in its own thread I never changed the way it is called. The original setup was a timer that called an actionperformed method to read from the stream ever 200ms. I had changed this to start an instance of the reader thread instead, but without checking if the old thread was done. So it was probably a shitton of threads all trying to use the same Scanner object. I changed it to have only one thread started and that thread just loops forever with a sleep(200) at the end and the problem stopped.
|
# ? Apr 17, 2015 02:29 |
|
Spiritus Nox posted:I have an extra credit assignment that involves rewriting a server I've already implemented via thread pools and selectors with Asynchronous IO. My professor intimated that I'd want to take a look at AsynchronousSocketChannels - but our textbook doesn't mention them at all. Anyone have any recommendations on where to find a quick-and-dirty introduction to network IO with Asynchronous Sockets and how it differs from selector-based IO? Good news for you; there are resources on the internet now, not just in books!
|
# ? Apr 20, 2015 05:11 |
|
Zorro KingOfEngland posted:I recently inherited a webapp that uses Spring, and every so often in the logs I see messages like this:
|
# ? Apr 21, 2015 06:07 |
|
It seems to be happening at random times throughout the webapp's lifecycle, not just at startup and redeploy. I think I've narrowed it down to that atmosphereResourceImpl bean, but nothing concrete yet. It doesn't seem to be affecting anything so I'm letting it be for now.
|
# ? Apr 21, 2015 15:54 |
|
Can you post what atmosphereResourceImpl looks like (anonymized if need be)? If there's something in your bean that's forcing the application context to refresh I would expect it to be pretty evident in the code.
|
# ? Apr 21, 2015 23:04 |
|
Can anyone recommend what I should be looking at to start programming windows applications in Java (Swing or JavaFX)? I want to build a file explorer and mass renamer that is standalone and looks just like a Windows program. As background, I'm a novice programmer that has so been working on command line programs in Linux with lots of XML processing. When I last looked at Java GUI making for windows in 2002 everything was ugly and slow, so hopefully things have moved on... So far I've figured out I should first start using an IDE (netbeans I guess?), and second pick JavaFX or Swing to work on a GUI. I don't need fancy graphics (but keen for it to have a 'Windows' look and feel), so maybe JavaFX isn't worthwhile if I'm going to rely on lots of stackoverflow answers to help me struggle through. However if its much easier than Swing and better if starting from scratch I could look at that. Any pointers welcome.
|
# ? Apr 23, 2015 21:20 |
|
headlight posted:Can anyone recommend what I should be looking at to start programming windows applications in Java (Swing or JavaFX)? I want to build a file explorer and mass renamer that is standalone and looks just like a Windows program. Either use Eclipse with Windowbuilder (https://eclipse.org/windowbuilder/) or use Netbeans so that you can use Swing with a nice WSYWIG interface. You don't want to manually code all those positioning values and stuff. I personally prefer Eclipse over Netbeans any day. I wouldn't bother with JavaFX if you don't need to be rendering custom stuff. Keep it simple; sounds like you just want basic Windows windows and dialogues, right? Whats your plan here for the application? Open up the designer, drop in a form and some buttons and stuff, and then you can double click on them or right click on them and add code for how to handle them, change their properties, etc. You can hop back and forth between the designer view (what the components look like and how they're arranged) and the actual source code view, which will include some autogeneration to make it super easy for you. Alternatively for windows just use C# and WinForms (and like Visual Studio Express or something), C# and Java are practically the same thing and WinForms will give you a really nice Windows looking application with very little effort, just like the WSYWIG editors I described above. That said you can do Swing ones and it'll work just fine, but the interface will look a little more Java than standard Windows style. No biggie.
|
# ? Apr 23, 2015 21:26 |
|
headlight posted:Can anyone recommend what I should be looking at to start programming windows applications in Java (Swing or JavaFX)? I want to build a file explorer and mass renamer that is standalone and looks just like a Windows program. DO NOT USE NETBEANS!!!! intelij idea community edition or eclipse luna at a push... but not the horror that is NETBEANS!
|
# ? Apr 24, 2015 06:21 |
|
I'm going to push back on you two fuckers and say USE NETBEANS instead, eclipse sucks and while I've been using InteliJ for 3 months I'm still not sure it's better than NetBeans. Seriously it doesn't matter, they all will suite your needs so pick one based on any arbitrary criteria you like (looks or ease of installation) and just go with it. NetBeans WYSIWYG is dope
|
# ? Apr 24, 2015 07:05 |
|
Zaphod42 posted:Stuff TheresaJayne posted:Stuff Janitor Prime posted:Stuff Thanks all - sorry I didn't meant to start a which IDE is best discussion, any will do, but this is all most helpful. I'll guess I'll start with Swing and go from there. Thanks again!
|
# ? Apr 24, 2015 07:48 |
|
Zaphod42 posted:You don't want to manually code all those positioning values and stuff.
|
# ? Apr 24, 2015 15:13 |
|
Thanks guys UI got 99% in the last assignment and the teacher commented on my nice try/catch
|
# ? Apr 25, 2015 02:00 |
|
Zaphod42 posted:Either use Eclipse with Windowbuilder (https://eclipse.org/windowbuilder/) or use Netbeans so that you can use Swing with a nice WSYWIG interface. You don't want to manually code all those positioning values and stuff. I personally prefer Eclipse over Netbeans any day. Java (with Swing and JavaFX) is one language where the usage of a UI builder actually harms productivity (a lot). Windows resource files ... yea, sure, you don't wanna touch that with a 10m pole. But Java, one person earlier brought up MigLayout. It's great and it does a good job. However, if you take 5 minutes to learn GridBagLayout (honestly, doesn't take more than 5 minutes using the tutorial) you will find that your more complex UI's are very easily implemented (in a maintainable manner) using it. Of course, for simpler requirements, other layouts may be more appropriate, you should get familiar with them. Using a UI builder is almost always a recipe for getting a lovely and unmaintainable code at the end. And yeah, try out IntelliJ. Then go and use proper IDEs, such as eclipse and netbeans. They have the audacity to ask for money for intellij. The nerve ...
|
# ? Apr 25, 2015 02:28 |
|
On the topic, does anybody here unit tests swing? I'd like to know what program you use, but also how to structure gui unit tests (i find it so hard to isolate the gui)
|
# ? Apr 25, 2015 04:49 |
|
Don't bother trying to unit test your GUI. Try to get as much of your logic out of the GUI as you can (ideally everything not specific to the construction and arrangement of your Swing components) and test a layer down, then cover your presentation layer during end-to-end/functional/whatever-you-call-it testing. I'd go so far as to say that any sort of automated testing of an AWT/Swing or SWT app is of questionable value since the tooling that I've seen is all hugely dependent on implementation details so you're likely to end up spending a lot of time rewriting the tests.
|
# ? Apr 26, 2015 17:33 |
|
quote:so you're likely to end up spending a lot of time rewriting the tests. quote:Try to get as much of your logic out of the GUI as you can (ideally everything not specific to the construction and arrangement of your Swing components
|
# ? Apr 26, 2015 17:36 |
|
CarrKnight posted:On the topic, does anybody here unit tests swing? I'd like to know what program you use, but also how to structure gui unit tests (i find it so hard to isolate the gui) Unit Tests are supposed to test your business logic with some simple interface tests for DB and such. If you are programming a MVC model you start testing at the controller and stop at the DAO. If you work for a big corporation you will probably have to test from View Bean down to raw DB code.
|
# ? Apr 27, 2015 06:15 |
|
CarrKnight posted:You are right, unfortunately in my field we tend to use old libraries that make this hard. But yeah, I try my best. That's super unfortunate. Are you ending up with a bunch anonymous SwingWorkers inside your Swing classes? Are you running your business logic on the EDT?
|
# ? Apr 28, 2015 01:24 |
|
JimboMaloi posted:That's super unfortunate. Are you ending up with a bunch anonymous SwingWorkers inside your Swing classes? Are you running your business logic on the EDT? I am not running the business logic on the EDT, but that might be maybe the only good thing I can say about the libraries I use.
|
# ? Apr 28, 2015 04:22 |
|
Simple stupid question: Im trying to use SimpleDateFormat to parse a timestamp like this: ""2015-03-11T00:00:00-0300"" (inside a jackson ObjectMapper, to parse a JSON response from a webservice). What is the correct format to use? Ive tried "yyyy-MM-dd'T'HH:mm:ssZ" and "yyyy-MM-dd'T'HH:mm:ss-Z" and other combinations and nothing seems to work. EDIT: nevermind it: I was trying to parse it to a DateTime, parsing it for a Date works (using "yyyy-MM-dd'T'HH:mm:ssZ") Elias_Maluco fucked around with this message at 01:02 on Apr 29, 2015 |
# ? Apr 29, 2015 00:35 |
|
How the hell do I get a jar GUI to actually be responsive when I run it on Windows 8.1? I didn't make the file, so I can't really edit it (Stanford's NER tagger, for the record). It starts up OK and I can click a menu, but as soon as it opens that menu, nothing else responds except the close button.
|
# ? Apr 30, 2015 15:33 |
|
Java GUIs aren't really known for their responsiveness, but that almost sounds like a bug of some sort. Are you able to try it on another computer to see if it behaves the same? (I'm not able to try it myself right now.)
|
# ? Apr 30, 2015 15:37 |
|
Yeah, I can run it fine on the school's server (Windows Server 2012, I believe).
|
# ? Apr 30, 2015 15:44 |
|
You could try launching it from the command line and seeing what gets printed when you click the menu, that might give you some insight. Other than that the only thing to check is that you have the right version of the JRE (I see the software you're using requires Java 8,) and that you have the latest updates for it from Oracle. Also, it's kind of a one-in-a-million chance, but why not try deleting your copy and redownloading it? Occasionally things do get corrupted which is why some people provide the MD5 hash of their binaries so you can be absolutely sure no bits got flipped.
|
# ? Apr 30, 2015 16:15 |
|
carry on then posted:You could try launching it from the command line and seeing what gets printed when you click the menu, that might give you some insight. Nothing is printed. It seems to fork the command, since the prompt looks ready to accept another command. quote:Other than that the only thing to check is that you have the right version of the JRE (I see the software you're using requires Java 8,) and that you have the latest updates for it from Oracle. java -version returns 1.8.0_45, which is Java 8, correct? quote:Also, it's kind of a one-in-a-million chance, but why not try deleting your copy and redownloading it? Occasionally things do get corrupted which is why some people provide the MD5 hash of their binaries so you can be absolutely sure no bits got flipped. I tried this, too, and no luck.
|
# ? Apr 30, 2015 21:33 |
|
Can you run other Java JARs okay? Something sounds wrong with your JRE.
|
# ? Apr 30, 2015 22:09 |
|
Zaphod42 posted:Can you run other Java JARs okay? Something sounds wrong with your JRE. I'm not sure; I don't think I have any other JARs just sitting around. Do you have an example?
|
# ? Apr 30, 2015 22:14 |
|
hooah posted:I'm not sure; I don't think I have any other JARs just sitting around. Do you have an example? http://sourceforge.net/projects/portecle/
|
# ? Apr 30, 2015 22:57 |
|
That works fine until I open a secondary dialog. The Open dialog box was completely empty and unresponsive, and the rest of the program was unresponsive after closing that window. I tried Options, which I was able to see the first time I tried it, but just tried again and got a blank window. Sounds like my JRE is hosed up, but I feel like I've reinstalled it in the past for this same problem. Is there a good set of instructions for "really, do a full clean uninstall" reinstallation anywhere?
|
# ? Apr 30, 2015 23:11 |
|
I didn't really see anything specific to Java when I went looking, but you might try something like Revo Uninstaller http://www.revouninstaller.com/revo_uninstaller_free_download.html to run after the standard uninstaller.
|
# ? Apr 30, 2015 23:13 |
|
Just reinstalled, similar behavior, but I see the content of secondary windows more often.
|
# ? Apr 30, 2015 23:19 |
|
Elias_Maluco posted:Simple stupid question: Im trying to use SimpleDateFormat to parse a timestamp like this: ""2015-03-11T00:00:00-0300"" (inside a jackson ObjectMapper, to parse a JSON response from a webservice). That is a ISO8601 date time, and SimpleDateFormat can not parse them according to the specification. Jackson has a ISO8601 parser, which is included in jackson-databind ISO8601Utils. You should probably be using databinding anyway: code:
|
# ? May 1, 2015 07:19 |
|
|
# ? May 18, 2024 21:27 |
M31 posted:Also, use Joda Time. Is Joda Time still necessary with Java 8? I've just been using the built in stuff now.
|
|
# ? May 1, 2015 07:46 |