When I try to put code in Blackboard discussion posts it gets messed up.  How do I get code to be readable? 

When you need to paste code into a discussion board post, here is one approach that will show your code with fairly correct formatting and not too much extra work:

In the toolbar above the editor, on the third row, almost at the end is an HTML button. 

 

Click this button and you will get a second editing window.  In this window add an open and a close pre tag:

 

put your code between the two pre's and then click the update button to return to the main editor.  If you need to have more than one section of code you can do this more than once in the same message.

NOTE: if you are including code with angle brackets < > such as for generics or including HTML tags, add extra spaces around them or Blackboard will strip that part of your code entirely, so say " < T > "  not "<T>" 

(Blackboard is trying to provide a text editor for writing html documents inside an html document.  This is a hard problem.  But Blackboard does a hilariously worse job at it than... pretty much anybody else.  This is another reason that most of the course material lives on a web page and not inside Blackboard.)


Can I use Eclipse or some other IDE for my homework?  Don't you know that NetBeans sucks and Eclipse is awesome? Or if we're using NetBeans can't we use Maven or Graedle or ...

I will be grading using my HCC issue computer, which has Netbeans 8.1, which I do not have admin rights to do updates on.  NetBeans projects made in the current version using Ant open and run correctly on this setup.  Other formats don't.

So, you can use any IDE you want, but if you want me to open and grade your work, what you turn in to me must be a complete NetBeans project folder, so it will be up to you to convert before turning in. 

I have used different IDEs in other semesters for this class, including a text editor and command line compiler/interpreter.  We are currently using NetBeans.  You will probably be subjected to a variety of different IDEs in your career.


How do you open a project you have downloaded from Blackboard? 

Once you have downloaded it, you will have a zip file.  Then you need to unzip it.  NetBeans will not open anything from inside a zip file.

A quick way to extract your files from the zip (in Windows) is to double click the zip file to navigate the contents.  Inside you should see your project directory.  Drag this out of the zip file to another destination.  It may take a moment to finish unzipping. 

Then you will have both the folder and the zip file.  Drag the folder to the main editing area of NetBeans (not to the Projects area).


I submitted the wrong project / only part of my project / some other file instead of submitting the correct zipped complete NetBeans project.  Can I resubmit?

It is your responsibility to be sure that what you have submitted is a .zip file  containing a complete NetBeans project made with Ant.  Up until the due date, you may resubmit as often as you want.  Beyond the due date I will not accept it for credit. 


Why did you give me a zero for the way I zipped my project?  AwesumZip75992 is a great open source program that is 9000% more efficient than what Windows does!  All you have to do to open a .awsm75992zp file is...

It is your responsibility to show that you can follow the format requirements of this class, including using a .zip file that opens natively on a Windows computer.  This should not be a difficult hurdle to clear, please come discuss with me if you are having trouble figuring out how to zip a file using something other than your pet program.


When I open my Netbeans project from home on an HCC machine (or my project from HCC on my home machine) I get an error like invalid target release: 1.7 and I can't compile or run my code.  How do I fix this?


How should I indent my code? 

Code should be indented one tab stop inside each structure (class, method, conditional, loop, try, etc).  For example

 
/* format example */
public class Doge {
   private String name;
 
   // print  message based on name
   public showMessage() {
        if (name == null) { // name not set!!
           System.out.println(�so null pointer, much error�);
        } else if (name.equals(�Shiba Inu�)) {
           System.out.println(�wow. such original�);
	} else {
   	   System.out.println(name+�, very java, many code�);
   	}
   }
}
 

NetBeans will do this for you as you type.  If you have edited your code and got it a bit muddled, use Source > Format and it will fix it for you.


Shortcuts like psvm and sout aren't working on my netbeans at home.

You can find the settings for these under Tools> Options > Editor to see all the available abbreviations. This allows you to edit and add these.

