Skip to main content
We welcome contributions to improve the Currency Converter! This guide will help you set up your development environment and understand the contribution workflow.

Development Setup

1
Clone the repository
2
git clone <repository-url>
cd source
3
Verify Java installation
4
Ensure you have JDK 17 or higher:
5
java -version
javac -version
6
Verify dependencies
7
Check that Gson library is present:
8
ls -lh lib/gson-2.10.1.jar
9
Compile and test
10
Compile the project to ensure everything works:
11
javac -cp "lib/gson-2.10.1.jar" -d out src/lad/com/alura/conversormoneda/**/*.java
java -cp "out:lib/gson-2.10.1.jar" lad.com.alura.conversormoneda.controladores.ConversorApp

Code Style Guidelines

Based on the existing codebase, follow these conventions:

Package Naming

  • Use lowercase: lad.com.alura.conversormoneda
  • Organize by layer: controladores, modelos, vista

Class Naming

  • PascalCase for classes: ConversorApp, ConsultaMoneda
  • Descriptive names that reflect purpose
  • Spanish variable names (project convention): monedaBase, cantidad, resultado

Code Organization

// 1. Package declaration
package lad.com.alura.conversormoneda.modelos;

// 2. Imports (grouped)
import java.time.LocalDateTime;
import java.util.ArrayList;

// 3. Class declaration
public class ClassName {
    // Fields
    // Constructors
    // Methods
}

Indentation and Formatting

  • Indentation: 4 spaces (no tabs)
  • Braces: Opening brace on same line
  • Spacing: Space after keywords (if, for, while)

Modern Java Features

The codebase uses modern Java features:
  • Records: For immutable data classes (see RegistroConversion.java:6)
  • Text blocks: For multi-line strings (see Conversor.java:4-18)
  • Switch expressions: With yield keyword (see ConversorApp.java:50-76)
  • Lambda expressions: For stream operations (see ConversorApp.java:37)
When adding new features, prefer modern Java idioms over legacy patterns.

Adding New Currency Pairs

To add support for additional currency conversions:
1
Update the menu
2
Edit src/lad/com/alura/conversormoneda/vista/Conversor.java:4-18
3
Add new menu options:
4
public static void eleccionUserMenu() {
    System.out.print("""
            Sea bienvenido/a al Conversor de Moneda =]
            
            ==================================================
            1) Dólar           =>> Peso argentino
            2) Peso argentino  =>> Dólar
            // ... existing options ...
            9) Dólar           =>> Euro  // New option
            10) Euro           =>> Dólar // New option
            ==================================================
            Elija una opción válida:
            """);
}
5
Add switch case logic
6
Edit src/lad/com/alura/conversormoneda/controladores/ConversorApp.java:50-76
7
Add new cases to the switch expression:
8
objetivo = switch (opcion) {
    // ... existing cases ...
    case 9 -> {
        base = "USD";
        yield "EUR";
    }
    case 10 -> {
        base = "EUR";
        yield "USD";
    }
    default -> objetivo;
};
9
Update conditional check
10
Edit src/lad/com/alura/conversormoneda/controladores/ConversorApp.java:43
11
Update the range check to include new options:
12
if (opcion >= 1 && opcion <= 10) { // Updated from 6 to 10
    // ...
}
13
Update exit option
14
If adding multiple options, update the exit option number:
15
if (opcion == 11) { // Updated from 8 to 11
    System.out.println("Gracias por usar el conversor.");
    break;
}
16
Similarly, update the history option number if needed.
The ConsultaMoneda class (see ConsultaMoneda.java:14) already supports any valid currency pair through the ExchangeRate-API. You only need to update the menu and switch logic.

Testing Conversions

Before submitting changes, test your modifications:
1
Compile with changes
2
javac -cp "lib/gson-2.10.1.jar" -d out src/lad/com/alura/conversormoneda/**/*.java
3
Run the application
4
java -cp "out:lib/gson-2.10.1.jar" lad.com.alura.conversormoneda.controladores.ConversorApp
5
Test each new currency pair
6
  • Select your new menu option
  • Enter a test amount (e.g., 100)
  • Verify the conversion returns a reasonable result
  • Check that the conversion appears in history (option 7)
  • 7
    Test edge cases
    8
  • Enter invalid menu options
  • Enter zero or negative amounts
  • Test with very large numbers
  • Verify error handling for API failures
  • Submitting Changes

    1
    Create a feature branch
    2
    git checkout -b feature/add-eur-support
    
    3
    Make your changes
    4
    Edit the necessary files following the code style guidelines.
    5
    Test thoroughly
    6
    Run the application and test all functionality.
    7
    Commit your changes
    8
    git add .
    git commit -m "Add EUR/USD currency pair support"
    
    9
    Push to repository
    10
    git push origin feature/add-eur-support
    
    11
    Create a pull request
    12
    Submit a pull request with:
    13
  • Clear description of changes
  • List of currency pairs added
  • Screenshots or test results
  • Enhancement Ideas

    Consider these potential improvements:

    Code Enhancements

    • Extract API key to configuration file or environment variable
    • Add input validation for amounts
    • Implement error handling for network failures
    • Add unit tests for ConsultaMoneda class
    • Support custom currency pair input

    Feature Additions

    • Save history to file
    • Display historical trends
    • Add currency symbols
    • Support batch conversions
    • Add favorite currency pairs

    Architecture Improvements

    • Separate concerns more clearly
    • Add configuration management
    • Implement dependency injection
    • Add logging framework
    • Migrate to Maven/Gradle for dependency management
    Start with small, focused changes. It’s easier to review and merge smaller pull requests.

    Getting Help

    If you encounter issues:
    • Review the Building guide for compilation help
    • Check the Dependencies page for library information
    • Examine the existing code for examples
    • Test with the working currency pairs first

    Code Review Process

    Pull requests will be reviewed for:
    • Functionality: Does it work as intended?
    • Code style: Follows existing conventions?
    • Testing: Has it been tested thoroughly?
    • Documentation: Are comments clear and helpful?
    • Compatibility: Works with JDK 17+?
    Thank you for contributing to the Currency Converter project!

    Build docs developers (and LLMs) love