Git Product home page Git Product logo

oo.js's Introduction

OO.js

OO.js is a tool that suggests Object-Oriented design for a JavaScript code. This repository is the implementation of the paper "OO.js: Object-Oriented Design Suggestions for JavaScript Programs"

Below is the list of available artifacts:

  • The source code is in the src folder. The code is writen in TypeScript.
  • The code is not thoroghly unit tested, but some tests were writen and are available in the test folder. It is possible that some tests are outdated. You can run the tests using npm test command after the installation is complete.
  • The the input and output of the experiments done are in hte experiment folder. The output are in CSV format.
  • A detailed analysis of the results can be found in this spreadsheet.

Installation

Node.js and TypeScript is required to run the program. It is tested on a Windows 10 machine. However, it should work on any system that supports the required version of Node.

Step 1: Install the system requirements

Install Node v14+ from here: https://nodejs.dev/

When complete, open a terminal and install TypeScript and TS Node. Run the following commands TypeScript: Run the following command in a command line tool

npm install -g typescript
npm install -g ts-node

Step 2: Clone the repository

Open a terminal in a location where you want to install the program and run the following command:

git clone https://github.com/mohayemin/OO.js

If you do not have git or do not want to clone the repository, you can download the package directly from here: https://github.com/mohayemin/OO.js/archive/main.zip. Unzip the package in your desired location.

Step 3: Install dependencies

Move to or open your terminal in the reporsitory root directory (the directory where the README.md file is located) and install the dependencies:

npm install

Running the program

Run using configuration file

There is an input.json file at the repository root. This file contains the inputs for the program. Below are the rescriptions of the parameters.

  • files (required): A list of string. Specifies the input files for which design should be suggested. Each individual item on the list are considered separate programs. It is an array that takes a list of file or folder paths. It accepts both relative and absolute path. If the path is a directory, it will process all files in that directory and all recursive subdirectories. That means if you want to process a multi-file program, you can just put the files in a directory.
  • outputDirectory (optional): The results are printed in hte console. You can additionally generate the results as CSV in the outputDirectory.
  • closenessMetric (optional, default=class): one of class or method.
  • cohesionRangeAlgorithm: (optional, default=zeroToOne): one of zeroToOne or fromValues

Use the command npm start to run the program with the configurations in the input.json file.

Quick run

You can also quick run the program with default configuration. Just add the file/folder names as command line arguments. For example:

npm start code-file-1.js code-file2.js code-folder-1

This command is equivalent to runing the program with the following config file:

{
    "files": [
        "./code-file-1.js",
        "./code-file2.js",
        "./code-folder-1"
    ],
}

Sample Input/Output

sample-input.js

function A() {
    B()
    C()
    D()
}

function B() {
    D();
}

function C() {
    D();
}

function D() {
    G();
}

function e() {
    f();
    G();
}

function f() {
    G()
}

function G() {
}

Command

npm start .\sample-input.js

Output

A B C D G E F : +0.00 (+1.00 -1.00) : 7
A B C D G E$F : +0.09 (+1.00 -0.91) : 4
A$D B C G E$F : +0.07 (+1.00 -0.93) : 5
A$D B C G$E$F : +0.03 (+1.00 -0.97) : 6
A$D$B C G$E$F : +0.22 (+1.00 -0.78) : 3
A$D$B$C G$E$F : +0.53 (+0.92 -0.39) : 1
A$D$B$C$G$E$F : +0.43 (+0.43 +0.00) : 2

oo.js's People

Contributors

mohayemin avatar

Stargazers

Minhaz Kamal avatar Md Sabbir Rahman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.