[go: up one dir, main page]

0% found this document useful (0 votes)
9 views60 pages

Software Testing Company by Slidesgo

Uploaded by

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

Software Testing Company by Slidesgo

Uploaded by

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

MERN

STACK
Submitted to
Dr. Amjad
Farooq
Submitted By
Tayyaba Afzal (2022-CS-
134)
Raveeha Mohsin (2022-
CS-149)
TABLE OF CONTENTS

01 Overview & Description

02 Guidelines with Examples


0
1
OVERVIEW
MERN Stack

A NoSQL database used to A JavaScript library for


store data in flexible, JSON- building user interfaces,
like documents. with reusable components.
Mongo DB React

01 02 03 04
Express.js Node.js
A framework for Node.js that A JavaScript runtime
handles the backend server environment that allows
operations and routing. developers to build server-
side applications.
Guidelin
02 es
MongoDB

Use Schema Validation:

Define your data structure clearly


using schemas to ensure data
integrity. Always specify required
fields and data types in your
schemas to avoid invalid data
from being inserted.
Use Schema Validation:
MongoDB

Error Handling in Database Connections:

Always include error handling when


connecting to MongoDB to ensure you
catch and log database connection failures.
MongoDB

Use Mongoose Models Effectively:

Use Mongoose models to interact with your


MongoDB collections. Keep your database
operations organized by using appropriate
model methods such as find, save,
update, and delete.
Use Mongoose Models Effectively:
MongoDB

Optimize Queries:

Use MongoDB query operators to fetch only


the data you need and avoid retrieving
unnecessary fields to improve performance.
MongoDB

Use Indexes for Query Optimization:

For large datasets, ensure to create


indexes on fields you frequently query to
improve performance.
Frontend Framework
Frontend Framework
Express

Modularize Routes:

Break down your routes into smaller modules to


keep the code organized. Each route should have its
own file for easier management.
Express

Centralize Error Handling:


Use middleware for error handling in Express
applications. Create a global error handler to
manage different types of errors.
Express

Use HTTP Status Codes Appropriately:

Return the correct HTTP status codes (e.g., 200


for success, 404 for not found, 500 for server
errors) to inform the client of the
result of the request.
Use HTTP Status Codes Appropriately:
Express

Asynchronous Request Handling:

Use async/await for handling


asynchronous requests and ensure proper
error handling within the async functions.
Asynchronous Request Handling:
Express

Use Middleware for Common Tasks:

Middleware in Express is like a helper that


runs before your main code. It helps you
manage tasks that happen repeatedly, such
as logging requests, checking user
permissions, or processing data. By using
middleware, you avoid writing the same code
over and over, making your application
cleaner and easier to maintain
Use Middleware for Common Tasks:
React

Keep Components Small and Focused:

Each component should ideally focus on a


single responsibility. For instance, separate your
form logic and presentation. You can create a
Form component that handles form inputs and
submission, while the EmployeeAdd component
manages the overall state and interactions.
Keep Components Small and Focused:
React

State Management
Use a single state object for
related data.
State Management
React

Effect Management

Use useEffect for API calls and include


cleanup logic.
Effect Management
React

Use Controlled Components:

Maintain form inputs as controlled


components, which you are already
doing. This helps keep the UI in sync
with the state.
Use Controlled Components:
React

Validation and Feedback:

Implement form validation and give


users immediate feedback on errors,
like displaying error messages
for invalid inputs
Validation and Feedback:
React

Simplify Conditional Rendering:

Instead of using multiple ternary operators,


consider using separate components or a
utility function to handle different rendering
cases. This approach keeps your JSX
clean and readable.
Simplify Conditional Rendering:
Simplify Conditional Rendering:
React

Use Switch for Route Management

When using React Router, wrap your routes


with a Switch component to ensure that
only one route is rendered at a time. This
can prevent multiple routes from being
matched simultaneously and improve
performance. Additionally, always use the
exact prop when necessary to avoid
unintended matches.
Use Switch for Route Management
React

Leverage Route Parameters

Use URL parameters to pass data between


routes efficiently. This can make your
application more dynamic and user-friendly.
In your components, access these
parameters with useParams to fetch or
display specific data.
Leverage Route Parameters
React

Component Reusability and Modularity

Break down your components into smaller,


reusable pieces. This makes them easier to test
and manage. Use props to pass data and callbacks
to child components for better communication.
Node.js

Environment Configuration:

Store sensitive information such as database URLs and


API keys in environment variables instead of
hardcoding them in the code.
Node.js

Avoid Blocking Code:


Always use non-blocking, asynchronous methods
for I/O operations to keep your application
scalable and prevent performance bottlenecks.
Node.js

Modularize Code for Reusability:

Organize your application logic into reusable


modules and separate concerns like routes,
database connections, and services.
Node.js

Handle Uncaught Errors and Rejections:

Always handle unexpected errors like


unhandled promise rejections or uncaught
exceptions to prevent the
application from crashing.
Node.js

Avoid Blocking the Event Loop:

Node.js is single-threaded, so avoid writing


code that blocks the event loop (such as
long-running loops or synchronous
functions). Use asynchronous methods (like
fs.promises for file handling) to keep your
application fast and responsive.
Avoid Blocking the Event Loop:
Any
Questions
?
Thank
You

You might also like