This project focuses on the validation and identification of credit card types from various data sources. The primary goal is to process credit card data, ensuring the validity of credit card numbers and correctly categorizing them into types such as Visa, MasterCard, American Express, and Discover.
- Primary Objective: Develop a system to validate credit card numbers and identify the card issuer from a given dataset.
- Secondary Objective: Implement a design that is adaptable and extensible for future additions of credit card classes and types.
To achieve these objectives, the following design patterns are employed:
The Strategy Pattern is a behavioral design pattern that enables an object to change its behavior at runtime. It encapsulates algorithms in separate classes following a common interface strategy.
- Interfaces:
Reader
: Handles reading of different file formats.Writer
: Manages writing data to various file formats.CreditCardHandler
: Determines the type of credit card.
- This pattern allows the application to adapt its processing logic depending on the file format and credit card type, enhancing flexibility and maintainability.
This pattern creates a chain of receiver objects for a request. This pattern decouples sender and receiver of a request based on the type of request.
- Main Credit Card Handler: Acts as a central point for processing files, delegating the validation task to specific credit card handlers (Visa, MasterCard, etc.).
- Each handler in the chain is responsible for certain validation criteria, creating a scalable and robust validation mechanism.
- Advantages:
- Promotes decoupling of request processing.
- Enhances flexibility in changing the order and adding new handlers.
- Disadvantages:
- Complexity in debugging and tracking the processing path.
- Possibility of requests falling through without proper handling.
- Advantages:
- Increases flexibility in implementing various algorithms.
- Promotes code re-usability and modular architecture.
- Disadvantages:
- Requires clients to be aware of different strategies.
- Can lead to a proliferation of strategy classes.
- Launch
App.java
. - Input the paths for the input and output files, including their extensions.
- Execute the provided JUnit test cases to validate the functionality.