You may find that on later Netbeans editions like 20 you have to make sure you are on a new line of code (hit enter) and that you are in an appropriate place (i.e. it will not do sout if you are outside a method.


Did you know that if it only has one line, you don't NEED curly braces? You don't really want curly braces on every single conditional and loop do you?   

Yes, I know that.

YES I want curly braces EVERY SINGLE TIME.

I know those two extra keystrokes exhaust your little finger and drain your soul, but for the purposes of this class, do it.


I think it would be better to name variables with capital letters / have mutators return  / whatevs. Why are these wrong?  

They are the wrong answer to how to write code following the standards used in this class.  In general, I try to stick with the most widely used conventions, so that the habits you learn are most likely to match the code you will read and be asked to write.  I don't always think these conventions are the best, just the most common.

If nothing else, you are practicing your standards compliance, so you'll be prepared the day you find yourself working for a shop with some completely bonkers coding standard left over from the days when the chief coder was a cobol wizard..


Why are we using arrays/for loops/ whatever when this would be a lot easier with Arraylists / foreach / some convenient and easy-to-use tool?

There are some cases where I have ruled out widely used constructions because at this point they tend to be used as crutches to avoid learning how to work through certain kinds of problems. 

Often, although you would usually make use of some common tool to solve a simple problem, I'm making you to work through the simple problem manually, rather than making you work through some large an elaborate problem where the common tool couldn't be used.

To put it another way, I'm making you reinvent the wheel because I'm pretty sure you don't need to spend a lot of time in this class learning to use a wheel, but you probably need practice inventing things  in general, and inventing the hovercraft would make for a very long classwork.


I've got <default package> instead of a package in my project.  What's going on?

This most often happens when you're creating your project in NetBeans and you go to change the name of the main class created automatically, and replace the whole thing instead of just the part after the period.  The original name will be something like pkgnm.Filename and you changed it to MyClass instead of to pkgnm.MyClass .  In this case, your java files won't have a package statement at the top.

While this usually won't make a difference in how your code runs, it would be better to have a package.  You can easily fix this by right clicking the project and choosing New > Java Package (the name of the package doesn't matter).  Then drag your java files onto the package you created.

If some of your classes are in a package (or you at least have a package) but some classes are in <default package> that probably means that when you added new classes you clicked on the top of the project (the coffee cup) or somewhere else instead of on the package (the icon looks like a square yellow package tied with string).  You can fix this by dragging the class onto the package where it should be, and then clicking the Refactor button when prompted.


How much commenting do you require?   

Use comments to explain what you're doing.  There should generally be a comment on each class and method (constructors, accessors, mutators, and toString may not need them) and anywhere you're doing something that isn't blindingly obvious.  Meaningful method and variable names can limit the need for comments.  You may find it helps to copy the description from the assignment as a comment.

What's going on?? No comments, useless names:

public void newPuppies(int x, String y) 
chow();
check();
System.out.println(x + "\'s " + y + " new puppies have arrived!!");
 
if (x > 3) {
	chow();
	hire();
}
}

Comments not helping readability -- wordy for no reason, names still bad:

// method newPuppies goes through process to adopt some new puppies
// buying food for the puppies and checking that the house is safe
// takes x, a variable to store how many puppies
// takes y, a variable to store the name of the owner
public void newPuppies(int x, String y) 
// call method to buy puppy chow
chow();
// call method to check that the house is safe
check();
 
// print out message saying how many puppies have arrived
System.out.println(x + "\'s " + y + " new puppies have arrived!!");
 
//check if there are more than three puppies and if so do extra prep
if (x > 3) {
	// call method again to buy more chow so we have double the food for the extra puppies
	chow();
	// call method to hire puppysitter needed for the extra puppies
	hire();	
}
}
 

Readable -- comments and better naming:

 

// named owner preps for and adopts some puppies
public void adoptPuppies(int howmanypuppies, String ownerName) {
// prep
buyPuppyChow();
safetyCheckHouse();
 
System.out.println(ownerName + "\'s " + howmanypuppies + " new puppies have arrived!!");
 
//extra prep for large litters
if (howmanypuppies >3) {
	buyPuppyChow(); // double food
	hirePuppySitter();
}
}