Campbell Ritchie wrote:
Does it? Good grief!Jason de Vere wrote:. . . netbeans does . . .
Rob Camick wrote:You have been given a link to the Swing tutorial. Read the tutorial and play with examples of the tutorial.
Your posted code looks nothing like the examples in the tutorial . For example, you should NOT be extending JFrame. You SHOULD be using "invokeLater()" to create the GUI.
Learn from the examples and from the API.
Tim Moores wrote:It's done all the time :-) In the simplest of cases, you'd use the JAX-RS API to create REST WS running on your choice of servlet container (Tomcat, Jetty, you name it). The kind of client(s) (browser, desktop app, mobile app, other web apps) wouldn't matter much.
Junilu Lacar wrote:
Jason de Vere wrote:At the moment I'd doing a course in Algorithms and Datastructures, where most of the time we are discussing mathematical concepts and using pseudocode. The lecturers advise us to use C++ to implement it if we want to try it out. However, I haven't got a clue about C++ so I was doing it with Java. That is why I am avoiding using any advanced methods.
There's not much difference in C++ and Java as it relates to writing a program like this. The implementation language is not that important here. It's how you organize the ideas that make up your solution that's crucial. If you're studying algorithms and data structures then sure, you're going to have build almost everything yourself instead of using parts/assemblies that are already available for you to just use.
Junilu Lacar wrote:The CS curriculum (over 30 years ago now) I went through had us learn a programming language first before we studied algorithms and data structures. That is, CS101 - Computer Programming (in Pascal) was a pre-requisite for CS204 Algorithms and Data Structures (in Pascal). It seems it would be difficult to learn about the latter if you didn't already have some basic mastery of the implementation language you were using.
Winston Gutkowski wrote:I think you're doing fine, and I particularly like the fact that you're explaining each step in your code. You'd be amazed how many experienced programmers forget to do that.
I also like the fact that you've named your method expand(), because that's exactly what it's doing. It's also a verb, and methods are usually actions of some sort.
However, what I don't like is that your method takes no parameters and returns no value. This makes it highly "coupled" - meaning that it doesn't stand on its own.
If you look at Junilu's example, his method takes the original array as a parameter and spits back a "modified" array, so the only thing left to do is assign it somewhere. And his code never references anything outside the method.
This is called "re-usability" and means you can - for example - copy and paste it into another program to do something similar, or (probably better) add it to a static library of generic "Array" methods, which is precisely what java.util.Arrays is.
As you go forward, what you'll discover is that most methods follow the "IPO" pattern - IPO standing for "Input - Process - Output".
That is: they take an input (in your case, an array), perform some sort of process on it (in your case enlarging it), and produce a result (the expanded array).
So the general signature pattern for most methods is:
{public/protected/private} final return-value method-name(parameter1, [parameter2, ...])
And don't forget that "final", even though it's redundant for private methods. Just get into the habit of adding it, because one of these days it will save your bacon. :-)
HIH
Winston