0% found this document useful (0 votes)
2 views11 pages

SOP's

The document outlines deployment procedures for Java/Spring MVC applications on Tomcat, including pre-deployment checklists, deployment steps, rollback procedures, and documentation practices. It also provides best practices for MySQL database management, covering schema design, indexing, and query optimization. Additionally, it details Java and Spring MVC coding standards to enhance code quality, maintainability, and testing practices.

Uploaded by

Omsi Avinash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views11 pages

SOP's

The document outlines deployment procedures for Java/Spring MVC applications on Tomcat, including pre-deployment checklists, deployment steps, rollback procedures, and documentation practices. It also provides best practices for MySQL database management, covering schema design, indexing, and query optimization. Additionally, it details Java and Spring MVC coding standards to enhance code quality, maintainability, and testing practices.

Uploaded by

Omsi Avinash
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 11

1.

Deployment SOP for Java/Spring MVC on Tomcat

A well-defined deployment process minimizes errors and downtime. Use this as your
standard operating procedure for manual deployments on your local Tomcat server.

A. Pre-Deployment Checklist

1. Code Quality & Testing - Developer

o Commit & Merge: Ensure all changes are

1. Committed, Merged
2. Passed all Unit/Integration tests.

o Code Reviews: Confirm that code reviews have been completed and
approved.

o Make sure no unwanted Cron is left open and running.

o Make sure all the Alerts are removed.

o Feature Flags/Configuration: Document any feature toggles or configuration


changes.

2. Backups & Environment Checks - EDP

o Backup: Copy the current WAR file and export any critical data.

o Server Health: Verify that the local server has sufficient disk space and is not
experiencing performance issues.

o Configuration Files: Confirm that configuration files (e.g., context.xml,


application properties) match the target environment.

3. Versioning & Documentation - Developer

o Version Update: Update the version number in your build tool


(Maven/Gradle) if needed.

o Release Notes: Document changes for team visibility and rollback planning.

B. Deployment Steps

1.Check if deployment server, DB are in same environment.

2.Confirm if required paths are updated as required.

3. Check if client is informed or not if required.

3. Stop the Tomcat Server

o Command Line (Unix/Linux):


bash

Copy

cd [TOMCAT_HOME]/bin

./shutdown.sh

4. Delete and Backup up existing Deployments

o Remove the existing WAR file from the webapps directory.

o Delete (or archive) the expanded application folder if deploying an exploded


WAR.

5. Deploy the New WAR File

o Copy the new WAR file (built from the latest code) into the webapps
directory.

o Ensure that the WAR file is correctly named (e.g., myapp.war) for automatic
deployment.

6. Start the Tomcat Server

o Command Line (Unix/Linux):

bash

Copy

cd [TOMCAT_HOME]/bin

./startup.sh

7. Post-Deployment Verification

o EDP

1. Log Review: Inspect Tomcat logs for startup errors or exceptions.

2. Smoke Testing: Visit key application pages and test critical


functionality (Lists are reflected are not).

3. Service Health: Verify if server utilization is as expected and no issue


id

4. Confirm left Menu is visible.

5. Check booking and billing screens are visible.

o Developer
1. Confirm with client whether deployed changes are reflected and
application is working as intended.

2. Check prints, header file error is not reflected.

8. Confirm the team about deployment.

C. Rollback Procedure

 Immediate Action:

o If critical issues arise, stop Tomcat immediately.

o Replace the new WAR file with the previously backed-up WAR.

o Restart Tomcat and confirm that the previous version is operational.

 Communication & Documentation:

o Notify the team of the rollback.

o Document the incident and any lessons learned for process improvements.

D. Documentation & Communication

 Maintain a log detailing deployment dates, versions, encountered issues, and


rollback events.

 Use shared documents or an issue tracker to record feedback and improvements.

2. MySQL Best Practices and Guidelines

Efficient and secure database management is key. Below are detailed practices for schema
design, modifications, query optimization, and performance checks.

A. Schema Design and Modifications

