Java OOPC -Coding Standards ,Object and Class

 

  Java Coding Standards

Java coding standards ,java object and java class
 

Why coding standards for java?


 Standards in java code, we can mention it also as coding conversions or style guidelines. Those are essential in many ways, but in the first place it’s for identity purpose. Programmers follow those regulations for give code to quality, readability, maintainability and collaboration aspects of Java code.


Here are some key reasons why standards in java code are important.


1.Readability

Coding standards ensure that code is written in a consistent manner throughout a project. This consistency makes it easier for developers to read and understand the code.


 

2.Maintainability

When developers follow a consistent style, it becomes simpler to identify and fix bugs.


 

3.Collaboration

In a collaboration development environment ,multiple developers work on same project .Coding standards facilitate collaboration by providing a shared set of guidelines, ensuring that team members can understand each other’s code easily.

 

 

4. Industry Standards and Conventions

        Following coding standards align codebase with industry and communication conventions. This makes it easier for other developers, Mainly those are not familiar with code other’s specific project ,to understand and contribute to the code.


Coding Standards for Classes: 

 

  • Usually meaningful and descriptive names use for classes and name represent the purpose or role of the class.

  • Use capital letter for first letter of class. Further, CamelCase or we can tell it as  PascalCase. It means that capitalize the first letter of each word.

Eg: String, StringBuffer, Dog


Coding Standards for Variables: 

  • Usually variable name should be lowercase letter.
  •  If it contains multiple word than every inner word should start with uppercase (CamelCase).

Eg: name, age. mobileNumber


Coding Standards for Methods: 

  • Usually method name should either be verb or verb noun combination.
  • starting with lower letter and If it contains multiple word than every inner word should start with uppercase.

Eg: print(), sleep(), setSalary()

Java Object and Classes

Java  Object


In Java, an object is a concept used to represent  real-world entities in a  program. Objects are instances of classes, which serve as blueprints or templates defining the properties and behaviors common to a group of objects.

In simply we can tell object is process or the action.


public class Car {

    // Attributes

    String make;

    String model;

 

    // Methods

    void startEngine() {

        // Method implementation

    }

}


Java Class

 

In Java, a class is a block of object-oriented programming (OOP) helps to arrange the things we need to.  It serves as a blueprint or template for implements objects.  A class defines the properties and behaviors (methods) that objects of that type will have.


public class MyClass {

    // Class members (fields and methods) go here

}


 






Comments

Popular posts from this blog

Linked List Data Structures

Java OOPC -Encapsulation

Java OOPC - Interface