HEMANT SONKER'S BLOG

Wednesday, October 15, 2008

how to change windows command prompt background color

1
Left click on the Windows start button. Click "Run." Type in the letters "cmd." Right click on the blue bar on the top of the prompt. Click "Properties." To customize a DOS batch file instead of the general command prompt, open the batch file.
Step2
Choose the "Options" tab. Change the cursor size by selecting the button next to "Small," "Medium" or "Large."
Step3
Hit the "ALT" key and "U" to display the command prompt in full screen mode. When in full screen mode, hit "ALT," "P" and the spacebar at the same time to bring up the command prompt's properties.
Step4
Select the "Font" tab. In the "Size" box, choose the characters' pixel width and height Under "Font," choose from available fonts.
Step5
Change screen buffer and window size on the "Layout" tab. To change the position of the window, uncheck the "Let system position window" box, and select the left and top values. The value "0" displays the window in the top left corner.
Step6
Move on to the "Colors" tab. Choose colors for screen text, background, popup text and popup background. Customize colors by changing the color values manually, or select from the color palette to choose a standard color.
Step7
Click "OK" at the bottom of the window. You will be prompted to save properties for all future command prompts. Choose this option to keep the values each time you open a command prompt. For individual batch files that open a DOS prompt, you can choose "Apply properties to current window only."

Java: Coding Guidelines


A good start would be to use the following.

  • Readability - Make your program as readable as possible ( good names, spacing, ...).
  • Simplicity - Don't add unnecessary complication and duplication. KISS.
  • Convention - Use standard conventions and good practices as much as possible
  1. Comments, indentation, spacing, braces, ...
    • Comments
      • Header comments at front of each file with purpose, author, date ...
      • "Paragraph" comments at beginning of each group of code.
      • Document "tricks" -- anything unobvious.
      • Avoid useless comments. Don't comment code that is already clear.
      • Using javadoc is essential for larger projects.
    • Indentation
      • Use either K&R or Allman indentation style. Don't use others.
      • Indent size 4 spaces
      • Blanks, not tabs
      • Use your IDE's indentation tool.
      • Continued statements should be indented two indentation levels.
    • Spaces and blank lines - Use them to make the source more readable
      • No space between method name and the left parenthesis. f(x), not f (x).
      • One space between keywords (if, while, for, switch, ...) and the left parenthesis.
      • Spaces around assignment and many other operators.
      • Space after comma. f(a, b).
      • Put blank lines between elements - methods, inner classes, ....
  2. Variable (local, instance, class) Declarations
    • One per line. Declare more than one only when there are very closely related (eg, x and y).
    • Add // comment if meaning of variable isn't completely clear or if has special range, values, etc.
    • Don't reuse variable name for more than one purpose. Variables are cheap.
    • Local variables (declared in method)
      • Declare at first use is preferred to declaring at front.
      • Give variable the least required scope (without adding extra blocks).
      • Declare within for loop header if possible.
      • Don't hesitate to create extra local variable if it improved readability.
    • Instance variables (fields)
      • Declare them private.
    • Static (class) variables
      • Use static final for named constants.
      • Static (class) variables are rare.
  3. Braces
    • Use them, even for single statements.
    • K&R or Allman style
  4. Naming conventions
    • Names must be meaningful if possible.
    • Conventional names can be used: i, j, iter.
    • Case rules should be followed. class - start upper, vars - start lower, const - all upper).
    • Instance variables (fields) may start with prefix (eg, "_", "m", ...).
    • Use plural names of mass nouns for arrays and data structures.
    • Avoid confusing name duplicates (method same as field, differing only by case, ...).
    • Don't use a $ in an identifier name.
  5. Error Handling
    • "Happy Trails" programming allowed for most student programs.
    • Recover from user input errors.
    • Crash on programming errors is acceptable. Debugging output is useful.
    • Catching exceptions
      • Don't catch an exception if you can't handle it.
      • Don't use exceptions to handle normal flow (eg, ArrayIndexOutOfBoundsException).
      • Don't use exceptions to hide program errors; fix them.
      • Don't silently ignore exceptions, except in those few cases where you can't do anything anyway.
    • Throwing exceptions
      • Don't throw Exception - make it more specific.
      • Put informative message in exception constructor.
      • If you're supplying a class for someone, throw meaningful exceptions.
  6. Visibility
    • General rule: make data private, methods public.
    • Protected - Use only when designing for inheritance.
  7. Miscellaneous
    • DRY - Don't Repeat Yourself. Repeated code should be replaced with loop/method/...
    • No magic numbers - use named constants.
    • Avoid premature optimization. Don't worry about optimization unless there's a problem.
    • KISS. Keep It Simple, Stupid. Always prefer a simple to a complicated solution.
    • Methods
      • Don't assign to parameters; it makes code more difficult to read.
      • Consider declaring parameters final to assure the reader they aren't changed.
      • Use multiple returns only if it makes the code clearer, otherwise return only at the end.
      • Methods should fit on one page/screen. If they're bigger, consider splitting them.
      • Avoid recursion unless it's a situation where it's much better (eg, traversing trees).
    • Loops
      • Use for instead of while if it groups everything in one statement.
      • For loop clauses should be coherent -- all related.
      • Use the enhanced for (foreach) when possible.
      • Don't change a for loop iteration variable in the body of the loop.
      • Use break to exit early or to terminate an "infinite" loop.
      • The continue statement is rarely used.
    • Switch
      • Switch statements should include a default clause.
      • Make default the last clause in a switch.
    • If
      • Do not write an empty true or else clause.
      • Writing positive logical expressions is more readable then negative. Change if easy.
    • Data structures
      • Use the generic forms of Java Collections data structures.
      • Use newer rather than older versions: HashMap<...> instead of HashTable, ArrayList<...> rather than Vector.
    • Methods
      • A method should be small and focused on one task.
      • Split a method into several methods if it operates on different levels of data.
      • Split a method if it becomes too large (longer than one screen is a common guideline).
      • Split a method which does different things.
      • Smaller methods are easier to understand, use, and debug.
      • It's OK to have utility methods that are only called from one place.