Inserting New Tables and Columns

 Naming Conventions:

o Use consistent and meaningful names (e.g., table names should be singular or
plural consistently; column names can follow snake_case or camelCase).

o Avoid reserved keywords and ambiguous names.


 Creating Tables:

o Define clear data types and constraints (e.g., NOT NULL, UNIQUE, DEFAULT
values).

o Document relationships, primary keys, and foreign keys.

o Example:

sql

Copy

CREATE TABLE employee (

id INT AUTO_INCREMENT PRIMARY KEY,

first_name VARCHAR(50) NOT NULL,

last_name VARCHAR(50) NOT NULL,

department_id INT,

created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP

);

 Adding Columns:

o When adding columns, consider the impact on existing data and application
logic.

o Use migration tools like Liquibase or Flyway to track and apply schema
changes.

o Example:

sql

Copy

ALTER TABLE employee

ADD COLUMN email VARCHAR(100) NULL AFTER last_name;

Mapping with ORMs

 Entity Mapping:

o If using an ORM like Hibernate, keep your entity classes in sync with your
database schema.

o Use annotations such as @Entity, @Table, @Column, and relationship


mappings like @OneToMany, @ManyToOne, etc.
o Example:

java

Copy

@Entity

@Table(name = "employee")

public class Employee {

@Id

@GeneratedValue(strategy = GenerationType.IDENTITY)

private Integer id;

@Column(name = "first_name", nullable = false)

private String firstName;

@Column(name = "last_name", nullable = false)

private String lastName;

@Column(name = "email")

private String email;

// getters and setters

B. Joins and Indexing

Using Joins

 Types of Joins:

o INNER JOIN: Use when you need only matching records.

o LEFT (or RIGHT) JOIN: Use when including non-matching records is necessary.

 Best Practices:

o Ensure join conditions are based on indexed columns.


o Avoid joining on expressions or functions, which can prevent index usage.

o Example:

sql

Copy

SELECT e.first_name, e.last_name, d.department_name

FROM employee e

INNER JOIN department d ON e.department_id = d.id;

Indexing

 When to Index:

o Columns used in WHERE, JOIN, or ORDER BY clauses.

o Frequently queried columns.

 Types of Indexes:

o Single Column Indexes: For individual columns.

o Composite Indexes: For multiple columns frequently used together.

 Maintenance:

o Regularly review and optimize indexes.

o Avoid over-indexing since it can slow down INSERT/UPDATE operations.

 Example:

sql

Copy

CREATE INDEX idx_employee_last_name ON employee(last_name);

C. Performance Checks & Query Optimization

 Analyzing Queries:

o Use the EXPLAIN command to analyze and optimize query execution plans.

o Enable and monitor the slow query log.

 Query Best Practices:

o Avoid SELECT *: Specify only the needed columns.


o Simplify Queries: Break down complex queries or subqueries and consider
rewriting them with joins.

o Caching & Denormalization:


Consider caching frequently accessed data (using tools like Redis) or
denormalizing data for read-heavy operations—but balance against data
consistency.

3. Java & Spring MVC Coding Standards

Consistent coding standards improve readability, maintainability, and reduce errors. The
guidelines below cover general practices as well as detailed aspects of loops, conditionals,
logic, and overall design.

A. General Java Coding Conventions

 Naming Conventions:

o Classes & Interfaces: Use PascalCase (e.g., UserController, OrderService).

o Methods & Variables: Use camelCase (e.g., getUserDetails(), orderCount).

o Constants: Use UPPER_CASE_WITH_UNDERSCORES (e.g.,


MAX_LOGIN_ATTEMPTS).

 Formatting & Style:

o Indentation: Use 4 spaces per indent level (consistent use of spaces over
tabs).

o Line Length: Aim for lines under 100–120 characters.

o Braces: Follow a consistent brace style (K&R, Allman, etc.).

 Comments & Documentation:

o Write clear Javadoc for public classes and methods.

o Include inline comments for complex logic.

o Avoid redundant comments that merely restate the code.

