Simplifiing Java

Discuss how to write good code, break bad code, your current pet projects, or the best way to approach novel problems

Re: Simplifiing Java

Post by conscience on Thu Jul 07, 2011 1:27 am
([msg=59526]see Re: Simplifiing Java[/msg])

mShred wrote:Oh nothing is wrong.. I just didn't get why you quoted yourself. Was that on accident? Or am i just missing something completely obvious. My bad man.


Ah, 'k! I just re-stated that I'm not too experienced with J as a response to what ryl wrote. Sorry for obscuring the thread
Let him who has understanding recount the number of the beast, for it is a human number: His number is 0x029A.
conscience
Poster
Poster
 
Posts: 248
Joined: Thu Jan 08, 2009 9:05 pm
Location: 127.0.0.1
Blog: View Blog (0)


Re: Simplifiing Java

Post by mShred on Thu Jul 07, 2011 1:42 am
([msg=59530]see Re: Simplifiing Java[/msg])

Ohh that would make sense. Yeah this thread is pretty much necroed. My bad.
Image

For those about to rock.
User avatar
mShred
Administrator
Administrator
 
Posts: 1612
Joined: Tue Jun 22, 2010 4:22 pm
Blog: View Blog (2)


Re: Simplifiing Java

Post by martyj2009 on Sun Aug 07, 2011 12:50 am
([msg=60645]see Re: Simplifiing Java[/msg])

and you should avoid using I, i think c# and others use this as a convention for declaring interfaces.


When an interface in C# starts with I normally it is declared like II. For example you have a class named Item that is an interface. The normal styling would name it as IItem.

There is no reason to avoid using the letter I as a class name unless it's something dumb like IRobot.

As for the OP. My main suggestion would be your tabs. Decide if you are going to use 2 spaces for a tab or 4. Try not to change it up. I also prefer to have curly braces on the next line is it helps with readability but that's entirely up to you.
martyj2009
New User
New User
 
Posts: 5
Joined: Sun Aug 07, 2011 12:24 am
Blog: View Blog (0)


Re: Simplifiing Java

Post by conscience on Sun Aug 07, 2011 8:06 am
([msg=60652]see Re: Simplifiing Java[/msg])

Since then I got a job at a software company. We have quite a few standards there to follow. Braces, tabulation, no interface naming like IRobot (instead we'd name it Robot and an implementing class could be EngineAssemblingRobot for example), commenting standards, unit test naming standards, etc.

Maybe I'm a pervert, but I'm having lots of fun working with these stuff, really. :mrgreen:
Let him who has understanding recount the number of the beast, for it is a human number: His number is 0x029A.
conscience
Poster
Poster
 
Posts: 248
Joined: Thu Jan 08, 2009 9:05 pm
Location: 127.0.0.1
Blog: View Blog (0)


Re: Simplifiing Java

Post by VPR3 on Mon Aug 08, 2011 3:42 pm
([msg=60679]see Re: Simplifiing Java[/msg])

Well here's another one excuse the mess, I coulda cleaned this up but I didn't have my coffee...
but it generates random numbers......
Code: Select all
import java.util.Scanner;
import java.util.Random;

public class FIIK
{
public static void main (String[]args)
{
    Scanner input = new Scanner (System.in);
    Random randomNumbers = new Random();
    int c=0,g,n = randomNumbers.nextInt(100);
 
    System.out.println("Guess a number between 1-100. You have 3 attempts.\n");
    do
    {
     System.out.printf("Guess %d: ", ++c); g = input.nextInt();
     if (c == 2) System.out.println("\nLast Chance");
     if ( c == 3 && g != n ) System.out.printf("\nYour Stupid. The number is %d.\n",n);
     if (c < 4 && g == n) System.out.printf("\nSo your lucky, but still stupid...\n");
    }
    while (c != 3 && g != n);
}
}
VPR3
Poster
Poster
 
Posts: 161
Joined: Fri Apr 22, 2011 11:35 am
Blog: View Blog (0)


Previous

Return to Programming

Who is online

Users browsing this forum: No registered users and 0 guests