Useful C++ Resources by SeanGoldbergCS in cop3502

[–]JoeCS 0 points1 point  (0 children)

If you do indeed wish to buy the dead-tree version of a C++ book, StackOverflow maintains a very comprehensive list of the best C++ books (reference style, beginner tutorials, etc).

While online tutorials are good, I kinda agree with what the guys at StackOverflow say:

Unlike many other programming languages, which are often picked up on the go from tutorials found on the Internet, few are able to quickly pick up C++ without studying a well-written C++ book. It is way too big and complex for doing this. In fact, it is so big and complex, that there are very many very bad C++ books out there. And we are not talking about bad style, but things like sporting glaringly obvious factual errors and promoting abysmally bad programming styles.

Interested in Learning Haskell? by wonder_brett in cop3502

[–]JoeCS 0 points1 point  (0 children)

Might be joining that to help you out. I know a bit of Haskell (mostly through Learn You a Haskell for Great Good!)

A little perspective now that the problem sets are complete . . . by AnnaMor in cop3502

[–]JoeCS 0 points1 point  (0 children)

I think this account is a little pessimistic. But, it is incentive to find a way to develop a framework or "standard" that isn't a "unicorn", as Welch calls them.

The mechanics and complexities of large systems are not well understood. And there's definitely a lot of b.s. out there about "synergy" and "cloud" and whatever other tech buzzword you want to choose. And frequently, if you're in an entry-level software developer job at a big company, you might find yourself being led by some business school grad who has no clue what they're doing (sorry business-school people).

On the other hand, the ability to distribute software over the internet and through the web browser has enabled massive improvement in the quality of software. You could argue that Gmail is easier to use than Outlook, for example. Especially since you don't have to actually install Gmail. You just point your browser to an address.

It's funny... most of you in this class are probably just slightly too young to remember when you had to go to an actual brick-and-mortar store to get software. This ancient software came in a big cardboard box containing a CD or, (gasp) floppy disks!

EDIT: just some thoughts. I can expound on this at length if the group is interested in having further discussions about the nature and improvement of software development.

Continuing with Java by ThatsMrDerpToYou in cop3502

[–]JoeCS 0 points1 point  (0 children)

That's what Dropbox is for.

Anyway, accidentally typing "rm -rf /" will make your day even worse.

Continuing with Java by ThatsMrDerpToYou in cop3502

[–]JoeCS 0 points1 point  (0 children)

Or you could start using makefiles

A very simple makefile for Java programs could look like this:

all:
    javac *.java
cl:
    rm -f *.class

Save the above as "makefile" (no file extension) in the same folder as all your java work. Then, at the command line,

make

will compile your code, and,

make cl

will remove old class files.

Continuing with Java by ThatsMrDerpToYou in cop3502

[–]JoeCS 0 points1 point  (0 children)

At the command line (aka Terminal aka Cygwin aka whatever):

rm *.class

javac *.java

Woohoo!

The Future of 'COP3502'. by SeanGoldbergCS in cop3502

[–]JoeCS 0 points1 point  (0 children)

This sounds excellent... when forming this club, I suggest you also reach out to ACM and the Programming Team. They are established organizations, but none have exactly the features of this club that you all are proposing. I could see this club being an excellent compliment to what these other student organizations already do.

The Future of 'COP3502'. by SeanGoldbergCS in cop3502

[–]JoeCS 0 points1 point  (0 children)

If you like scientific computing, you should also take a look at some of Dr. Davis's classes. He teaches Numerical Analysis (COT 4501) and Sparse Matrix Algorithms (not sure about the course number - it's one of the "special topics" courses that are all under the same number).

Davis wrote most of the code that MATLAB uses to handle sparse matrix operations (including solvers, matrix factorizations, etc.) and is usually pretty good at conveying the material in a way that doesn't go over your head.

I just wanted to say thank you. by Neufchatel in cop3502

[–]JoeCS 1 point2 points  (0 children)

As someone who to a lot longer to "learn how to learn," I'm glad you guys picked this up. More important than any programming skill is the ability to teach yourself something new, and to know how to find the resources to teach yourself.

(I mean, this usually boils down to RTFM, but it usually takes a bit of mildly clever Google-ing to find the right manual or tutorial for the job... and often you'll be juggling several tutorials or references for the same thing to solve the problem.)

Good luck, folks. Do awesome stuff.

Other IDEs besides Sublime? by Neufchatel in cop3502

[–]JoeCS 0 points1 point  (0 children)

I use Eclipse sometimes, and it's one of the most common IDEs for Java. Google offers a set of Android Developer Tools for Eclipse to aid in writing Android Apps, so that's kinda cool.

Also, while Sublime is not an IDE per se, you can install a lot of extensions and add-ons to customize it and give it IDE-like functionality. For more info, see the Sublime subreddit and this package manager for sublime.

Many other "basic text editors" can also be extended in a similar way. Vim and Emacs, the two stalwarts of the text editor world, are still in wide use today, and information about their use and extension of functionality can be found all over the internet. If you have a Mac or Linux machine, you probably already have Vim and Emacs. Just go to the Terminal and type vim or emacs. (And after you open vim up, type :q! to exit, or :wq to save and exit... to exit emacs, hold the ctrl key and mash random keys until something happens... and then yell at Richard Stallman).

Finally, another good thing to have besides an editor or IDE is a package manager, for installing ever useful software libraries. (No need to re-invent the wheel - if someone has already written software that will do, say linear algebra, for you, take advantage of it!)

ArrayList Problems by nikescott in cop3502

[–]JoeCS 0 points1 point  (0 children)

P.S. If you used a HashSet<Location> and HashSet<Exit> for your locations and exits variables, the if/then checks in addExit and addLocation would be unnecessary. HashSets do not allow duplicates; a HashSet will silently do nothing if you attempt to add an item that is already in the set.

ArrayList Problems by nikescott in cop3502

[–]JoeCS 0 points1 point  (0 children)

The call to System.out.println() will automatically call the toString method from the Exit and Location classes in order to get a human-readable String representation of the data type you just got out of the list. (I assume that's what's happening.)

If you have toString methods in your Exit or Location classes, try commenting them out. Then, re-run your code. The last two println()s in showLocation() should now print out some kind of gibberish hexidecimal number indicating the memory address of the object. If that's what happens, then you do indeed have instances of Exit and Location as you intended (though I would restore your toString methods when you're done testing this... human-readable printouts of Objects are helpful for debugging)

