|
Lysidas posted:The correct answer is IntelliJ Community Edition.
|
# ¿ Nov 21, 2011 09:58 |
|
|
# ¿ Apr 27, 2024 09:25 |
|
MonsterUnderYourBed posted:simple question with the JDBC hooking into MySQL.
|
# ¿ Dec 20, 2011 10:15 |
|
Pucklynn posted:I'm not the one you're speaking to, specifically, but I have pretty much the same issue. My main grump with IDEs is that when I start a new project, it asks me about a million different setup options and populates files and bits of code that I just don't understand yet. Ideally I'd like to start with as minimalist a program as possible, to be sure I understand how each piece goes together. I feel like using the IDE skips over a lot of important basics of how a Java program is set up. Java IDEs don't necessarily do any of that. Yet if you choose to create a project structure, Ant build files and whatnot, then for projects larger than Hello World it's probably a good idea anyway. A good IDE checks syntax, integrity, imports etc on the fly and lets you fix them semi-automatically, saving you a lot of javac->edit->javac cycles. Going for commandline first is kinda similar to learning to write prose by insisting on using a pencil and paper, as opposed to word processor on a computer.
|
# ¿ Jan 19, 2012 12:25 |
|
TRex EaterofCars posted:No one smart uses struts any more. Ugh. Could you explain what's wrong with Struts? (Just curious)
|
# ¿ Jan 21, 2012 01:29 |
|
See something like this: http://totheriver.com/learn/xml/xmltutorial.html . DOM is easier to use but takes up more memory and CPU (gets important if the XMLs are in megabytes of size), SAX is a bit of a bitch to use but is faster and doesn't blow up if the XML files are huge, StAX is sort of middle ground but haven't used it much yet. Don't use a regexp to parse XML, especially other peoples' XML, it will bite you in the rear end. That's what XML parsers are there for. There's a bunch of boilerplate code, but once you have that DOM object you can do cool stuff with it like search it with XPath, modify the elements, transform it with XSLT, et cetera. edit: If the XML in question corresponds to a concrete XML schema, then see this: http://xmlbeans.apache.org/ pigdog fucked around with this message at 10:13 on Jan 25, 2012 |
# ¿ Jan 25, 2012 09:27 |
|
Um, yeah. Java is a compiled language, you need to compile the .java file to a .class file before you can use it. The Java code that's contained in the JSP files is compiled automatically by Tomcat, but regular Java files need compiling before use.
|
# ¿ Jan 30, 2012 15:29 |
|
TRex EaterofCars posted:Ah yeah, I never run app servers in IDE's any more for that exact reason. I just do jpda and connect remotely cause it's just less headaches imo. also: JRebel.
|
# ¿ Mar 9, 2012 22:57 |
|
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 |
|
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 |
|
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 |
|
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 |
|
Came across this pretty nice article on Java anti-patterns for newbies and not-so-newbies alike.
|
# ¿ Apr 14, 2012 16:08 |
|
iscis posted: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. Don't use names like p_02, p_02Node, temp etc. Name things so looking at a name would tell the reader what they are. Any particular reason you wouldn't just use LinkedList? That is, if you really need a linked list in the first place, as opposed to normal ArrayList.
|
# ¿ Apr 16, 2012 10:43 |
|
Are you sure you even need to throw an exception, rather than implementing, say, Strategy pattern to choose a different algorithm to handle different states?
|
# ¿ Apr 19, 2012 17:37 |
|
Doctor w-rw-rw- posted:One thing that many people don't grok about Java is that programming it effectively is, essentially, computer-aided programming: IDEA is even smarter than Eclipse when it comes to autocompleting and programming aides http://blog.codeborne.com/2012/03/why-idea-is-better-than-eclipse.html
|
# ¿ May 9, 2012 08:12 |
|
Fair enough. IDEA does have some Android support even in the free edition, but I've no idea how it compares.
|
# ¿ May 9, 2012 09:06 |
|
With the caveat of not knowing the context, it doesn't look wrong at all. Are you sure you need to use foreach loops rather than say a HashSet, or something like someInstanceOfA.getSomeKindaB(someParameter).getSomeKindOfC(someOtherParameter)?
|
# ¿ May 9, 2012 11:29 |
|
It'd be weird for a method that's named getAge() return an animal object rather than some number representing age. If you'd replace getAge() with something like getCritter() then yes, you could do that. With the caveat that it's usually not nice form, as 1337JiveTurkey explained. The implementation might be something like public Animal getCritter() { Cat critter = new Cat(); return critter } where it may only use a concrete Cat object internally, but doesn't make the specific claim of returning a Cat; just some kind of Animal. I'd guess it's not a typo, just something they would expect you to be mindful of when implementing methods.. anyhow a modern IDE would pick up and alert you of the incompatible return type right away. pigdog fucked around with this message at 09:50 on May 10, 2012 |
# ¿ May 10, 2012 09:37 |
|
Aleksei Vasiliev posted:Is there any specific idiom for "iterate over a list, run a function per object, return the result of the complete iteration"? There are other alternatives, but we use LambdaJ a lot.
|
# ¿ Jul 17, 2012 17:04 |
|
Also check out Flyweight pattern if it's applicable in your context.
|
# ¿ Aug 22, 2012 18:13 |
|
It depends on the context, too. Sometimes option 1 is right.
|
# ¿ Oct 11, 2012 23:28 |
|
Get rid of the comments on obvious things, they only clutter the code without adding anything, or even create confusion where there wasn't any in case of int counter = 1; // initialize counter to zero stuff. The names in your code do a decent job of explaining what they're about, on their own. Don't reuse variables for different contexts or purposes in a method, particularly input parameters like start in your case. while (start != end){ sounds a bit ridiculous, doesn't it? Introduce another variable, let inputs be inputs and output(s) be output(s). It's usually quite a good idea to consider inputs immutable, if possible. intHexValue is never used. pigdog fucked around with this message at 11:47 on Nov 6, 2012 |
# ¿ Nov 6, 2012 11:43 |
|
carry on then posted:== only tests for reference equality. You'll want input.equals("File") for string equality. Better yet "File".equals(input), so that in case input is null (which won't happen here but would in most code), the comparison would simply return false rather than throw a NullPointerException.
|
# ¿ Nov 19, 2012 08:06 |
|
IDEs can optionally just visually collapse and fold simple accessor methods for you, too, so at least they clutter a bit less.
|
# ¿ Jan 16, 2013 23:29 |
|
It's hard to understand the context, though it appears you're doing something wrong. Can you post the code so far and/or the text of the assignment? Are you trying to print each object's cost and volume, or the sum of the ones contained in the array?
|
# ¿ Jan 28, 2013 17:58 |
|
JUnit seems more prevalent, but from my cursory experience with TestNG, there isn't a huge lot of difference. Mocking frameworks however can be pretty remarkably different to work with.
|
# ¿ Feb 8, 2013 21:00 |
|
You might want to wrap the DAO exceptions into custom, application-specific exceptions such as HorrificUnrecoverableException or ShobonMerelyNotSuccessfulException (not literally), so the classes down the line needn't worry about, say, any SQL-specific stuff showing up. For example if your app uses the normal DAO pattern of ApplicationClass -> SomeService -> SomeDAO, then usually the sensible exceptions the Service can throw are defined at the Service level, and DAO exceptions are wrapped into these. From there on it's not a bad idea at all to prefer passing exceptions down the line and handling them all, if possible, in one or few locations, where it makes best sense for your application. Certainly in your case, you'd want to pass the exceptions and the try/catch loop be near the part which decides which HTTP codes to pass. Whenever catching and rethrowing exceptions locally, never remove the original exception, but pass it along in the new exception, merely adding information to it instead of replacing or removing. pigdog fucked around with this message at 09:44 on Feb 10, 2013 |
# ¿ Feb 10, 2013 09:41 |
|
Until then you can use LambdaJcode:
|
# ¿ Feb 16, 2013 08:21 |
|
Hard NOP Life posted:Easiest way, copy the mysql.jar to the default java installation folder, on my CentOS server it's at /usr/java/default/jre/lib/ext The simplest if not terribly convenient way is to add the driver .jar into classpath like java -cp mysql.jar MyApp or append it to CLASSPATH environment variable export CLASSPATH=$CLASSPATH:./mysql.jar java MyApp Any serious app or server would take care of that stuff itself in some way or another, i.e. a startup script.
|
# ¿ Mar 6, 2013 22:09 |
|
HatfulOfHollow posted:I've been tasked with a project to produce a report on methods nearing the 64k size limit. Our application uses a lot of jsps and generated code and we've seen issues in the past where a small change in one place leads to problems in other pages that import the new code. Does anyone have any idea how I could go about determining the size of a method compiled in a class file? You are doing it wrong.
|
# ¿ Aug 20, 2013 22:20 |
|
Sorry for the unhelpful post, I saw "64k methods" and kinda knee-jerked. If we're talking JSP's that are compiled into such monster methods, then that's another thing. Try to have less crap stuff in your .jsp files, move the business logic to proper java classes, Javascript files to separate .js and such. While it's down to any particular JSP framework, perhaps try replacing static includes such as <%@ include file="blah.jsp" %> with dynamic like <jsp:include page="blah.jsp"/>. Anyhow, it depends a lot on your context. Could you decompile some of the .class files the JSP gets compiled into and see what takes up all the space?
|
# ¿ Aug 20, 2013 22:56 |
|
Pollyanna posted:The superclass Items has one parameter: [amount]. The Weapons subclass of Items, however, has two parameters: [amount, power]. It inherits [amount] from Items (all Items have an amount), and innately has [power] (all Weapons have damage dealing power, but not all Items do). A rule of thumb is that class inheritance is for sharing common implementations of functionality, but as far as behavior, you should take a good look at interfaces once your inheritance topology starts feeling limited and strange. A subclass can only extend one parent class, but can implement several interfaces and thus "be" many things at once. For example a Cloak and a Blacksmith can both implement Burnable and needn't have anything else in common rather than having implemented burn() or whatever the Burnable interface requires, at some point of their respective class hierarchy. Definitely read up and mess around with interfaces, they're more useful than they appear. pigdog fucked around with this message at 15:34 on Sep 19, 2013 |
# ¿ Sep 19, 2013 15:32 |
|
Yeah, you already have int[] rolls so you don't need roll1 .. roll4 in the first place.
|
# ¿ Oct 3, 2013 20:25 |
|
KildarX posted:
vv No it is. Instead of comparing, you're assigning a false value to valid. Mixing up == and = is a classic mistake, most IDEs would warn you about it there. pigdog fucked around with this message at 23:04 on Oct 3, 2013 |
# ¿ Oct 3, 2013 22:53 |
|
Regular expressions are precisely the right tool here. Just not one regular expression that attempts to match every rule.
|
# ¿ Oct 4, 2013 11:38 |
|
rhag posted:Regular expressions are just as good here as taking out the tank to kill a fly. It will work, but it will require too much effort and will waste too much energy in the process versus what's required. code:
pigdog fucked around with this message at 21:55 on Oct 4, 2013 |
# ¿ Oct 4, 2013 18:45 |
|
Max Facetime posted:Those regexps don't work either. Instead of pwd.matches("[a-z]") you'd need to do Pattern.compile("[a-z]").matcher(pwd).find() , then. In any case, there's no reason to reinvent the wheel for matching patterns in strings. ps: \p{Lu} and [\p{L}&&[^\p{Lu}]] instead of [A-Z] and [a-z] match these fancy Unicode strings too, if that's the requirement. pigdog fucked around with this message at 22:03 on Oct 4, 2013 |
# ¿ Oct 4, 2013 21:51 |
|
You should never be writing Java in vim in ssh session. And what do you mean it needs to run on a specific server? You should e.g. compartmentalize the server-specific stuff in its own class or abstract class, override it for development.
|
# ¿ Oct 8, 2013 18:30 |
|
Are you sure you actually need these terabytes of data, or is it just the dataset you've used to test it against? I mean, using terabytes of data is as such a pretty intensive deal, even simply reading a terabyte from a hard disk takes hours. Are you sure your code cannot be expressed with a smaller dataset? You should make the effort to do so. Perhaps if your code merely uses some of that data for some of its input rather than it being the integral part of it, then you should look at mock versions of the component that reads them, and needn't use the database altogether. I mean it's a really good idea to be able to run your code on your own workstation, not have it tied to peculiarities of that data on that system. quote:Why are you guys still using Eclipse?? IntelliJ IDEA shits all over it.
|
# ¿ Oct 8, 2013 19:16 |
|
|
# ¿ Apr 27, 2024 09:25 |
|
Sagacity posted:I'm about to start work on my first non-trivial Java project in a long time. Coming from a C# background most concepts are thankfully similar, but I still need to make a few choices. quote:* Maven or Gradle? Maven is more verbose but it integrates pretty seamlessly with IntelliJ. Do you really spend so much time editing these files that Gradle would be a plus? quote:* Does anyone still use Spring in a non-ironic way for DI (vs Guice), Data (vs Hibernate, Morphia, whatever) and Security (vs Shiro or roll-your-own)?
|
# ¿ Oct 14, 2013 10:01 |