This week's book giveaway is in the Spring forum.We're giving away four copies of Spring Boot in Practice and have Somnath Musib on-line!See this thread for details.
Win a copy of Spring Boot in Practice this week in the Spring forum!

# Benjamin Scabbia

Ranch Hand
since Jul 10, 2014
Benjamin likes ...
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
3
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by Benjamin Scabbia

Winston Gutkowski wrote:

Benjamin Scabbia wrote:It prints 0..9 - why?

Because:is precisely equivalent to:apart from the fact that, in the second case, i is defined outside the loop.

Now, looking at that second loop, would it make any difference if it was ++i instead of i++?

HIH

Winston

Great answer thanks for helping me out!

Makes sense and of course, in the second loop using a prefix or postfix would make no difference
7 years ago
Hi!

I was looking at this for loop

It prints 0..9 - fine.

I then looked at this loop

It prints 0..9 - why? From what I understand ++i is a prefix, therefore by the time the for loop condition is checked, shoudln't i start with 1? So 1..9?

If I did this test in a print statement so:

7 years ago
Hi!

I'm working on a mini-project. I am building an airplane booking system, where each plane has a limited number of seats (50).

Currently, when a booking is made I add it to the flight details using this method. (booking holds various information inc Number of seats booked as an Int)

My issue is that I can't figure out the best way to keep track and assign the seats for each booking. I.e. say someone books 6 seats, how can I allocated seats 0-5 (or 1-6)? So when the next user comes, they can only book seats 6 (or 7) onwards?

I considered using a LinkedList which would allow me to keep track of seats, but then say someone cancels the booking and seats 2,3,4 become available, these would now be 'null', but how do I manage this?

