/
Programming Backend

Programming Backend

Stakeholder: @Ajay Sharma @Ajeet Kumar (Unlicensed)

What is the purpose of the Article?

  • You will understand how to write the best code

Audience

  • Software Development Engineers

1. OOPS

2. Commenting

Comments describe the semantics of a class, field, or method. Good documentation comments should allow you to use the class and its methods without having to read any source code. In contrast, implementation comments are used to clarify how a particular piece of code operates. While you should write implementation comments when you feel they are necessary, documentation comments are an integral part of programming and are mandatory in this class

Every documentation comment begins with:
"/**"
and ends with
"*/"

A one-line comment begins with "//"

3. Hibernate(ORM)

Object-Relational Mapping or ORM is the programming technique to map application domain model objects to the relational database tables.

Hibernate Best Practices:

  • Use of model(Entity) classes

  • Session close properly

  • Use find(), save() and update() method

  • Use bind parameters

  • Do not use eager loading

  • Use the automatic primary key generator

  • Prefer using session.get() instead of session.load(). Load always returns the proxy to avoid getting LazyInitializationException

  • As HibernateException is RuntimeException never catch them at the business layer and have them be propagated to UI Layer

  • Always set lazy=true for collection mappings and use Join Fetch in HQL or setFetchMode() method in Criteria API to retrieve collections

  • Use 2nd Level Caching technique for read-only data

  • Use Criteria API

  • Use surrogate keys and let Hibernate generate new values

4. Environment-Specific Application Properties Guideline for Springboot

5. Guidelines for Null Check for Strings Using StringUtils

6. Guidelines for Using Optional in Java 8 to Avoid NullPointerException (NPE)

7. Guidelines for Handling Flow Termination Due to Unmet Conditions

8. Guidelines For using Constants

9. Guidelines for Naming Conventions

10. Guidelines for Using Java 8 Features

11. Avoid Updating Null Values into the Database

https://auperator.atlassian.net/wiki/x/EwA2FAE

 

Related content