Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

This is a repository to modernizing a legacy software project written in Cobol using GitHub Copilot

License

NotificationsYou must be signed in to change notification settings

continuous-copilot/modernize-legacy-cobol-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This repo contains COBOL code for a simple accounting system. You can use GitHub Copilot to transform this code to a Node.js accounting system.

Note: Keep in mind GitHub Copilot is an AI pair programmer that helps you write code. It is not a code generator and is using generativemodels trained on public code. It may provide completions that are not perfect, safe, or otherwise suitable for production. Always review suggestionsand take a trust but verify approach.

Cobol to Node.js

Prerequisites

  • Basic understanding of programming concepts.
  • Basic understanding of the COBOL programming language.
  • GitHub Copilot or GitHub Copilot Chat installed in your IDE or GitHub Codespace.

Setup the development environment

Option 1: Use an IDE that supports GitHub Copilot

  • IDE options for both GitHub Copilot and Copilot Chat:
    • Visual Studio Code Visual Studio Code
    • Visual Studio Visual Studio
    • JetBrains IDE JetBrains IDE

For Visual Studio Code

  • Install the GitHub Copilot and GitHub Copilot Chat extensions for Visual Studio Code.
  • Install the COBOL extension for Visual Studio Code.

Option 2: Use a GitHub codespace

  • Create a new codespace in this repository.
    Codespace

  • The configuration for the codespace is already set up with the required extensions.

    • GitHub Copilot
    • GitHub Copilot Chat
    • COBOL
    • Markdown All in One
    • Mermaid Markdown
    • python

About the program

This COBOL program simulates an account management system. This program will involve multiple COBOL source files and perform various operations like crediting, debiting, viewing the balance, and even exiting the program. Here’s how you its structured:

  • Main Program (main.cob): The main program will handle the user interface and call subprograms for different operations.
  • Operations Program (operations.cob): This program will handle the actual operations like credit, debit, and view balance.
  • Data Storage Program (data.cob): This program will manage the storage of the account balance.

Steps to Compile and Run the Program

  • Option 1: Install COBOL compiler on MaCIf you don't already have a COBOL compiler, you'll need to install one. Common COBOL compiler is GnuCOBOL: An open-source COBOL compiler. To Install , use brew:
brew install gnucobol
  • Option 2: Open the terminal in the GitHub codespace or Ubuntu Linux system and run the following command to install the COBOL compiler:
sudo apt-get update&& \sudo apt-get install gnucobol

reference:gnucobol

  • Compile, link and create executable: Link the object files together to create the final executable:
cobc -x main.cob operations.cob data.cob -o accountsystem
  • Run the Program: Run the executable to start the account management system:
./accountsystem

Program Interaction Example

  • Program starts with user input menu
--------------------------------Account Management System1. View Balance2. Credit Account3. Debit Account4. Exit--------------------------------Enter your choice (1-4):
  • User Chooses to View Balance:
Current balance: 1000.00
  • User Chooses to Credit:
Enter credit amount:200.00Amount credited. New balance: 1200.00
  • User Chooses to Debit:
Enter debit amount:300.00Amount debited. New balance: 900.00
  • User Chooses to Exit:
Exiting the program. Goodbye!

Explanation

  • main.cob: This is the main interface where users select operations.
  • operations.cob: It handles specific operations such as viewing, crediting, and debiting the account balance.
  • data.cob: This program acts as a simple data storage, handling reading and writing of the balance.

This multi-file structure introduces modularity, making it easier to manage and extend the program. Each file has a clear responsibility, and the program flow is driven by user interaction.

Data flow

@workspace can you create a sequence diagram of the app showing the data flow of the app. Please create this in mermaid format so that I can render this in a markdown file.
sequenceDiagram    participant User    participant MainProgram    participant Operations    participant DataProgram    User->>MainProgram: Start Application    MainProgram->>User: Display Menu    User->>MainProgram: Select Option (1-4)        alt View Balance        MainProgram->>Operations: CALL 'Operations' USING 'TOTAL'        Operations->>DataProgram: CALL 'DataProgram' USING 'READ', FINAL-BALANCE        DataProgram-->>Operations: RETURN FINAL-BALANCE        Operations->>User: DISPLAY "Current balance: " FINAL-BALANCE    end        alt Credit Account        MainProgram->>Operations: CALL 'Operations' USING 'CREDIT'        Operations->>User: DISPLAY "Enter credit amount: "        User->>Operations: Enter Amount        Operations->>DataProgram: CALL 'DataProgram' USING 'READ', FINAL-BALANCE        DataProgram-->>Operations: RETURN FINAL-BALANCE        Operations->>Operations: ADD AMOUNT TO FINAL-BALANCE        Operations->>DataProgram: CALL 'DataProgram' USING 'WRITE', FINAL-BALANCE        DataProgram-->>Operations: RETURN        Operations->>User: DISPLAY "Amount credited. New balance: " FINAL-BALANCE    end        alt Debit Account        MainProgram->>Operations: CALL 'Operations' USING 'DEBIT'        Operations->>User: DISPLAY "Enter debit amount: "        User->>Operations: Enter Amount        Operations->>DataProgram: CALL 'DataProgram' USING 'READ', FINAL-BALANCE        DataProgram-->>Operations: RETURN FINAL-BALANCE        alt Sufficient Funds            Operations->>Operations: SUBTRACT AMOUNT FROM FINAL-BALANCE            Operations->>DataProgram: CALL 'DataProgram' USING 'WRITE', FINAL-BALANCE            DataProgram-->>Operations: RETURN            Operations->>User: DISPLAY "Amount debited. New balance: " FINAL-BALANCE        else Insufficient Funds            Operations->>User: DISPLAY "Insufficient funds for this debit."        end    end        alt Exit Application        MainProgram->>MainProgram: MOVE 'NO' TO CONTINUE-FLAG        MainProgram->>User: DISPLAY "Exiting the program. Goodbye!"    end
Loading

Generate a test plan

@workspace The current Cobol app has no tests. Can you please create a test plan of current business logic that I can use to validate with business stakeholders about the current implementation.Later I would like to use this test plan to create unit and integration tests in a node.js app. I am in the middle of transforming the current Cobol app to a node.js app.The test plan should include the following:1. Test Case ID2. Test Case Description3. Pre-conditions4. Test Steps5. Expected Result6. Actual Result7. Status (Pass/Fail)8. CommentsPlease create the test plan in a markdown table format. The test plan should cover all the business logic in the current Cobol app.

Note

You may still need follow up with another prompt to generate the markdown file format for the test plan.

Convert this to markdown syntax please to insert as a new file

Convert files using prompt engineering best practices

Create the Node.js project directory

mkdir node-accounting-appcd node-accounting-app

Use GitHub Copilot to convert the files iteratively

Convert main.cob to main.js

Convert operations.cob to operations.js

Convert data.cob to data.js

Let's link all node.js files to work together in one accounting application, and then initialize, install dependencies, and run the application.

Initialize a new Node.js project

npm init -y

Install the Node.js app

npm install

Run the Node.js app

node main.js

Generate unit and integration tests

@workspace I would like to create unit and integration tests cases form the test plan mentioned in#file:TESTPLAN.md file The node.js code is in node-accounting-app folder and I am looking to generate testsfor #file:operations.js file. Use a popular testing framework and also provide all the dependencies required to run the tests.

License

This project is licensed under the MIT License - see theLICENSE file for details.

About

This is a repository to modernizing a legacy software project written in Cobol using GitHub Copilot

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp