(Part 2) Top products from r/javahelp

Jump to the top 20

We found 20 product mentions on r/javahelp. We ranked the 61 resulting products by number of redditors who mentioned them. Here are the products ranked 21-40. You can also go back to the previous section.

Next page

Top comments that mention products on r/javahelp:

u/high_hobo · 1 pointr/javahelp

I actually ended up helping a few people on this exact problem. Small world, eh?

The way I would have designed it would be to start at how I wanted to use the system. This may seem odd and fairly abstract, but can lead some detail as to how it can be done:

Car entrant = new Car("Ford Fusion"); // or whatever
Spot spot = carPark.park(entrant);

if (spot == null) {
System.out.println("Could not find a spot for the car!");
} else {
System.out.println("Car was parked at: " + spot);
}

This tells me I automatically need a few things.

  1. We need a Car class
  2. We need a Spot class
  3. We need a CarPark class
  4. In the car park class, there is a method to park a Car and returns the Spot that the car was parked into; if available, otherwise null.

    So what was the purpose of this exercise? Merely to show one way to approach the problem. I'd personally say that the code above is fairly clean and understandable, would be a good way to have the final implementation be written.

    ---

    From here you have a few options. One I found to be quite nice was having a Floor class that contains all the Spots available for that floor. This kinda makes sense, as multiple Floors make up a single CarPark and will usually be very very similar.

    Then as for parking the car, a modified Visitor Pattern was used. Which might seem a little confusing at first. However, think of it in the real world. A car will keep visiting available floors until it either runs out of floors or finds a spot to park. Just as you would do as you are trying to find a spot to park in.

    So in the end it could look like:

    public class Car {

    public Spot visit(Floor floor) {
    // find suitable empty spot
    }
    }

    public class Floor {

    private final List<Spot> spots; // all available spots

    }

    public class Spot {

    // type, availability, etc...

    }

    public class CarPark {

    private final List<Floor> floors;

    public Spot park(final Car vehicle) {
    for (Floor floor : floors) {
    Spot spot = vehicle.visit(floor);
    if (spot != null) {
    return spot;
    }
    }
    return null;
    }
    }

    Very bare-bones implementation, but a good starting block. Here, I designed it with the real world in mind. Car, CarPark, Spot, these are all tangible real-world objects. And a CarPark is basically a bunch of Floors and each Floor has certain Spots available to it.

    This design here should mirror the real world fairly nicely. That is the purpose of OOP. Its to you can say things like carPark.park(car); and understand what that does.

    ---

    Hopefully you understood the steps I took here. If anything was too confusing, not explained in enough depth or anything, feel free to ask.

    As to learning this stuff, here are my recommendations in order of importance:

  5. Write more programs like this. 'Simulations' like this are often based off of the real world and have a very nice OOP model.
  6. See if your university/college offers a Software Design class. These are based off of OOP like 99% of the time and go over patterns like Visitor, Adapter, Singleton in far more depth as well as teaching you how to come to that conclusion.
  7. Check out a few books. Design Patterns is fairly in depth. Personally, I have a few OOP books and one I found to be quite nice is Object Design: Roles, Responsibilities and Collaborations

    Hopefully this helped clarify a few issues here.
u/jbacon · 1 pointr/javahelp

Here's pretty much your most basic flow for problem 3:

  1. Find the square root of your target number.
  2. Starting at 2, check if target % loop counter == 0
  3. If yes, store as a factor and divide your current target by that number. Use that as the new for loop end condition. Find the complement of that factor, and store that as well.
  4. Go through all the divisors you found and test if they are prime.
  5. The largest remaining number should be your solution.

    To troubleshoot, use a debugger (Eclipse's builtin is nice). If you feel it's taking too long, break the program's execution and check its state. Is the loop counter about where it should be? Are the found divisors plausible? Is the loop end target plausible? Set a breakpoint on the first line inside the loop and keep stepping through (either one line at a time if you like, or just hit 'resume' and it will break again at the top of the next loop iteration).

    I learned Java throughout college, as it was the primary teaching language. Honestly, the best way to learn is just to WRITE CODE. Solve problems that you don't know how to solve. Invent random things that are useful to you. Your code doesn't have to be perfect when you're learning (and it definitely won't be!), and what is important is that you constantly look for ways to improve. I want you to look back on code you've written a year ago, and think that it's absolute crap - that will show that you are learning and improving.

    Somewhat counter-intuitively, the best resources are books! I'll list some recommendations below.

    Keep these principles in mind:

  6. Don't repeat yourself. If you're copying and pasting code, it is wrong. If there is not a single point of truth for each piece of information in your code, it is wrong. Find ways to keep your code clean and non-repetitive.

  7. Document everything. Comments - comments everywhere. Explain what ever piece of your code does. Explain what each method's arguments are, what it does, and what it returns. If you don't know, then that's a big red flag to reevaluate your design. If a bit of code is doing something complicated, write inline comments explaining what each bit does. All this is for future you - I can hardly remember code I wrote last week, let alone a year ago.

  8. Separation of concerns. Each piece of code should only work with what it is directly responsible for. UI code should deal with presentation. Application logic should deal with data manipulation. A persistence layer should handle any database or serialization of things. Keep your code loosely coupled!

  9. Design patterns. There are dozens of semi-formal patterns used to solve common problems in software. Learn to recognize these problems, when to apply these patterns, and how to modify them to suit your goals. See Wikipedia, or Design Patterns by the Gang of Four.

  10. Be pragmatic. What does your code really need to do? What is the minimum that it needs to accomplish, and how can you keep it extensible enough for future expansion? The answer to the last part is largely the previous points - well designed code is always easily changeable. The Pragmatic Programmer is another excellent book. It even comes with a handy summary sheet of its main points!

  11. TEST! Write lots of unit tests. Make sure that every piece of your program is tested to be correct. Every time you find a bug, write a test for it so it never happens again. If a piece is difficult to test, it may mean that it is poorly designed - reevaluate it. This is guaranteed to save your bacon at some point - you'll probably hate the work, but the safety net is invaluable. Being able to instantly tell if you program is working properly is invaluable when making changes.

    Once you start getting a feel for Java, which I think you might be already, Effective Java is the book. You probably won't need any other resource for Java itself.

    If you need help with something, Reddit is a great place, but Stack Overflow is the programmer's mecca. The best resource on the web for just about everything software, and their sister sites cover other topics, from IT/sysadmin to gaming.
u/MegaGreenLightning · 3 pointsr/javahelp

I've read both Effective Java and Clean Code and highly recommend them as well.

There's also Agile Software Development (by Robert C. Martin):
http://www.amazon.com/Software-Development-Principles-Patterns-Practices/dp/0135974445/ref=sr_1_1?ie=UTF8&qid=1451828712&sr=8-1&keywords=agile+software+development

This book contains among other things a description of the SOLID principles of software design. For example the Single Responsibility Principle tells you that each class should have only one responsibility. This reduces coupling and leads to small and more easily understandable classes. The book also contains some nice case studies showing how to apply these techniques.

While Clean Code deals with writing code and how to design methods and classes, Agile Software Development tackles the topic at a higher level and discusses how to develop and design software consisting of different classes and packages etc. It requires a basic knowledge of programming and OO, though.

Robert C. Martin has also created a series of purchasable training videos at cleancoders.com. These videos cover the topics of both books starting with the rules for clean code and then going into the SOLID principles and other advanced topics.

u/Pandarr · 1 pointr/javahelp

I just started reading Effective Java about 2 days ago and am already 1/3rd through it. Very good stuff even though I've been doing Java for a good 8 years or so. Depending on your level some of it might be over your head but you can skip a section and come back to it later. Knowing some good habits is better than knowing none! I also got the Java Puzzlers: Traps, Pitfalls, and Corner Cases book and man that's a tough book. It's very easy to read and understand but so far I haven't figured out any of the puzzles on my own although I'm only about 10 in. So far I can't imagine encountering any of these situations in the real world (or at least my office) but it's good to know and understand them because I'm sure at least one will eventually happen.

u/Bgomez89 · 1 pointr/javahelp

declaring a method as private/public does different things. A public method means that any class can access that method. A private method on the other hand cannot be accessed by any class except the one it's in.

You're pretty new to java and it's awesome that you're starting to build programs. Keep going! I'm a big fan of this text book: http://www.amazon.com/Java-How-Program-Edition-Deitel/dp/0132575663

It's a very easy to read and has lots of great explanations/problems

u/banuday17 · 1 pointr/javahelp

To sharpen your OOP skills, I highly recommend these two books. I would go so far as to say they changed my life:

