Sunday, 13 December 2020

Coding standards in Java

 Coding standards in Java :

Java programming language has defined some coding standards for class, variables, methods, interface which has to be followed.

Standards for methods in java:

  • In java programming language coding standards for method is usually name of method  should either be verb or noun combination and it has to start with lower letter.
  • If method name has multiple word than every first character of inner word must start with uppercase.


    Ex: print(), println(), sleep(), setAttribute(), getAttribute().

Standards for Variables in java:

  • The variable names in java programming language usually should be noun and start with lowercase letter.
  • If variable name has multiple word than every first character of inner word must start with uppercase.


    Ex: name, age, email, mobileNumber, studentId.

For Classes:

  • Coding standard of class in java programming language is name of class  should be noun and it has to star with uppercase letter.
  • If class name has multiple word than every word must start with uppercase.


    Ex: String, System, StringBuffer, StringBuilder, Thread

For Interface:

  • Unlike class interface in java language usually name of interface must be adjective and interface name must start with uppercase letter.
  • If interface name has multiple word than every first character of word must start with uppercase.


Eg:  Serializable, Runnable



Constants:

  • These names should be a noun and these should contain only uppercase.
  • If the name of constant consists of multiple word than thye should be separated with ( _ ) underscore.

    
    Ex: MAX_PRIORITY, MIN_PRIORITY.



Getter Methods:


  • Getter should be public method.
  • Method name should be prefixed with get.
  • Getter should not take any parameter.

   syntax:   getXXXX( )
    
    Ex.  getInt( ), getString( ), getDate( ).

Setter Methods:


  • Setter should be public method and return Type of setters should be void.
  • Method names of setters should be prefixed using set.
  • They take some argument.

    

    syntax:   setXXXX( )


    Ex.  setInt( ), setString( ), setAttribute( ).

This is a java program for getters and setters:

public class EmployeeBean{

    private int empId;
    private String name;

    public void setId(int id){
        this.empId=id;
    }

    public int getId(){
        return empId;
    }
    public void setName(String name){
        this.name=name;
    }

    public String getName(){
        return name;
    }

}

Friday, 4 December 2020

In C programming V is used for

In C programming V is used for:

 In C programming V is used for vertical tab. This is a program that demonstrate the use of  \V.

// this is a C program to demonstrate V in c language

 #include <stdio.h>

int main()
{
    printf("Hello \n ");  

    printf("This  \v is  \v a  \v c-language \v program \v to \v demonstrated \v V. ");

    return 0;
}

 OUTPUT:



 Here are few escape characters:

 \b which is used for Backspace in C programming language 

\e   we use this for escape character  in C.

\n 
 This is used for new line character.
 
 \t 
   This is used for Horizontal tab
\\ 
  We use this in c-language  to display the backslash character.

 

Tuesday, 1 December 2020

How to Beautify xml code

 Beautify XML code:

 Online XML Beautifier beautifies ugly XML code and makes it more readable.
 These Online XML Beautifiers gives the code proper indentation, spaces,newlines etc. so that
 it becomes well-formatted code which is easy understandable by user.

Some of them are Notepad3, Code Browser, Kate, Bluefish, Text Editor Pro, Notepad++, XML Notepad 2007, Atom.