Is it best to create a new class like 'Seats', where my LinkedList would then store 50x Seats object which holds the seat number and a boolean value (whether it's occupied or not) and then go from there? Or does anyone else have a better idea? Thanks!

*Assumptions:
-Not fussed about where they sit
-All airplanes have 50 seats
7 years ago

Peter Rooke wrote:Two academic books we used many years ago;

Introduction to Database Systems - CJ Date
Fundamentals of Database Systems

That's a look to learn - good luck!

Thanks for your reply and advice! I've gone for "Relational Theory for Computer Professionals by C. J. Date" which is fairly new and hopefulyl will get me up and running. But as soon as I finished that book (which Im hoping to get through quickly) I will be looking for new material and I will deffo check out the two above in-depth
7 years ago

Joanne Neal wrote:

Benjamin Scabbia wrote:no idea how you found this little gem!

I think it was originally offerred as a course on Coursera. If you haven't come across this site yet, it's well worth a browse, as is Udacity

Yes I've used Coursera in the past, it's very good (did a Python course). I've also heard of Udacity but never used it. I will keep an eye out for relevant courses. Thanks again!
7 years ago

Joanne Neal wrote:

Benjamin Scabbia wrote:Also +1 for the list of books! I will spend the evening evaluating my choices and purchase something in the next couple of days

If you prefer listening and watching to reading (and don't want to spend any money), this course from Stanford University is a great introduction to databases.

Hi Joanne,

Thank you for the suggestion, seems to cover Relational Databases, Relational Algebra & SQL, so thats a huge win!! . (no idea how you found this little gem!).

Don't suppose you have any other recommendations for Entity Relationships & Transactions Management?

I'm also torn between these 6 books..., so if anyone could help me decide which might be most suitable, I would be MASSIVELY grateful!
1. The Language of SQL. By Larry Rockoff
2. Database Design for Mere Mortals. By Michael Hernadez
3. Sams Teach Yourself SQL in 10minutes. By Ben Forta
4. Learning SQL. By Alan Beauliue
5.SQL in Easy Steps

Could anyone suggest which books I can use (along with the material you guys mentioned above), since I prefer learning from a book. I know very little on the subject, so I don't really know which (or combinations) of books would be best? Could someone help me filtering the list down to 1-2 books.

Thanks again guys
7 years ago

Campbell Ritchie wrote:I am a bit surprised they will let you do Advanced Databases without doing Basic Databases first.

The module is optional and since I came from a non CS degree, I have never studied it, so it's actually designed for people with prior experience so I'm really exposing myself... But I know the importance of databases so it's a challenge (or a gamble) that I'm willing to take
7 years ago

K. Tsang wrote:MSCS for non-CS? Is that really possible?

Anyway undergrad database course will cover material like SQL, ER modeling, logical/physical design, normalization, security and transaction management.

So I suggest you pick up any database management books and have a glance.

Yet I believe you should need drill on SQL quite a bit. Head First SQL here is probably a good choice for beginners. It should give some grounds in those areas.

Yes it's a very strange format indeed. After studying a Business Economics degree for 3 years, I learnt (the hard way) that it really wasn't for me so I found this course which ties in nicely with my job (not much spare time though!).

Thanks for the recommendations, I have uses head first before (java & design patterns) and I was very impressed so I'm happy to go back to them. It is 2007 though, is that an issue? Also do you know if it covers any other areas which would prepare me for the module?
7 years ago

Campbell Ritchie wrote:I am a bit surprised they will let you do Advanced Databases without doing Basic Databases first.
Try this part of the Java Tutorials for a start. Look in our books pages and you might find something useful there.

I shall move this discussion to a more appropriate location.

Thank you for the reply and sorry for posting in wrong section. I know that my university uses Java as the fundamental programming language, however, I am unsure if the module will cross over with java at this stage or whether it will be purely oriented on the database side (which is what I suspect), but interesting and very useful nonetheless!
Also +1 for the list of books! I will spend the evening evaluating my choices and purchase something in the next couple of days
7 years ago
Hello guys,

I am currently studying a Masters in Computer Science (for people with non CS degrees) and I am considering studying for my next module "Advanced Databases". My concern is that I have never studied databases and I have very limited knowledge in the area. Messaging the head of the module I found out that I need to have some understanding of these 5 concepts:

1.The relational Model;
2.Relational Algebra (and maybe Relational Calculus);
3.SQL;
4.Entity-Relationship Modelling (ERM) and Enhanced ERM (we are using UML notations);
5.Transactions Management;

I have roughly 2 months to gain an understanding of the 5 subjects.

Can anyone recommend me some material/books that are suitable for a degree level and that will help me get up to speed with some of above concepts? Also any advice would be greatly appreciate it.

Thanks
7 years ago

Paul Clapham wrote:You'd only need to concern yourself with the number of processors if your tasks were actually using processors. But accessing a web site is far from being compute-bound. To the contrary, it spends almost all of its time waiting for network traffic to complete. So the number of processors isn't relevant to the number of threads you should use.

Anyway, yes, the ExecutorService is the way to go. Your Processor class would find more links, so it would have to create new Processor objects for them and give them to your ExecutorService. You should experiment to see if the number of threads in the pool makes a difference; it may be that your operating system's TCP/IP stack throttles the number of threads it handles at once, for example.

Great, I'm glad that i'm at least on the right path. And yes that make sense that the app is not computer-bound, although tests suggest a thread pool is a necessity!

So if I had an array of websites, how do I implement this into the program? I get I need to create a new Processor for each site, but the only obvious way to do it is like this:

Would above work or would I end up creating 50 different processors? Or because I specified the executor thread pool to 4, would that mean once one has finished it would then start on the next threadPool - therefore even though I have 50 processors, only 4 will be active at once?

7 years ago
Good evening! I have this program which I'm currently working on that desperately needs some thread support.

The program looks in the specified URL and scans the page for links and email addresses. It also grabs all links from the homepage (theoretically all other pages of website) and then again looks for links.
(Note, not full code below + using an HTML parser called JSoup)

The program works perfectly but it's fairly slow. Can someone explain to me how I implement threads for this particular program. I assume (depending on the number of processors) I can have x threads running, therefore I can iterate through x number of sites?

This is what I have come up with so far - although I have never used threads so no idea if my implementation is correct.

Then in the main application I could do something like:

Is this implementation correct? I understand that the code is not complete but I'm just wondering if what I'm doing is correct? Theoretically, I could then use a large array of websites, and let the processors iterate through them and as one finishes.... what happends then? How would I make the thread that's finished parsing through the website start on the next element in array?

Thanks guys
7 years ago
Hi guys, I'm following a set of tutorials and I'm having trouble getting my head round these 'custom' action listeners.

So (to simplify it) say I have 2 classes and an interface.
Class 1: MainFrame which extends JFrame and connects all gui components
Class 2: A panel (with some random elements) which extends JPanel. MainFrame instantiates this class.
Interface 1: A listener for the panel

Class 1 (MainFrame)

Class 2 (FormPanel)

Interface (FormListener)

So I understand that the mainFrame creates an instance of FormPanel where the formPanel adds a number of elements, then the mainFrame adds the panel to the main JFrame. I also understand that the FormPanel has a listener which grabs the information FROM the filled in form, once the user presses the okButton. I get this, BUT:

1. how does the information flow (assuming it's from Panel TO mainFrame?)
2. how does the okButtonlistener get the information to MainPanel?
3. Why the interface?

Thanks guys!
7 years ago

Mike. J. Thompson wrote:

I would suggest using

That is functionally the same, but makes your intent clearer.

I like this, I agree makes intent clearer. Thanks!
7 years ago

Bear Bibeault wrote:Hint:

Fantastic solution, exactly what I was looking for - I'm surprised I didn't think of it to be honest!
Not sure what code went wonky, must have been a copy/paste issue.
7 years ago