Running a Java Program from Command Prompt

  • Create a temporary folder C:\mywork. Using Notepad or another text editor, create a small Java file Hello.java with the following text:
     class Hello
    {
    public static void main(String[] args)
    {
    System.out.println("Hello, World!");
    }
    }

    Save your file as Hello.java in C:\mywork. To make sure your file name is Hello.java, (not Hello.java.txt), first choose "Save as file type:" All files, then type in the file name Hello.java.

  • Run Command Prompt (found under All Programs/Accessories in the Start menu). Type
    C:\> cd \javaprog
    This makes C:\mywork the current directory.
    C:\javaprog> dir
    This displays the directory contents. You should see HelloWorld.java among the files.
    C:\javaprog> set path=%path%;C:\Program Files\Java\jdk1.5.0_09\bin
    This tells the system where to find JDK programs.
    C:\javaprog> javac Hello.java
    This runs javac.exe, the compiler. You should see nothing but the next system prompt...
    C:\javaprog> dir
    javac has created the Hello.class file. You should see Hello.java and HelloWorld.class among the files.
    C:\javaprog> java Hello
    This runs the Java interpreter. You should see the program output:
    Hello, World!

    If the system cannot find javac, check the set path command. If javac runs but you get errors, check your Java text. If the program compiles but you get an exception, check the spelling and capitalization in the file name and the class name and the java Hello command. Java is case-sensitive!

  • It is possible to make the path setting permanent but you have to be very careful because your system might crash if you make a mistake.

Click "Edit" and at the end append

;C:\Program Files\Java\jdk1.5.0_09\bin

(or the path to the appropriate folder where the latest version of JDK is installed). Do not put spaces before the appended path string.

Click OK on the path edit box and OK on the Ennvironment Variables box. The new setting will go into effect next time you run Command Prompt.