Projects and other stuff

Projects and other stuff

Re: Nero’s JCalculator

rs06player:

Just wanted to share,

Nero’s JCalculator, download open-source here.

Information: Nero’s JCalculator is a simple open-source Calculator made by Nero using Java.

Version: 1.0 [ALPHA]

Future of the project: At last, this will be released to the public for learning purpose, also, I’m developing this just for getting knowledge in Java, the full release will contain a nice GUI and these stuffs, but I’m still learning anyway :D.

I discovered your post while searching through the tumblr tags for Java and decided to give it a try.

1. It’s compressed using a propitiatory archive format (.rar) which alienates people running Linux-based operation systems (Ubuntu, Fedora, etc). It took me awhile to open the archive because I had to find the right packages to install, which can be time-consuming. You should really use the .tar.gz archive format instead because it works on virtually every file manager without having to install any additional content.

2. You included a .bat script in your archive, which only works on the Windows operating system. Users running Mac OSX or Linux will either have to use the command line to run the program (a lot of people don’t know how to do this ) or import the src folder into Eclipse (or another IDE) and run it from there. Instead, you should compress the program into a .jar file, which is supported by every operating system with a JVM.

3. You shouldn’t call any of your classes “Main”. I know what you’re getting at, it’s the class containing the main method, but the name simply isn’t descriptive and doesn’t provide the programmer with any useful information. Once you start having projects with dozens or even hundreds of different classes, it’ll be really confusing what Main is or why it’s important.

4. You seem to break up the program into four separate classes that don’t do anything on their own. Instead, you should create a class called “Calculator,” code any methods that you need, and put it together in the main method. It’ll be much easier to read and less confusing for other programmers. You should only start a new class if you need a separate body of similar methods that accomplish a part of your task efficiently and can be re-used for later projects.

5. The comments aren’t very helpful in explaining what you’re trying to do in the class. Typing:

    // Objects
    public static Scanner s = new Scanner(System.in);
    // variables
    public static double FirstNumber;
    public static double SecondNumber;
    public static String type;

doesn’t tell us anything new; we know what objects and variables are. You should get into the habit of writing verbose descriptions before major chunks of your code so that programmers reading your code have a basic idea of what’s going on before they delve into the code; it’ll make their lives much easier.

6. Too many if-then-else statements; get into the habit of using switch. Trust me, it’s easier to read. Instead of typing:

if(ask.type.equalsIgnoreCase(“Sum”)){
            Result = ask.FirstNumber + ask.SecondNumber;
        }else if(ask.type.equalsIgnoreCase(“Minus”)){
            Result = ask.FirstNumber - ask.SecondNumber;
        }else if(ask.type.equalsIgnoreCase(“Multiplay”)){
            Result = ask.FirstNumber * ask.SecondNumber;
        }else if(ask.type.equalsIgnoreCase(“Division”)){
            Result = ask.FirstNumber / ask.SecondNumber;
        }   

you should type:

switch (ask.type) {

case “sum”: Result = ask.FirstNumber + ask.SecondNumber;

break;

// … etc

}

Note: above only works if using a Java 7 compiler.

6. Attempting to divide by zero returns the result “Infinity.” Although this is a problem with Java’s implementation of float and double variables, you should really make an effort to prevent this.

7. Entering a letter or a number that doesn’t exist such as “j” or “4x” will return a InputMismatchException. You can fix this by surrounding the piece of offending code into a try-catch block that informs the user of the invalid input.

8. Lastly, you should make the program loop until the user tells it to stop. It can be annoying to the user if they have to launch the program every time they want to make a new calculation.

Hope this helps! If you need any other help, feel free to ask.

(via rs06player-deactivated20120405)

My review of the Code Warrior IDE

Today, I had a Java quiz. It was extremely simple, assuming that I had a competent IDE to use. Eclipse? I wish that were the case; I would’ve finished the quiz in 5 minutes tops if I was using Eclipse.

Instead, I had to use this ancient, proprietary, IDE called “Code Warrior” that nobody has ever heard of and is a piece of shit. I can’t even figure out to make a new class file; it’s complicated and doesn’t even work the way that I expect it to work. Since I knew I was under pressure and didn’t have time to figure out how to use it, I simply deleted lines of my calculator program and edited in the new stuff that was relevant to the quiz. I’m all set, right? I wish it were that easy. Code Warrior does not have a compiler built in, it uses the god awful Windows “cmd prompt” that wants to be a terminal but fails so hard. Error highlighting, right? Every good IDE underlines incorrect code in red and gives a small description about it. Code Warrior has no such feature. It waits until you attempt to compile the .java file and then hits you with a barrage of error messages that make no sense. Yep, you guessed it. It’s the equivalent of writing code in notepad and manually compiling it using the words “javac example.java” and “java example.”

Actually, it doesn’t even do that. It compiles it to a .jar every time, which makes no fucking sense. Why on earth would I want my program to be compiled to a .jar unless I tell it to? What audience is Code Warrior catering in? What purpose is it serving? To be frank, nobody. I quickly Google searched “Code Warrior review” and the results gave me content dating back to 1997. No self-respecting programmer would use this instead of Eclipse or NetBeans (I personally do not like NetBeans, but at least it can call itself an IDE).

I did finish the quiz, but I almost ran out of time when I didn’t need to. I’m going to ask my teacher on Monday if I can use Eclipse in a polite manner, and I will state the advantages for doing so. I already know Java, and using Eclipse will help me get my work done quicker. There are literally no downsides to using an IDE that I’m comfortable using, especially under pressure. Also, I don’t exactly agree with using proprietary software, either.

If you ever have the unpleasant experience of using the Code Warrior IDE, I pray for your sole.

Top