|
Well, it seems that you've implemented a For-Switch, which is a common enough mistake that it's got its own wikipedia page. It's a good way to exercise both of those control structures, but you generally want to choose whether you're doing something sequentially or in a loop. ("Both" is the wrong answer.) In Comptuer Science we count starting at 0. In Java, we name classes starting with a capitol letter, in CamelCase, using full words. I can't see where you're using keybd to gather input at any point in time... unless it's in the Cat class? It's good practice to have "setter methods" accept an argument, rather than gather their own data. This way, you can load values from a database, or a text file, or by randomly generating them, and still use the same Cat class and setters. I implemented a simple solution before I re-read your line that says you don't use Arrays yet. (That is crazy. Using arrays makes this simpler.) Arrays (or their big-brothers, Collections) are the correct way to manage storage of many of the same type of thing. Java code:
Java code:
Java code:
Gravity Pike fucked around with this message at 08:16 on Dec 10, 2013 |
# ? Dec 10, 2013 08:13 |
|
|
# ? May 9, 2024 18:31 |
|
Bullio posted:I'm very new to coding, I hope I'm not wasting your time with such a low level question, but goons never let me down before. Don't worry, we like the easy questions. They're easy to answer, and make us feel superior. Bullio posted:For class, I'm doing a simple little program where a user inputs information for 3 cats and the program outputs which cats listed are over 3 years and declawed. I finished it already and turned it in, but I'm looking for advice on a more elegant way to do it as opposed to the clutter I made grinding it out when I turned it in. We don't hit arrays until next semester and I couldn't figure out how to set up just one block of questions and apply the data to the correct object instance. So I made a set of System.out.println for each cat, which is ugly as hell. Anyway, using a for loop with a switch statement is the way to go, I think, but I keep getting problems in the implementation. Sorry if this is too low level. Sounds like you could organize some of this logic as a seperate method/function to call, which is something newbie programmers are usually very hesitant to do, but becoming comfortable with it is the real way to Getting It™ as a programmer. Rather than knock everything out in one method, build yourself some tools first, and then you can use those tools in a much simpler method. That'll print out properly as you're expecting, however it'll print all of the "Enter:" blocks at once, and then go to your section which I guess would read the inputs? You may want to prompt separately for each one as you take the inputs. Hah, I didn't know it had a wiki page, that's funny. Gravity Pike posted:In Comptuer Science we count starting at 0. In Java, we name classes starting with a capitol letter, in CamelCase, using full words. Thing is he didn't make an off-by-1 error, so its not a big deal. So he's wasting a bit, in modern performance when you're learning that's trivial. I guess its good to know that you can count from zero, but really, that's minor. Making the off-by-one error is the real mistake, and he avoided that. It also prevents him from having to do i+1 on each loop iteration... so that's actually more efficient. You should def get comfortable with camel case though, its a really good habit to get into. variables and methods begin lower, then go capital. Classes begin capital. That way you can tell at a glance if something is a class or a feature of a class, and the capitols after the first make it much easier to read (since you aren't allowed spaces) thisisreallyhardtoread ThisIsPrettyEasyToRead ClassName methodName variableName Zaphod42 fucked around with this message at 23:52 on Dec 10, 2013 |
# ? Dec 10, 2013 23:45 |
|
I think the big problem is finding a format that would be "acceptable" for his class. If he's not allowed to use arrays, he's probably not allowed to make methods aside from main, not allowed to use OO, etc. There's only so much you can do when you're limited in this way.
|
# ? Dec 11, 2013 01:14 |
|
Wow. I appreciate the great responses. To tell you the truth, I was nervous about even posting with all the pros around here. I'm really grateful. Anyway, it was late when I was trying to write that up, so I didn't realize that I left no room for user inputs. It was all cobbled together pretty badly. Volmaria is right, it's finding something using only the tools we've learned so far that's making it difficult. Seeing all these awesome efficient ways to get a job done makes me jealous of people with a more comprehensive knowledge. Zaphod, in the for loop, I put i=1 instead of i=0 because I wanted it to name the objects myCat1, myCat2, etc. I'm thinking I'm wrong in how it'd do the naming conventions. I got Joyce Farrell's Programming Logic and Design Comprehensive on the recommendation from my instructor when I asked him what additional books I could read to help get acquainted with programming in general. I learned about camel case in that, but I'm still trying to develop the habit. Gravity Pike, fields and arrays are still beyond me. To tell the truth, I only knew about arrays because I skipped ahead in the book and tried to shoehorn one in for a password verification program. It didn't go well because I didn't select the right type or something. We won't get into those until CS219 though. To give you a better idea of what I'm going for, I'll post the assignment I did turn in that's slapdash, but meets the program requirements. Thing is, I don't want to be bad at this. I'd rather gain the skills and knowledge necessary to write elegant code that's easy to read and modify. I got Joyce Farrell's Programming Logic and Design Comprehensive on the recommendation from my instructor when I asked him what additional books I could read to help get acquainted with programming in general. Here's what I turned in. You experienced types might want to brace yourself, it's ugly and inefficient. I will say that I love this whole object oriented programming. Having the method calls in another file makes it way easier to troubleshoot. [b]Cat class code:
code:
It meets the requirements, so I should get a proper grade for it, but I was hoping I could learn from you guys what I could do better with the tools at my disposal. Also, what books would you recommend? I like Java, but I'm really only relying on it as a stepping stone to learn how to program before focusing on learning another language entirely. The posts I've read here have been way informative and I look forward to delving deeper into the programming world.
|
# ? Dec 11, 2013 01:51 |
|
Code reuse is the biggest thing in programming, usually. Programmers are lazy, and they especially hate repeating themselves. There's a few things you can do here, if you make the Cat class yourself: * take the code that reads in the input from the user to get the parameters fire the cat, and put it into it's own method. Have that method return a new Cat instance, which has the appropriate fields * have that method live inside of the cat class, and return void, setting the instance values instead. * create a constructor for Cat that is passed the input stream, and reads in the values that it needs to create itself The idea is that you want to make a thing that will handle giving you a cat, so that you can call it an arbitrary number of times instead of copy/pasting your code and changing one value on each line. Also, I believe that the Boolean class has a method to parse a string and return the appropriate boolean value.
|
# ? Dec 11, 2013 02:11 |
|
Volmarias posted:Code reuse is the biggest thing in programming, usually. Programmers are lazy, and they especially hate repeating themselves. There's a few things you can do here, if you make the Cat class yourself: Awesome. I did do the Cat class myself. So if I throw the user input code into the class file, I can write a method and word it something like public void userInput(); right? Where I'm lost is how do I accept user input? Would it go in the class file the way I have it assigning the data to the reference variable: myCat.setName(keybd.nextLine()); ? By having the method return void, it'd be a mutator, right? I just learned about constructors yesterday. Am I right in assuming it'd be something like (rough approximation): code:
I'm going to work on your first suggestion and see if I can figure it out. I get what you're saying, but I don't know exactly how to get it done. Place the user input lines in the class file in a method and at the end of the method, each time it's run, it should return a new cat instance. Would it be named properly? Also, how do I get it to say Cat 1, Cat 2, Cat 3 each succeeding time it runs the set of questions? Like I said, it's already turned in and meets requirements, this is more for my personal education than anything. Thanks for your help and feel free to let me know when I'm starting to bug you with my stupid questions. In the meantime, I think I need to reread the last 2 chapters in an effort to get it to sink in better. Edit, nix the boolean question. You said there was a way to parse a string and pass the appropriate value to the boolean. Would that be a wrapper class?
|
# ? Dec 11, 2013 02:59 |
|
Bullio posted:Awesome. I did do the Cat class myself. Sort of. Something like: code:
quote:By having the method return void, it'd be a mutator, right? In the sense that it has a side effect, yes. The return value isn't really important here. quote:I just learned about constructors yesterday. Am I right in assuming it'd be something like (rough approximation): Not quote. The syntax of constructors is that the name is the same as the class. I was suggesting for your edification something like: code:
quote:I'm going to work on your first suggestion and see if I can figure it out. I get what you're saying, but I don't know exactly how to get it done. Place the user input lines in the class file in a method and at the end of the method, each time it's run, it should return a new cat instance. Would it be named properly? Also, how do I get it to say Cat 1, Cat 2, Cat 3 each succeeding time it runs the set of questions? quote:Edit, nix the boolean question. You said there was a way to parse a string and pass the appropriate value to the boolean. Would that be a wrapper class? I meant Boolean.parseBoolean So, if I were going to write this myself, it would probably be something more along the lines of: code:
|
# ? Dec 11, 2013 05:22 |
|
Bullio posted:If so, how do I get the boolean value assigned to it. I think I remember saying a boolean couldn't be set with a constructor. I could be wrong though. boolean can't be constructed because it isn't an object, correct! But Boolean is an object and can be! You can then save that Boolean as a Boolean or as a boolean, because java has autoboxing (syntactic shorthand, the compiler will convert to wrapper classes and back automatically, since they're obvious) Java code:
Bullio posted:Edit, nix the boolean question. You said there was a way to parse a string and pass the appropriate value to the boolean. Would that be a wrapper class? The big B Boolean is a class which is a wrapper to little b basic data type boolean, yeah. And the parse method is a static method (you don't need a big B boolean instance to call it) that takes a String and returns a Boolean. So there's a class in java like Java code:
Zaphod42 fucked around with this message at 05:54 on Dec 11, 2013 |
# ? Dec 11, 2013 05:43 |
|
Bullio posted:It meets the requirements, so I should get a proper grade for it, but I was hoping I could learn from you guys what I could do better with the tools at my disposal. Also, what books would you recommend? I like Java, but I'm really only relying on it as a stepping stone to learn how to program before focusing on learning another language entirely. The posts I've read here have been way informative and I look forward to delving deeper into the programming world. Effective Java is a great Java book, as is Java Concurrency in Practice. The thing is, I'm not sure whether they'd be of a whole lot of use to you at this point; they expect kind of a lot of background knowledge that you just don't have yet, and they give you guidelines to solve problems that are beyond your skillset. Honestly, I'd probably go with the official Java Tutorials, paying a whole lot of attentions to "Getting Started" and "Language Basics." Having a very strong grasp of "Collections" is essential; these are your bread-and-butter tools for everyday programming. Date and Time functions are... well... there. Java's built-in Date object really isn't that great, tbh. (All the cool kids use the JodaTime library.) And don't discount Java completely; it's not the newest, hottest language, but it is mature, which means that a lot of us make a living writing Java code. There are libraries to do basically anything in Java, and tools that work well surrounding the platform. A good programmer is language-agnostic; they'll be able to write in basically any language, given a while to study up on it, and have two or three at their fingertips to perform a wide variety of tasks. Having been on the interview-loop for a while, at my company we're looking for developers who are solid in any language, have a decent grasp of a scripting language to do simple tasks, and are familiar enough with bash to do very simple tasks without even writing a program in the first place.
|
# ? Dec 11, 2013 06:41 |
|
Volmarias posted:
I haven't come across the setFromInput or Output/InputStream before, but I'm going to save these posts in Evernote so I can refer to them when I do encounter those method calls. I am grateful for the examples and I know you're making an effort to dumb it down a bit for me, so thank you. The only thing we did with constructors in class was along the lines with what I posted, so learning you can call member methods from within was enlightening. It seems the more I learn, the more I don't know. I just took my final, but there's one more program and up to 3 more extra credit we can work on, so I think I figured out what I'm doing all day this Saturday. Been a bit too busy during the week to get in front of a computer for any proper length of time. Zaphod42 posted:boolean can't be constructed because it isn't an object, correct! That last line made me laugh hard. You wear the Zaphod name well. As far as finding out Boolean can be an object. . .mind blown. I wasn't aware of that at all. In your explanation, you said Java will convert between wrapper classes and primitive types automatically, so does that mean it doesn't matter whether I capitalize boolean in my declarations? In all honesty, I'm think I'm starting to reach the limits of my understanding. This semester covered a few basics, looping structures (which have a complexity that I don't think I've scratched the surface of), operands, increment and decrement operands, a few basic classes (i.e. math), skimmed across wrapper classes, and starting fiddling around with oop. I think at this point, I need to start spending some hours in tutorials to reinforce and expand on those techniques because it's still kind of easy to get lost. I really do appreciate your help though, for everything I don't understand I'm learning two new things. Gravity Pike posted:Honestly, I'd probably go with the official Java Tutorials, paying a whole lot of attentions to "Getting Started" and "Language Basics." Having a very strong grasp of "Collections" is essential; these are your bread-and-butter tools for everyday programming. Date and Time functions are... well... there. Java's built-in Date object really isn't that great, tbh. (All the cool kids use the JodaTime library.) Thank you for this. This is what I'm going to do with my break over the holidays. I'm hoping they'll help me get to a level of understanding where I can just breeze through the assignments next semester and, even if they don't, they'll keep me in practice and keep the knowledge fresh in my head so I'll be ready to continue expanding on it when the next semester does start. quote:And don't discount Java completely; it's not the newest, hottest language, but it is mature, which means that a lot of us make a living writing Java code. There are libraries to do basically anything in Java, and tools that work well surrounding the platform. I didn't mean to make it sound like I was. I've always been tangentially interested in programming without really knowing anything about it, so I'd lurk here and there and read posts and marvel at all the amazing things people were doig that I didn't understand. One reoccurring theme throughout most of the conversations I'd seen was that Java was mostly disliked. Maybe it was the wrong impression, regardless, I'm still be excited to be learning any language. I thought programming would be beyond me forever. quote:A good programmer is language-agnostic; they'll be able to write in basically any language, given a while to study up on it, and have two or three at their fingertips to perform a wide variety of tasks. Having been on the interview-loop for a while, at my company we're looking for developers who are solid in any language, have a decent grasp of a scripting language to do simple tasks, and are familiar enough with bash to do very simple tasks without even writing a program in the first place. This. This is honestly where I want to get. The whole concept of programming thrills me and maybe even gives me a bit of a god complex. After all, you're creating something from nothing. At least that's how I see it. Point is, I wish I could live long enough to learn everything. Also, what is bash? The closest thing I can think of is this site called bash.org. Is it a programming style?
|
# ? Dec 12, 2013 06:49 |
|
Bash is the default linux terminal. Knowing how to pipe together simple commands like grep, sed, sort, uniq, wc in order to filter and reduce data is a very important skill to practice. Not a day goes by where I don't do something like log onto a load-balancer and, grep ' 500 ' load_balancer.log.2013-12-01* | grep -oP 'userid/\w+' | sort | uniq | wc -l to figure out how many unique users were affected by server errors in a given day. (Roughly, "Search through all files starting with load_balancer.log.2013-12-01 for lines containing ' 500 ', then take the parts of those lines that are the string 'userid/' followed by any number of letters and numbers, and then sort those alphabetically, and then remove duplicates, and then count the number of lines.") You could have written a Java program to do that, but you'd waste a whole lot of time worrying about things like reading from files, and looking up how to do directory manipulation, and deciding on data structures, and saving your code somewhere, and compiling, when you could have taken thirty seconds on the command line to do the same thing using tools that someone else already wrote. Command line skills are a bit harder to pick up than programming, because there's often not a class that specifically teaches them. On the other hand, each command tends to be very simple, and you only need to know a few commands in order to accomplish 90% of what you'd ever want to do from the command line.
|
# ? Dec 12, 2013 07:54 |
|
Gravity Pike posted:Bash is the default linux terminal. Knowing how to pipe together simple commands like grep, sed, sort, uniq, wc in order to filter and reduce data is a very important skill to practice. Not a day goes by where I don't do something like log onto a load-balancer and, grep ' 500 ' load_balancer.log.2013-12-01* | grep -oP 'userid/\w+' | sort | uniq | wc -l to figure out how many unique users were affected by server errors in a given day. (Roughly, "Search through all files starting with load_balancer.log.2013-12-01 for lines containing ' 500 ', then take the parts of those lines that are the string 'userid/' followed by any number of letters and numbers, and then sort those alphabetically, and then remove duplicates, and then count the number of lines.") You could have written a Java program to do that, but you'd waste a whole lot of time worrying about things like reading from files, and looking up how to do directory manipulation, and deciding on data structures, and saving your code somewhere, and compiling, when you could have taken thirty seconds on the command line to do the same thing using tools that someone else already wrote. That's pretty awesome. Thank you. I guess I should download a version of linux and start fooling around with it as well then.
|
# ? Dec 12, 2013 08:02 |
|
Bullio posted:That's pretty awesome. Thank you. I guess I should download a version of linux and start fooling around with it as well then. It can't hurt. Linux is fun because you can get the source code to most everything and build it yourself, so you can poke around and see how things are done, or make changes. Windows, everything is proprietary, you just flat out can't see the code ever to almost anything. If you have a mac, OSX is totally POSIX so you can just learn on that instead of bothering with Linux. Its terminal is pretty good. Alternatively you can install a linux shell in windows if you'd rather not deal with setting up partitions and a new OS. But it doesn't hurt to try a new OS, and some flavors of Linux like Ubuntu are really easy to set up compared to the old days.
|
# ? Dec 12, 2013 08:08 |
|
Bullio posted:I haven't come across the setFromInput or Output/InputStream before, but I'm going to save these posts in Evernote so I can refer to them when I do encounter those method calls. I am grateful for the examples and I know you're making an effort to dumb it down a bit for me, so thank you. The only thing we did with constructors in class was along the lines with what I posted, so learning you can call member methods from within was enlightening. It seems the more I learn, the more I don't know. I just took my final, but there's one more program and up to 3 more extra credit we can work on, so I think I figured out what I'm doing all day this Saturday. Been a bit too busy during the week to get in front of a computer for any proper length of time. setFromInput is just a name that I made up. InputStream and OutputStream are very important, as they're the base classes relevant for almost any lower level I/O that you do. System.in is actually an InputStream, and System.out is actually an OutputStream. This is important to understand, because by default they point to the console input/output, but they can be reassigned to other things. For example, you could write a test that provides your own input and verifies what the output is. quote:That last line made me laugh hard. You wear the Zaphod name well. As far as finding out Boolean can be an object. . .mind blown. I wasn't aware of that at all. In your explanation, you said Java will convert between wrapper classes and primitive types automatically, so does that mean it doesn't matter whether I capitalize boolean in my declarations? In all honesty, I'm think I'm starting to reach the limits of my understanding. This semester covered a few basics, looping structures (which have a complexity that I don't think I've scratched the surface of), operands, increment and decrement operands, a few basic classes (i.e. math), skimmed across wrapper classes, and starting fiddling around with oop. I think at this point, I need to start spending some hours in tutorials to reinforce and expand on those techniques because it's still kind of easy to get lost. I really do appreciate your help though, for everything I don't understand I'm learning two new things. The Boolean object is not actually the same thing as the boolean primitive. Translating between the two automatically is called Autoboxing, but it's important to realize that object versions of primitives exist for when an Object has to be provided for something, which also means that said object reference can be null. You should understand that there is a difference between primitives and objects, before you gleefully start mixing the two. I want to reiterate the suggestion of reading the official java tutorials. It's OK that not everything makes sense at this point, because you're still new to programming, but it will help you move a little faster if you're ready to learn more, and honestly it's probably going to be organized better than whatever book you're learning from. Volmarias fucked around with this message at 12:50 on Dec 12, 2013 |
# ? Dec 12, 2013 12:47 |
|
Be very careful about autoboxing and comparing equality.Java code:
true false false The first example may lead you to believe that == works everywhere on Integers, but you would be wrong, as you can see by the second and third example. This is due to the wording of Integer.valueOf(int) method: Returns an Integer instance representing the specified int value. If a new Integer instance is not required, this method should generally be used in preference to the constructor Integer.Integer(int), as this method is likely to yield significantly better space and time performance by caching frequently requested values. This method will always cache values in the range -128 to 127, inclusive, and may cache other values outside of this range. Using .equals() will work on all of these. Null values can cause either option to throw an exception. We've run into problems with this more than once, because we mix Integer (object) values coming from our ORM with int (primitive), and == sometimes works and sometimes doesn't, causing unexpected behavior.
|
# ? Dec 12, 2013 22:07 |
|
Java code:
|
# ? Dec 12, 2013 22:39 |
|
Well if either side of an == is a primitive, then the Object is auto-unboxed and == works as expected for the primitive types. Just be careful about the Object being null. But if the object is null, and you put it on the left side of the .equals(), it would throw the same NPE.
|
# ? Dec 12, 2013 22:52 |
|
So. Readers/writers. I'm trying to set my reader encoding to ANSI but it doesn't seem to want to actually read escape characters. pre:To request a character: [1m request <player_name> for <email_address>[0m To connect with an existing player: [1m connect <player> <password>[0m If you forgot your password: [1m password <player> for <email_address>[0m Java code:
Java code:
Not entirely sure what I should be doing. Windows telnet client receives the ANSI escapes and whatnot just fine, so I was thinking I could connect using Apache's telnet library, but I don't really want to depend on any external libraries for such a small program. I could theoretically parse ANSI output on my own, but this creates a problem where players connected to this game can say things with ANSI codes in them where the escape character is itself automatically escaped. By reading ANSI through the stream, this would display as intended (ex. Bob says, "~1b[1m") but my own parsing would have him say nothing and bold every following line. Smarmy Coworker fucked around with this message at 00:06 on Dec 13, 2013 |
# ? Dec 13, 2013 00:01 |
|
What are some good resources if I'm wanting to teach myself Java? I have seen several tutorials on how a to accomplish certain tasks but I'm more interested in a textbook or something else that's structured with lessons, exercises, reviews, etc. I've read a lot of good things about "Thinking In Java" and am considering ordering it.
crunk dork fucked around with this message at 03:01 on Dec 13, 2013 |
# ? Dec 13, 2013 02:59 |
|
Has anyone run into the "Project folder exists and is not empty" issue with NetBeans? I've deleted the userdir and the project directories, but this problem still crops up. What do I need to do to fix it?
|
# ? Dec 13, 2013 05:19 |
|
Drunk Orc posted:What are some good resources if I'm wanting to teach myself Java? I have seen several tutorials on how a to accomplish certain tasks but I'm more interested in a textbook or something else that's structured with lessons, exercises, reviews, etc. I've read a lot of good things about "Thinking In Java" and am considering ordering it. If you have no experience Greenfoot is excellent.
|
# ? Dec 13, 2013 05:37 |
|
front wing flexing posted:If you have no experience Greenfoot is excellent. The shameful part is I actually have an AAS in Information Systems but I feel like all I was taught in school was basic syntax, I graduated a year ago and didn't really pursue it so now that I've forgotten the little bit I did learn I decided it's time to start taking it more seriously. Greenfoot doesn't look like a bad place to start though, thanks!
|
# ? Dec 13, 2013 19:28 |
|
I did some searching around but I couldn't come up with a consensus to this question: is it considered bad form to have multiple packages in a single project? I am working on a new project and many of the classes have some reuse value, and I'm relatively sure I will use them in the future. So, while I am developing those classes, I want to define them in a separate package within my project. Then, when I need to reuse the classes in that package it will be trivial to move them into their own project.
|
# ? Dec 16, 2013 05:54 |
|
Woodsy Owl posted:I did some searching around but I couldn't come up with a consensus to this question: is it considered bad form to have multiple packages in a single project? I am working on a new project and many of the classes have some reuse value, and I'm relatively sure I will use them in the future. So, while I am developing those classes, I want to define them in a separate package within my project. Then, when I need to reuse the classes in that package it will be trivial to move them into their own project. It is good, and even encouraged, to have multiple packages. You might make them sub packages, of course. com.woodsyowl.dickbutt com.woodsyowl.dickbutt.parser com.woodsyowl.dickbutt.horsecocks However, you should also be happy to put common functionality that other projects would use into their own package, so that they don't need the dickbutt application for that functionality. These are two distinct considerations. Volmarias fucked around with this message at 06:05 on Dec 16, 2013 |
# ? Dec 16, 2013 06:02 |
|
Woodsy Owl posted:I did some searching around but I couldn't come up with a consensus to this question: is it considered bad form to have multiple packages in a single project? I am working on a new project and many of the classes have some reuse value, and I'm relatively sure I will use them in the future. So, while I am developing those classes, I want to define them in a separate package within my project. Then, when I need to reuse the classes in that package it will be trivial to move them into their own project. That said, /smartly/ organized is different than /strictly/ organized. It's just that refactoring tools make rearranging or whittling down lots of packages easy.
|
# ? Dec 16, 2013 11:54 |
|
Doctor w-rw-rw- posted:Smartly organized packages are a huge plus. Personally, I go ask far as I like in building package hierarchies, because it's so easy to go back and rearrange them to something sensible. Too many Java programmers IMO fail to use packages as meaningful clues to other developers. With regards to source control, would you want a separate repository for each sub-package? My projects are starting to intersect in that they end up using some classes that I've written prior. Is there a decent write-up detailing smart and effective package organization? edit: Derp, http://docs.oracle.com/javase/tutorial/java/package/index.html Woodsy Owl fucked around with this message at 16:04 on Dec 16, 2013 |
# ? Dec 16, 2013 14:41 |
|
Woodsy Owl posted:With regards to source control, would you want a separate repository for each sub-package? My projects are starting to intersect in that they end up using some classes that I've written prior. Is there a decent write-up detailing smart and effective package organization? Nah that's way too many repositories and too much work. You probably just want one single repo, with seperate folders for each project, and code organized under project src folders based on package. If a package is used in a seperate project, you'll want to copy the source code to the new project folder so they're separate, or better yet, create a third project that has the common code and compiles to a library, and then copy that library to the other two projects after compilation and import it. Maybe you have some branches for different release versions or something, but not per package, nahhh. Projects should be able to pull from tons of different resources without any conflicts.
|
# ? Dec 16, 2013 18:30 |
|
I'm working on a large application that's locked into a terrible database that cannot perform. All of our queries are hitting an 'Index' table, which is a simple table with three columns: customerId, indexName, indexValue. It might contain things like: 1, FirstName, John - and a search by name query would be something like Select customerId from Index where indexName=FirstName and indexValue=John. The customerId is later joined to another set of tables. Changing the database is not an option - but we are able to move the indexing off of the database onto something else. I'm looking for the best suggestion. Right now we are considering Lucene, because some of the indexed fields require fuzzy searching. However there is very little document searches, we really only have name/value pairs that link back to a customer. Is there anything more practical than Lucene for this kind of indexing? We essentially just need a quicker way to maintain an index since our database can't do it.
|
# ? Dec 18, 2013 16:53 |
|
I'm trying to follow Stanford's Intro to Programming course to learn Java. However, there seems to be a problem with their distribution of Eclipse for Windows (here), or perhaps it just doesn't work well with Windows 8. When I try to run that, I get this hideous mess of errors that I don't understand. Could someone help me get this working? I also tried using standard Eclipse, but couldn't get a Karel the Robot project working with it.
|
# ? Dec 18, 2013 17:55 |
|
FateFree posted:I'm working on a large application that's locked into a terrible database that cannot perform. All of our queries are hitting an 'Index' table, which is a simple table with three columns: customerId, indexName, indexValue. It might contain things like: 1, FirstName, John - and a search by name query would be something like Select customerId from Index where indexName=FirstName and indexValue=John. The customerId is later joined to another set of tables. Sounds like you might benefit from changing your database schema to something more sensible, but even so, I bet there are ways to optimize that table. What database IS it and what kind of actual indexes are there on the "Index" table? Lucene probably isn't what you're looking for, as it's designed to look for info from self-contained documents (such as for example forum posts) and isn't very good at joins. For relational data it's just fine to use a relational database.
|
# ? Dec 18, 2013 18:30 |
|
FateFree posted:I'm working on a large application that's locked into a terrible database that cannot perform. All of our queries are hitting an 'Index' table, which is a simple table with three columns: customerId, indexName, indexValue. It might contain things like: 1, FirstName, John - and a search by name query would be something like Select customerId from Index where indexName=FirstName and indexValue=John. The customerId is later joined to another set of tables. What do you mean by cannot perform? Has that index table indexes created for the indexName and indexValue fields? Such as CREATE INDEX IDX1 on Index (indexName,indexValue) ? Is customerId a primary key on the other tables? Or has an index made for it? However you look at it though, the existence of the Index table doesn't look good. Changing the database may not help in this case. Changing the developers may.
|
# ? Dec 18, 2013 18:32 |
|
It sounds like what you're really looking for is a DBA.
|
# ? Dec 18, 2013 18:34 |
|
hooah posted:I'm trying to follow Stanford's Intro to Programming course to learn Java. However, there seems to be a problem with their distribution of Eclipse for Windows (here), or perhaps it just doesn't work well with Windows 8. When I try to run that, I get this hideous mess of errors that I don't understand. Could someone help me get this working? I don't have windows 8 so I don't know of its horrors, but you should be fine just using the normal Eclipse for Windows devs from the Eclipse page. What was your problem with getting "Karel the Robot" to work with it? You're probably just not familiar with Eclipse, which I guess is why Stanford had a special build of Eclipse packaged ready to go. You'll just have to import the right project and make sure the build path is properly configured.
|
# ? Dec 18, 2013 18:48 |
|
Zaphod42 posted:I don't have windows 8 so I don't know of its horrors, but you should be fine just using the normal Eclipse for Windows devs from the Eclipse page. Using the standard version of Eclipse, I followed the directions here to set up Karel with Eclipse. However, likely due to my brand-newness at Java, I couldn't figure out how to translate the importing and class setup for the program written in the second lecture into something that would work with the directions I linked above.
|
# ? Dec 18, 2013 19:05 |
|
hooah posted:Using the standard version of Eclipse, I followed the directions here to set up Karel with Eclipse. However, likely due to my brand-newness at Java, I couldn't figure out how to translate the importing and class setup for the program written in the second lecture into something that would work with the directions I linked above. That seems fine. If you've got the libraries imported, the 'second lecture program' you refer to should work. Namespaces are set up such that it shouldn't be machine specific. So you're saying you've got the program that Stanford wants you to look at open in Eclipse, and Eclipse has the Karel external libraries imported. So, whats the issue? You're getting a compilation error when you try to build the program? Can you put the program on pastebin, or copy the output of the compiler error here for us? Need more information. You may just have to make sure the library is imported for specifically that project. Alternatively Java's just complaining because your package name doesn't match the source folder or something, odds are you can just mouse over the red underline and Eclipse will suggest a fix for you. (Package name X should be Y, for example) Click the underlined text and it'll apply the fix automatically. Zaphod42 fucked around with this message at 19:51 on Dec 18, 2013 |
# ? Dec 18, 2013 19:48 |
|
Zaphod42 posted:That seems fine. If you've got the libraries imported, the 'second lecture program' you refer to should work. Namespaces are set up such that it shouldn't be machine specific. I think my problem lies in importing. Currently, my project hierarchy is code:
code:
hooah fucked around with this message at 20:13 on Dec 18, 2013 |
# ? Dec 18, 2013 20:09 |
|
You don't need to import the .jar file - instead, you import the specific classes you want to use, and Eclipse uses your classpath setup to figure out where they are. With the code you have right now, you should be able to delete that import line, and then if you hover your mouse over the "extends Karel" statement then Eclipse should offer to fix it for you by importing the Karel class. Jabor fucked around with this message at 23:59 on Dec 18, 2013 |
# ? Dec 18, 2013 23:56 |
|
Jabor posted:You don't need to import the .jar file - instead, you import the specific classes you want to use, and Eclipse uses your classpath setup to figure out where they are. The fixes I'm offered are "Create class 'Karel'", "Change to 'Kernel' (java.awt.image)", and "Fix project setup...", none of which does what you say.
|
# ? Dec 19, 2013 01:21 |
|
hooah posted:The fixes I'm offered are "Create class 'Karel'", "Change to 'Kernel' (java.awt.image)", and "Fix project setup...", none of which does what you say. you will want to choose fix project setup, and add that jar onto the project's classpath. then you will have it available.
|
# ? Dec 19, 2013 02:24 |
|
|
# ? May 9, 2024 18:31 |
|
rhag posted:you will want to choose fix project setup, and add that jar onto the project's classpath. then you will have it available. Could you go into a little more detail? Keep in mind I've never worked with java or Eclipse before. Here's the dialog I see when I choose fix project:
|
# ? Dec 19, 2013 03:18 |