ASSIGNMENT
SOFTWARE ENGINEERING
By
Himanshu chib
2023A1R046
6th Sem
Computer Science & Engineering
Model Institute of Engineering & Technology (Autonomous)
(Permanently Affiliated to the University of Jammu, Accredited by NAAC with “A” Grade)
Jammu, India
2025-26
Assignment: COM-503
ASSIGNMENT
Subject Code: Software Engineering (COM-603)
Due Date: 31-03-2026
Question Course Blooms’ Level Maximum Marks
Number Outcomes Marks Obtain
Q1 CO4 3-6 10
Q2 CO5 3-6 10
Total Marks 20
Faculty Signature
Email: [Link]@[Link]
Assignment Objectives: The assignment objectives in Software Engineering are designed to help
students gain both theoretical knowledge and practical experience in building high-quality
software systems. These objectives ensure that learners not only understand the fundamental
principles of software development but also apply them in solving real-world problems.
Assignment Instructions:
1. To be done in groups: Group Size: 4-6 students
2. Assessment Rubrics: The evaluation will be done as per rubrics.
3. Submission Method: All the students will submit their individual hard copy of assignment and
upload the same on Google Classroom & CAMU LMS on or before the Due date. No late
submissions will be considered for the evaluation.
Group 7: Vidhi Chib (2023A1R041), Aman Sharma (2023A1R042), Vidant Sharma (2023A1R043), Radhey Kalra
(2023A1R044), Varun Sharma (2023A1R045), Himanshu Chib (2023A1R046)
Q. No. Question BL CO Marks Total
Marks
Case Study (Test-Driven Development): A team is
developing a Chat Application. Explain how Test-
Driven Development (TDD) can be applied to build the 4 CO4 10 10
1 “Send Message” feature. Provide a sample unit test and
code snippet.
Describe Coding Practices and Standards. Prepare a
checklist for best coding practices in developing an 5 CO5 10 10
2 Online Shopping Cart.
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
Q1) Case Study (Test-Driven Development): A team is developing a Chat Application. Explain how Test-
Driven Development (TDD) can be applied to build the “Send Message” feature. Provide a sample unit test and
code snippet.
1. Introduction
Test-Driven Development (TDD) is a software development methodology in which test cases are
written before writing the actual code. It ensures that the software meets requirements and reduces
defects early in development. TDD follows a cyclic process known as:
Red → Green → Refactor
• Red: Write a test case that fails
• Green: Write code to make the test pass
• Refactor: Improve the code without affecting functionality
2. Application of TDD to “Send Message” Feature
In a chat application, the “Send Message” feature allows a user to send messages to another user.
TDD can be applied to develop this feature systematically.
Step 1: Requirement Analysis
The expected behavior of the feature:
• User should be able to send a message
• Message should not be empty
• Message should be stored or delivered
• System should return a confirmation
Step 2: Writing Unit Tests (Red Phase)
Before writing the actual implementation, test cases are created to define expected behavior.
import unittest
from chat import ChatService
class TestChatService([Link]):
def test_send_valid_message(self):
chat = ChatService()
result = chat.send_message("User1", "Hello")
[Link](result, "Message sent")
def test_send_empty_message(self):
chat = ChatService()
result = chat.send_message("User1", "")
[Link](result, "Message cannot be empty")
if __name__ == "__main__":
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
[Link]()
At this stage, the tests will fail because the functionality is not yet implemented.
Step 3: Implementing Code (Green Phase)
Now, minimal code is written to pass the test cases.
class ChatService:
def send_message(self, user, message):
if message == "":
return "Message cannot be empty"
self.store_message(user, message)
return "Message sent"
def store_message(self, user, message):
print(f"{user}: {message}")
Step 4: Testing and Validation
The test cases are executed again:
• If tests pass → feature works correctly
• If tests fail → code is modified accordingly
Step 5: Refactoring
After successful testing:
• Code structure is improved
• Additional features like timestamps, database storage, and message IDs can be added
• Performance and readability are enhanced without changing functionality
3. Description of Code
• The ChatService class manages message operations.
• The send_message() method:
o Validates whether the message is empty
o Calls the storage function
o Returns appropriate response
• The store_message() method simulates saving the message.
• Unit tests ensure both valid and invalid scenarios are handled properly.
4. Advantages of TDD in This Case
• Ensures correct functionality before implementation
• Reduces bugs and errors
• Improves code quality and maintainability
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
• Provides clear documentation through test cases
5. Conclusion
By applying TDD, the “Send Message” feature is developed in a structured and reliable manner. It
ensures that all requirements are tested in advance, leading to robust and maintainable software.
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
Q2) Describe Coding Practices and Standards. Prepare a checklist for best coding practices in developing an Online
Shopping Cart.
Coding Practices and Standards
1. Introduction
Coding practices and standards are a set of guidelines that developers follow to write clean, efficient, secure, and
maintainable code. These practices ensure consistency across the system and reduce errors during development.
In real-world applications such as an online shopping cart, poor coding practices can lead to serious issues like
incorrect billing, security vulnerabilities, and system failures. Therefore, following proper coding standards is essential
for building reliable software.
2. Key Coding Practices and Standards
1. Code Readability and Naming Conventions
Code should be easy to read and understand.
• Use meaningful names such as addItemToCart() instead of func1()
• Follow consistent naming styles (camelCase, PascalCase)
• Maintain proper indentation and formatting
In a shopping cart, clear naming helps developers easily understand operations like adding, removing, or updating
items.
2. Modularity and Reusability
• Break code into small, reusable functions
• Each function should perform a single task (Single Responsibility Principle)
• Avoid duplication using reusable components
Example: Separate functions like addItem(), removeItem(), and calculateTotal() improve maintainability.
3. Input Validation
• Validate all user inputs before processing
• Ensure product ID is valid and quantity is within limits
This prevents issues like adding invalid products or negative quantities to the cart.
4. Error Handling
• Handle exceptions using proper mechanisms (try-catch)
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
• Provide meaningful error messages
Example: Display messages like “Product out of stock” or “Invalid quantity” instead of system failure.
5. Security Practices
• Sanitize inputs to prevent SQL Injection and Cross-Site Scripting (XSS)
• Use authentication and authorization for user access
• Encrypt sensitive data like payment details
This is critical in shopping carts where financial transactions are involved.
6. Performance Optimization
• Use efficient algorithms and data structures
• Minimize database queries
• Optimize loading time
This ensures fast cart updates and smooth checkout experience.
7. Documentation and Comments
• Write comments for complex logic
• Maintain proper documentation for functions and modules
This helps developers understand and maintain the system easily.
8. Testing
• Write unit tests for cart operations
• Test edge cases such as empty cart or maximum quantity
This ensures reliability under different conditions.
3. Checklist for Best Coding Practices in Online Shopping Cart
General Coding Standards
• Use meaningful variable and function names (e.g., addToCart, removeFromCart)
• Follow consistent coding style and indentation
• Avoid hardcoding values; use constants or configuration files
Core Functionality
• Add item to cart works correctly
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
• Remove item from cart works correctly
• Update item quantity dynamically
• Calculate total price including taxes and discounts accurately
• Handle empty cart scenario properly
Input Validation
• Validate product ID before adding to cart
• Ensure quantity is positive and within stock limits
• Prevent duplicate or invalid entries
Error Handling
• Handle out-of-stock products with proper message
• Handle invalid inputs without crashing
• Manage server or database failures gracefully
Security
• Sanitize all user inputs to prevent SQL Injection and XSS
• Implement user authentication before accessing cart
• Secure payment processing using trusted APIs
• Protect sensitive data using encryption
Performance
• Optimize database queries for cart operations
• Reduce unnecessary computations
• Use caching for frequently accessed data (e.g., product details)
Maintainability
• Use modular design (separate business logic and UI)
• Follow object-oriented principles
• Keep code simple and avoid unnecessary complexity
Testing
• Unit test for add, remove, and update operations
• Test edge cases (empty cart, maximum quantity, invalid inputs)
• Perform integration testing with payment system
User Experience
• Update cart instantly after user action
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
• Display total price clearly
• Provide confirmation before checkout
• Show error and success messages clearly
4. Conclusion
Following proper coding practices and standards is essential for developing a secure, efficient, and maintainable
online shopping cart system. A well-defined checklist ensures that all critical aspects such as functionality, security,
performance, and user experience are properly implemented, resulting in reliable and high-quality software.
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
Model Institute of Engineering and Technology (Autonomous), Jammu
Assignment: COM-503
Model Institute of Engineering and Technology (Autonomous), Jammu