 Error Handling:

o Use specific exception types and provide meaningful messages.

o Do not use exceptions for normal control flow.

o Log exceptions appropriately (avoiding sensitive information).

B. Detailed Guidelines for Loops, Conditionals, and Logic


Loops

 Efficient Iteration:

o Enhanced For-Loop: Use the for-each loop when iterating over collections or
arrays.

java

Copy

for (String item : itemList) {

// Process item

o Avoid Deep Nesting:


Extract complex or deeply nested loops into separate methods.

o Modification Safety:
Do not modify a collection while iterating over it unless using an iterator that
supports safe removal.

o Stream API:
Consider using Java 8’s Stream API for clarity and functional-style operations:

java

Copy

itemList.stream()

.filter(item -> item.startsWith("A"))

.forEach(System.out::println);

Conditionals

 Simplify and Clarify:

o Guard Clauses:
Check for error conditions or invalid states at the beginning of methods to
reduce nesting:

java

Copy

if (object == null) {

throw new IllegalArgumentException("Object cannot be null");


}

o Ternary Operators:
Use for simple, single-line assignments only:

java

Copy

String status = (score >= 50) ? "PASS" : "FAIL";

o Avoid Overly Complex Conditions:


Break down complex boolean expressions into clearly named variables or
helper methods for clarity.

Logic & Method Design

 Single Responsibility:
Each method should perform one clear task. If a method grows too complex, refactor
into smaller methods.

 Readability:
Use self-explanatory names and extract repeated logic into helper or utility methods.

 Error Handling:
Validate inputs early, and use custom exceptions where appropriate instead of
generic ones.

C. Design Principles and Patterns

 SOLID Principles:

o Single Responsibility: Every class/method should have one reason to change.

o Open/Closed: Design classes that are open for extension but closed for
modification.

o Liskov Substitution, Interface Segregation, Dependency Inversion:


Follow these principles to create flexible, maintainable code.

 Design Patterns:

o Use common design patterns (e.g., Factory, Singleton, Observer, Strategy) as


needed.

o Avoid over-engineering; keep the design as simple as possible until


complexity demands advanced patterns.

 Dependency Injection:
o Leverage Spring’s DI by preferring constructor injection over field injection to
improve testability and reduce coupling.

D. Spring MVC Specific Guidelines

 Layered Architecture:

o Controllers:
Handle HTTP requests and delegate business logic.

o Services:
Encapsulate business logic.

o Repositories/DAOs:
Manage database interactions.

o Keep each layer focused on its responsibilities.

 Annotations & Configuration:

o Annotate classes with @Controller, @Service, or @Repository as appropriate.

o Use @Autowired (prefer constructor injection) to manage dependencies.

o Validate request inputs using @Valid and related annotations, and handle
exceptions centrally with @ControllerAdvice.

E. Testing, Code Quality, and Version Control

 Unit & Integration Testing:

o Write unit tests for critical logic using frameworks like JUnit and Mockito.

o Include integration tests for controllers and service layers.

 Code Reviews & Static Analysis:

o Use code reviews (via pull requests or similar workflows) to ensure quality.

o Integrate static analysis tools (e.g., SonarQube, Checkstyle, PMD) into your
build process.

 Version Control:

o Follow a consistent branching strategy (like Git Flow or feature branches).

o Write clear commit messages that explain the "what" and "why" of changes.

Final Recommendations
 Documentation & Training:
Keep these guidelines in a central, easily accessible document. Provide training
sessions or workshops to help new team members understand and adopt these
standards.

 Continuous Improvement:
Regularly review and update these standards as technologies evolve and the team
identifies areas for improvement.

 Tooling Integration:
Use automated tools for static analysis, testing, and deployment to enforce these
guidelines consistently.

By following these comprehensive procedures and standards, your team will be better
equipped to deliver high-quality, maintainable, and efficient software while minimizing
deployment risks and ensuring robust database management. Happy coding and deploying!

You might also like