u/Idoiocracy · 2 pointsr/javahelp

Java is an excellent choice of language to learn if making an Android app is your eventual goal. While Kotlin is also available, your desire of wanting to learn a language in the context of physics simulation makes you a perfect audience for a highly recommended book called Computer Science: An Interdisciplinary Approach by Robert Sedgewick. This book is excellent because of the interesting problems and wide breadth of science and math topics that it touches upon while teaching the Java language.

The upside to going through this book is you will have an excellent foundation of Java and computer science, fully prepared to learn Android programming. The downside is that this will take longer than a tutorial approach, and the book costs money. Here is a sample chapter 2 in PDF format.

Please note that Robert Sedgewick has another book called Introduction to Programming in Java. The difference between this book and the Computer Science book is that the Computer Science book has the entire contents of the Intro Java book, but also has three additional chapters on computing theory, computing machines, and processor design. Since the two books cost about the same price, you might as well get the larger Computer Science book with additional content.

If you prefer video lectures or an online course, they are available for this textbook:

Video lectures

Coursera's Computer Science: Programming with a Purpose

Coursera's Computer Science: Algorithms, Theory, and Machines - This course covers the second half of the Computer Science book.

u/Highway62 · 1 pointr/javahelp

By "single-node linked list" do you mean singly-linked list? If so:

Each node in a singly linked list is just an object with an 'element' field to store stuff, and a 'next' (or 'pointer) field to store the next object in the list. If there is only one node, this node is the head and its 'next' field is set to null. If you want to add another node to the list, you just create a new node whose next field is null, and set the head's 'next' field to equal the new node. If you want to traverse the list you create a new node and set it to the head:

Node cursor = head;

then use a loop

while(cursor != null){
//do something with the element
cursor = cursor.next();
}

Once the cursor reaches the last item in the list, "cursor = cursor.next()" means that cursor is set to null and so the entry condition for the loop is no longer met and stops executing. So you are just continually setting the cursor to be the object pointed to in the 'next' field of each node until it is null.

The problem with a singly-linked list is that you can only traverse "forwards" travelling to each node's 'next' object until you reach the end. This is where a doubly-linked list comes in handy. A doubly linked list has a 'next' field and a 'previous' field. This makes it easier to delete nodes in the middle of the list as to delete one you can just set the 'next' field of the previous node to equal that of the current nodes 'next', and the 'previous' field of the next node to equal that of the previous node, then set the current node's previous and next fields to null, un-linking the node from the list. Once there are no references to an object in java, and the object makes no references to anything else, then Java's garbage collection will free up the space that object was taking up in memory, so the object is deleted.

In your example code, to see the difference between these two loops, you need to visualise in your head what is happening at each iteration, and the check that the while loop is carrying out for its condition. Since the second loop is checking the cursor's 'next' field to see if it is null, instead of checking to see if the cursor itself is null as in the first loop, this means that once the cursor is set to the last node (whose next is null) the loop will not execute again. So any actions you were carrying out on each element would not be carried out on the very last node because that node's 'next' is null, which doesn't meet the condition of the loop.

I found it helps a lot more if you can visualise what is happening with data structures, this book does a great job of explaining everything with illustrations of what is happening during traversals and deletions etc, if you can get your hands on it you should.

u/lost_in_trepidation · 3 pointsr/javahelp

I really like Intro to Java Programming, Comprehensive edition. link

It has tons of exercises and it covers lots of Java 8 features and JavaFx (the modern gui library for Java).

u/[deleted] · 1 pointr/javahelp

As a separate but related thought to my earlier reply, here's a link to http://docs.oracle.com/javase/tutorial/ the Oracle Java Tutorials. These things (and the Sun version) were my holy book when I was learning Java. Unlike the more C style book you appear to be using they focus on drilling the object oriented design concepts into your brain right from the start.

I also recommend picking up http://www.amazon.com/Programming-Principles-Practice-Using-C/dp/0321543726

While it isn't Java per se, the concepts Stroustrop focuses on are relevant to programming in any language.

u/sauceLegs · 2 pointsr/javahelp

If you have an understanding of how object oriented programming works, The Big Nerd Ranch guide to Android Programming is a great book. Not too expensive as far as CS textbooks go. If you aren't familiar with OOP or Java, though, you should start with basic programming in Java before moving on towards Android specific learning.

u/LegendaryAK · 1 pointr/javahelp

http://www.amazon.com/Java-Introduction-Problem-Solving-Programming/dp/0133766268

As an aside, I find it ridiculous author's like savitch can get away with a new edition every semester it seems like. When really the only thing that changes is the Java Version and the example problems. Other than that, I have his 4th edition of this same book, and I didn't notice much difference. I DO like it as a text-book, nonetheless.

u/ryosen · 2 pointsr/javahelp

Java is a great language to start out with and I would recommend two books to get you running. Since you are new to the language and programming in general, start with Head First Java. Then, move on to a more advanced treatment like Core Java. Thinking in Java is also very good but it's dense and some people have a difficult time digesting it.

Once you have the basics of the language down, learn about working with databases. Then, move on to server-side development as that's where the jobs are.

Despite the similarity of their names, Java and JavaScript are not similar and cannot be used interchangeably. JavaScript is primarily used in UI development in web browsers, although server-side implementations have existed for almost as long as JavaScript itself. Currently, the most fashionable of these implementations is node.js.

Lastly, since you are looking to work professionally but without any formal education, know that you are going to have a difficult time getting work for the first several years. You might find that learning JavaScript (and HTML and CSS) are a quicker route to finding a job as front-end web developers often do not require a college degree, whereas Java programming jobs invariably do.

u/asking_science · 3 pointsr/javahelp

I started out with Hands-On AI with Java, and once I got the basics down, I progressed to more general AI literature and applied that in Java.

u/JavaAndMIPS · 3 pointsr/javahelp

Make a personal project. I made a game editor.



Read more books.

Java Swing:

https://www.amazon.com/Java-Swing-Second-James-Elliott/dp/0596004087

Java I/O:

https://www.amazon.com/dp/0596527500/

Java Generics and Collections:

https://www.amazon.com/Java-Generics-Collections-Development-Process/dp/0596527756/

Java Concurrency:

https://www.amazon.com/Java-Threads-Understanding-Concurrent-Programming/dp/0596007825/

Java Network Programming:

https://www.amazon.com/Network-Programming-Elliotte-Rusty-Harold/dp/1449357679/

Java Web Services:

https://www.amazon.com/dp/1449365116/

Java Database Programming:

https://www.amazon.com/dp/1565926161/

Java Performance:

https://www.amazon.com/dp/1449358454/

Intro to Design Patterns w/ Java:

https://www.amazon.com/Head-First-Design-Patterns-Brain-Friendly-ebook/dp/B00AA36RZY/

Design Patterns (not Java and very dry, but much more in depth):

https://en.wikipedia.org/wiki/Design_Patterns

If you read every O'Reilly book on Java and do two or three big projects (or ten small ones) with what you learn in each book, you will learn how to do anything with Java. Java can do anything any other language can, but it takes longer to get there. Once you get there - once you build it - it will run forever, provided it's built well.



Online resources.

http://www.tutorialspoint.com/swing/

https://www.javatpoint.com/java-swing

The javax.swing class:

https://docs.oracle.com/javase/7/docs/api/javax/swing/package-summary.html

The Java API specification:

https://docs.oracle.com/javase/7/docs/api/

Never took one of these, defer to someone else's advice:

https://www.udemy.com/java-swing-complete/

It takes a while to figure out how to effectively use google. Look up my posting history to see how to format posts. You may need to make a test class to simplify things or provide a simple (and obviously safe) thing that people can execute and debug, if they decide to help you.

You will spend a lot of time on the Java API spec, so make sure that you know how to read a method header and signature. You'll get used to it after a few weeks.

*

General advice.**

Debugging is the single most important thing you do. If you can't see what's going wrong, you won't fix it except via trial and error (which is frustrating and takes forever). Any time something goes wrong, either walk through it with a debugger or get print statements working. Getting print statements working is often a job in itself.

I spend more time debugging than I do programming, because when things are going right it's a breeze but when they aren't it takes ages.

Take up some other hobby that keeps you active.

When you're frustrated and nothing is working, do something else. Go for a walk, garden for a bit, cook something. Make sure you have a notepad or note-taking program on your phone so you can stop and take notes when the solution comes to you.

If nothing else is working, just screw around with things and make print statements to see what they do. That's how I learned everything.

Try to break everything.

Don't be afraid of embarassing yourself.