|
thegasman2000 posted:I have been given a nice problem to solve and have no idea what I am going to do... I need to us the JustGiving Javascript API to enable functionality to a flash app. Is there a way for me to utilise JS in actionscript 3? Here is a link to the API if anyone fancies a look. https://api.justgiving.com/docs Perhaps you will have more luck asking about this in the JavaScript thread.
|
# ? Mar 26, 2012 21:39 |
|
|
# ? May 10, 2024 13:52 |
|
ComptimusPrime posted:Perhaps you will have more luck asking about this in the JavaScript thread. yep that makes sense!
|
# ? Mar 26, 2012 22:14 |
|
I apologize ahead of time if this has already been asked or is really obvious... Is there such thing as an "analyzer" for spring XML files? What I mean is some tool, framework, scripts or something that can compare a given set of XML files against a codebase to check for missed or duplicate entries that would probably result in the application crashing.
|
# ? Apr 3, 2012 23:35 |
|
Spring configuration isn't confined to XML files for some time now. If you can, then you could just instantiate your app by, say, trying to run some of Spring's own testing framework against it. It's quite useful to invest the time to understand and get your app or parts of your app up and running in Spring's own test harnesses, anyway.
|
# ? Apr 4, 2012 07:01 |
|
Unfortunately I don't have the luxury of getting rid of XML files in this case. What I am trying to do is find a way to ease the process of upgrading hundreds (or thousands) of XML files when a new version of an application drops. The current way it's done is: 1 - Install new version of application, use original version of XML config 2 - Launch app 3 - It crashes 4 - Read error logs and correct missing or broken parameter in XML 5 - Goto 2 Repeat that for a few days or so until finally everything works. I'm not familiar with the Spring framework, I just have the lovely task of upgrading our XML config when a new version drops. So any ideas or hints to avoid the brute force way above will be appreciated.
|
# ? Apr 4, 2012 12:55 |
|
My Rhythmic Crotch posted:Unfortunately I don't have the luxury of getting rid of XML files in this case. I don't think there exists a tool other than Spring itself which will simply verify if a given codebase will operate with another given set of Spring XML bean configs. In fact I think (but have not proven at all) that it's impossible to do this 100% without running the program. That said if you import a project of that kind into STS or IntelliJ, it will start flipping out if you have broken (not missing, unless they're constructor args) parameters. I know IntelliJ will do type checks and some other nice verification. Also you could have your beans implement InitializingBean's afterPropertiesSet() method and do sanity checks there, so at least you can catch missing / invalid properties to help improve the build/run/crash/debug cycle.
|
# ? Apr 4, 2012 14:50 |
|
I am pretty terrible at conveying what I am trying to accomplish; however, I will try my best: I have an object 'occupant.' Occupant may enter a room; however, he can also leave the room(Thus, deleting said occupant from the room). Before he leaves, he must notify that he is leaving. How could I go about doing this? in the leave method, I am just not sure how to return the object to a toString method, then set it to null. code:
I just get so lost with objects and inheritance.. I am never going to get my degree.
|
# ? Apr 6, 2012 00:43 |
|
Think about using a temporary in that leave method.
|
# ? Apr 6, 2012 00:45 |
|
My Rhythmic Crotch posted:What I am trying to do is find a way to ease the process of upgrading hundreds (or thousands) of XML files when a new version of an application drops. The current way it's done is: quote:I have an object 'occupant.' Occupant may enter a room; however, he can also leave the room(Thus, deleting said occupant from the room). Before he leaves, he must notify that he is leaving. How could I go about doing this? Some piece of code would have to be calling these enter() and leave() methods. Let's say it is God who indeed controls the way people and their rooms behave. The SmallRoom and Person classes look like the Model part of the MVC pattern, the part which describes the properties and relations between concepts. Whereas God would be the Controller part, the code which creates, calls and manipulates them. Usually, then, God would know where or whether he wants which people to go to which rooms. Rooms wouldn't, normally, have to notify him of it, because He knows best and He is the one setting them up as is. Now, the rooms might require a spying device which would indeed notify someone else whenever God manipulates them. That doesn't necessarily happen too often, and I'm not quite sure if you really need it. Usually the rest of the code would just take it up with God.
|
# ? Apr 6, 2012 07:16 |
|
You're not even addressing his problem. You're suggesting a beefy architectural style to solve his inability to reason about how to both set the person to null and also return the person in the leave method.
|
# ? Apr 6, 2012 07:25 |
|
The problem is that he is confused. Yes, the leave() could be implemented as code:
code:
It's confusing because you'd be mixing the controller code, which would be the parts which create and destroy and manage and manipulate objects, into the objects that represent the data. Unlike what you might have first heard in a lecture, it's perfectly cool for some objects to not contain actionable code at all, except for simple setters/getters. The SmallRoom class works pretty fine as a model class that represents a room. It's important to remember that all code that works on it doesn't need to be contained in the SmallRoom class, but would fit better in, say, God or ApartmentBuildingManager class. pigdog fucked around with this message at 08:11 on Apr 6, 2012 |
# ? Apr 6, 2012 08:00 |
|
ComptimusPrime posted:Think about using a temporary in that leave method. Wow, that was so easy! Thanks. pigdog posted:The problem is that he is confused. blergh, now the internet will think I didn't figure it out on my own; however, I did! I agree that having a get method would make things a bit easier. However, I am unfortunately forced to follow the guidelines given by my professor. (SmallRoom must use only methods included). Anyways, thanks for the help guys.
|
# ? Apr 6, 2012 08:26 |
|
pigdog posted:Why would there be hundreds (thousands) of XML files?
|
# ? Apr 6, 2012 09:22 |
|
pigdog posted:though better yet, have it simply set the occupant to null and return nothing.
|
# ? Apr 6, 2012 09:35 |
|
Aleksei Vasiliev posted:returning void is a sin (outside of static methods) This sounds like stupid dogma to me. You're going to have to backup this claim with some examples.
|
# ? Apr 6, 2012 17:55 |
|
"So shall my word be that goeth forth out of my mouth: it shall not return unto me void, but it shall accomplish that which I please, and it shall prosper in the thing whereto I sent it." -Isaiah 55:11 if you don't have anything better to return, return the object itself, good for chaining a constructor and some setters, for example
|
# ? Apr 6, 2012 18:02 |
|
MEAT TREAT posted:This sounds like stupid dogma to me. You're going to have to backup this claim with some examples. Maybe referring to the use of the domain model pattern? Which, granted, I don't fully understand, and am not sure if I have a proper understanding of. Here's my take: a parameterless function that is not static but which returns nothing presumably alters the internal state of an instance in a way that is totally opaque to someone inspecting it without source (or is completely useless). It also makes the object stateful, something which is best isolated rather than spread out, because it gets harder and harder to reason about classes and their behavior the more the lifecycle is distributed. In this case I think SmallRoom should define a leave(Person person) method rather than leave() because the interface itself is limiting it to a single occupant, and if a third party, say, a bouncer, were to have power over ejecting people, you might want to give them an interface that allows them to do so without having to specify the type of establishment they were bouncing for, or give them full access to all of the establishment's functions, such as serveBooze(Person person) or something. In any case, you might try: code:
code:
EDIT: See for yourself what the try-finally block does. You can use it to do things after something is returned, though I wouldn't recommend making it something you do all the time. code:
code:
Doctor w-rw-rw- fucked around with this message at 18:46 on Apr 6, 2012 |
# ? Apr 6, 2012 18:40 |
|
My Rhythmic Crotch posted:Because we have an incredibly large, elaborate product with scads of things to configure. Does it really make a difference? quote:Here's my take: a parameterless function that is not static but which returns nothing presumably alters the internal state of an instance in a way that is totally opaque to someone inspecting it without source (or is completely useless). It also makes the object stateful, something which is best isolated rather than spread out, because it gets harder and harder to reason about classes and their behavior the more the lifecycle is distributed. quote:Is grossly misleading.That doesn't copy the occupant, it copies the reference, and is probably best named something like "tempOccupant" instead of "copyOfOccupant" as it's temporarily there to hold a reference. quote:EDIT: See for yourself what the try-finally block does. You can use it to do things after something is returned, though I wouldn't recommend making it something you do all the time.
|
# ? Apr 6, 2012 20:13 |
|
Aleksei Vasiliev posted:if you don't have anything better to return, return the object itself, good for chaining a constructor and some setters, for example I used think chaining mutators was a good idea, but the resulting method call chains are really hard to indent properly and a big pain to step into in a debugger.
|
# ? Apr 7, 2012 00:14 |
|
I am in posted:I used think chaining mutators was a good idea, but the resulting method call chains are really hard to indent properly and a big pain to step into in a debugger. It's good for builders, though. And the way Guice does it for module configurations is actually pretty nifty.
|
# ? Apr 7, 2012 00:22 |
|
Doctor w-rw-rw- posted:It's good for builders, though. And the way Guice does it for module configurations is actually pretty nifty. I am going to spend way more time stepping into and out of that one line of code in a debugger than staring at those chain calls in quiet satisfaction despite the fact that it makes no difference to even the most brain-dead optimizing compiler.
|
# ? Apr 8, 2012 17:17 |
I'd like to have my program's assets stored inside the jar itself to avoid problems when someone has a strange working directory, and to make it easier to move the program around. Simultaneously, I'd like to be able to avoid having to repack the jar every time I change a file. This compels me to leave the assets outside the jar in my assets folder. Better put, if the loader finds a file in ./assets/, use that. Otherwise, load it from the <jar root>/assets/. The solution I've heard to be universal is, `URL url = Main.class.getResource(filename);`, where filename is 'assets/mainmenu.png'. Is there a way which does not require code changes between 'outside' file references and in-jar file references? Or do I have to do something like, 'if(new File(wat).exists()) {dance} else {load url from jar}'?
|
|
# ? Apr 8, 2012 17:38 |
|
Jo posted:Or do I have to do something like, 'if(new File(wat).exists()) {dance} else {load url from jar}'?
|
# ? Apr 8, 2012 17:45 |
|
Do you have a build script that generates the jar? You should. If so why do you care?
|
# ? Apr 8, 2012 17:53 |
Aleksei Vasiliev posted:This is more or less what I have done. Centralized file loading method that first attempts to load from the directory, then falls back to the JAR. Many thanks. That's what I've got set up. I guess it's not _that_ ugly a solution. Ranma posted:Do you have a build script that generates the jar? You should. If so why do you care? Some of the elements might be updated after the jar is created. I can create a self-contained Jar without issue, but if our graphics person is fiddling, I don't want her to have to open the jar, extract the image, and repack it. Even a three step process can be a pain in the butt if you're making lots of little tweaks. Jo fucked around with this message at 17:55 on Apr 8, 2012 |
|
# ? Apr 8, 2012 17:53 |
|
Paolomania posted:I am going to spend way more time stepping into and out of that one line of code in a debugger than staring at those chain calls in quiet satisfaction despite the fact that it makes no difference to even the most brain-dead optimizing compiler. You really feel the need to step through, one at a time, a bunch of method calls that each just set a single property?
|
# ? Apr 8, 2012 21:40 |
|
Jabor posted:You really feel the need to step through, one at a time, a bunch of method calls that each just set a single property? The real "fun" part starts when you have chained method calls producing the arguments for your chained method calls. A simple thing like code:
code:
Max Facetime fucked around with this message at 22:34 on Apr 8, 2012 |
# ? Apr 8, 2012 22:30 |
|
Aleksei Vasiliev posted:"So shall my word be that goeth forth out of my mouth: it shall not return unto me void, but it shall accomplish that which I please, and it shall prosper in the thing whereto I sent it." -Isaiah 55:11 I tried this with a set of builder objects which were covariant on the type of the object that they're building and that type had a deep inheritance hierarchy for historical reasons. I tried chaining for the hell of it and came up with something that started off like this and just got more insane: code:
|
# ? Apr 9, 2012 03:04 |
|
1337JiveTurkey posted:I tried this with a set of builder objects which were covariant on the type of the object that they're building and that type had a deep inheritance hierarchy for historical reasons. I tried chaining for the hell of it and came up with something that started off like this and just got more insane: Wow. That's horrible. I just meant that it makes sense for like, simple POJO builders, not for complex processes.
|
# ? Apr 9, 2012 04:35 |
|
Doctor w-rw-rw- posted:Wow. That's horrible. I just meant that it makes sense for like, simple POJO builders, not for complex processes. The thing is that there wasn't anything all that complex conceptually about it, I just needed the builder methods to return the actual type of the builder itself instead of the type of the interface. Some sort of shorthand for self types that doesn't require adding dummy type parameters to the hierarchy would remove the majority of the crap. A syntax change to the language to support chaining void methods would also get around the problem since there's no type of a return value, just the type of the chained instance which can't change.
|
# ? Apr 9, 2012 13:32 |
|
I am having listener trouble with a Swing JTable. I could post code, but the behavior is also seen here in step 1 (when you press the Launch button): http://docs.oracle.com/javase/tutorial/uiswing/components/table.html The problem is, when you click in a field and start typing a new value, the java.awt.event.MouseAdapter or import java.awt.event.MouseEvent do not register an event/keep the new value unless you press Enter, click somewhere else in the body (not the header) of the table, press the tab key, etc. So, if you type in a new value and then click on a header row, your value is wiped out. Also, if the parent JPanel is resized after entering a value, it wipes the data out. I tested this out in MS Excel by entering data and then clicking on a header row, and Excel registers the change. I tried a few different things, but I can't find an appropriate listener which registers this type of event (including TableColumnModelListener, TableModelListener, TableModelEvent).
|
# ? Apr 10, 2012 19:54 |
|
Try using a FocusListener if you want to detect when a particular table cell loses keyboard focus.
|
# ? Apr 10, 2012 22:39 |
code:
|
|
# ? Apr 12, 2012 20:00 |
|
fletcher posted:
It doubles down. Check out the source: code:
|
# ? Apr 12, 2012 20:02 |
|
fletcher posted:
http://docs.oracle.com/javase/6/docs/api/java/util/HashMap.html posted:When the number of entries in the hash table exceeds the product of the load factor and the current capacity, the hash table is rehashed (that is, internal data structures are rebuilt) so that the hash table has approximately twice the number of buckets. The array size double internally.
|
# ? Apr 12, 2012 20:04 |
Interesting, thanks guys. So if there is a ton of poo poo stored in the HashMap, and you exceed that initial capacity...well that is no good right?
|
|
# ? Apr 12, 2012 20:44 |
|
fletcher posted:Interesting, thanks guys. So if there is a ton of poo poo stored in the HashMap, and you exceed that initial capacity...well that is no good right? It's no big deal really. If you absolutely know how large it should be you can preemptively size it correctly, but that screams premature optimization.
|
# ? Apr 12, 2012 20:47 |
|
fletcher posted:Interesting, thanks guys. So if there is a ton of poo poo stored in the HashMap, and you exceed that initial capacity...well that is no good right? Unless it's all duplicates, the data being stored is going to generally be much more significant than the data structure itself in terms of size. Even if it's running on a 64-bit system, the incremental size increase from 128 to 256 buckets is 1kB. If you're really hard-pressed for space you could slightly increase the load factor but that will slow it down due to an increased risk of collisions.
|
# ? Apr 13, 2012 01:13 |
|
Came across this pretty nice article on Java anti-patterns for newbies and not-so-newbies alike.
|
# ? Apr 14, 2012 16:08 |
|
|
# ? May 10, 2024 13:52 |
|
I'm having trouble implementing some methods of a doubly linked list, if anyone could point me in the right direction I'd appreciate it.code:
code:
|
# ? Apr 16, 2012 02:14 |