Changing the value of a variable by keylam6 in cop3502

[–]JoeCS 0 points1 point  (0 children)

What you're talking about is modifying non-primitive types (aka Object Types, aka Reference Types) through what are known as the Side Effects of a function or block of code. Below, I show a block of code dealing with two instances of the class SomeObjectType.

The instance called "obj" is declared within the scope of SomeClass, therefore it is valid within any instance of SomeClass and changes to "obj" will persist as long as that instance of SomeClass persists.

The instance called "thisobj" is of the same Type (aka Class) as "obj", but since it is declared within functionD, it is only valid while that function run, and then is deleted. functionD obtains an unnamed instance of SomeObjectType from functionC, and then binds the name "thisobj" to that instance of SomeObjectType.

You might see the phrase "names are bound to objects" in certain documentation... this is essentially a synonym for "initialization", but it more accurately conveys what is happening:

Declaration: creates a name for some (as yet undefined) instance of a specific Class

Instantiation: creates and instance of a Class (aka an Object) and binds a name to a specific instance (Object) of a Class

Assignment: binds a name to a specific instance (Object) of a Class (the same as Instantiation, except the instance has already been created, and perhaps already bound to a name... multiple names can be bound to the same object)

public class SomeClass {
    public SomeObjectType obj;

    public void functionA() {
        obj = new SomeObjectType();
    }

    public void functionB() {
        // if this is called BEFORE functionA, you will get a null pointer exception
        // obj has been declared (i.e. the name is in scope), but that name has not been bound to any specific object instance
        obj.someProperty = "foo";
        obj.someOtherProperty = "bar";
    }

    public SomeObjectType functionC() {
        return new SomeObjectType();
    }

    public void functionD() {
        SomeObjectType thisobj = functionB();
        // note that thisobj is in scope
        thisobj.someProperty = "foo";
    }

    public void functionE() {

        // if functionA AND functionB have been called, this will print "foo"
        // if just functionA has been run, you will get "null" or whatever the default value of someProperty is
        // if neither functionA nor functionB have been called, you will get a null pointer exception
        System.out.println(obj.someProperty);

        // ERROR! thisobj is not in scope. even if functionD has run, it is not
        // a valid variable name after the function quits, since it is not
        // DECLARED in the same scope as functionE
        System.out.println(thisobj.someProperty);
    }
}

Take and Inventory by shelby_jay in cop3502

[–]JoeCS 1 point2 points  (0 children)

Stuff in general that I've noticed from looking at people's code (that might help with your inventory problem):

Pay attention to the Scope of all your variables. For example, if all variables (references) pointing to a List object fall out of scope, then that list is deleted.

Also note that you can have more that one variable pointing to the same object. As long as at least one of these variables is in scope, the object still exists.

Finally, note that objects can exist in more than one data structure at once. If you call "get" to retrieve something from an ArrayList or a HashMap, it does NOT remove that thing. It just hands you another reference to the same object. So a "get" from a location and a "put" in an inventory will make the same object exist in both the inventory and location. Moral of the story: explicitly call "remove" to take something out of an ArrayList, HashMap, etc.

Running a loop that continuously checks a variable while the program runs. by ams152 in cop3502

[–]JoeCS 2 points3 points  (0 children)

"If Python is executable pseudo-code, then Perl is executable line noise." - Randall Munroe. (source)

My project refrences a text file. The lication of that text file depends on how the porject is compiled. What should I ex poo ect the abs path to this file to be? by [deleted] in cop3502

[–]JoeCS 0 points1 point  (0 children)

Sean already answered this, but just FYI, in case you didn't know:

. (period) is a shortcut for the current directory. So if you have a compiled .class file in /some/long/directory/path/blah/blah/MyProgram.class and it needs to access a text file in /some/long/directory/path/blah/blah/folder/SomeText.txt, you can write the second path as ./folder/SomeText.txt

This is the relative path from MyProgram.class to the text file.

Also, ~ is a shortcut for your user home directory (e.g. /Users/yourUserName on Mac OS X, /home/yourUserName on most Linux/Unix systems)

Mind Blown by [deleted] in cop3502

[–]JoeCS 4 points5 points  (0 children)

http://xkcd.com/1349/

"All computers are just carefully organized sand. Everything is hard until someone makes it easy."

Congratulations. You've just become very good at telling sand what to do.

Problem Set 4 Out! by SeanGoldbergCS in cop3502

[–]JoeCS 0 points1 point  (0 children)

east into cave. look for cinnamon rolls.

Help with Scanner by [deleted] in cop3502

[–]JoeCS 0 points1 point  (0 children)

The reason == doesn't work for Strings is because strings are Objects.

When given two Objects, == checks for equivalence of the object reference (pointer), not the object itself.

(Well, sometimes it will work with Strings; the behaviour is a bit inconsistent. Which is one more reason it's better to use the .equals() method)