Giter VIP home page Giter VIP logo

aliensonearth's Introduction

AliensOnEarth

A console application that accepts Alien details and exports the same into a file of a certain format.

Please report any bugs or issues here.

Instructions for Installation:

Install Node.js
Install all dependencies
$ npm install

Instructions for Running the Application:

Run the application
$ node aliens
Run the application and generate a text file
$ node aliens --text
Run the application and generate a PDF file
$ node aliens --pdf

Note about the generated output files:

All generated files will go to the output directory
|-- aliens.js
|-- add-generator.js
|-- command-line-arguments.js
|-- update-command-line-arguments.js
|--	generators
|	|-- generate-pdf.js
|	|-- generate-text.js
|-- package.json
|-- alien-details.js
|-- output
|   |-- ALL GENERATED FILES WILL APPEAR HERE!

Instructions for writing plugins:

Writing new format generation plugin file-
  1. Create a <PLUGIN FILE NAME>.js file
  2. Write a function var generate<FORMAT NAME> = function(alienDetails, numberOfAliens), for example - var generatePdf = function(alienDetails, numberOfAliens)
  3. Export function using module.exports = generate<FORMAT NAME>, for example - module.exports = generatePdf;

For reference, see this!

For reference, alienDetails - is a JSON Object that contains all the alien details that have been accepted by the console application, with keys as specified by the alien-details.js file and the corresponding values are the accepted details store sequentially. An example, is as shown below

alienDetails = {
	'Code Name': ["Jar Jar Binks", "Jaba the Hutt"], 
	'Blood Colour': ["red", "green"], 
	'Number of Antennas': ["2", "0"], 
	'Number of Legs': ["2", "2"], 
	'Home Planet': ["Naboo", "Tattooine"]
};

Adding the generator for use-
$ node add-generator.js -f <FORMAT NAME> -p <FULL PATH TO PLUGIN FILE>
Once a format generation plugin has been added using the add-generator.js file, the corresponding command line argument to generate that format at runtime is --<FORMAT NAME>. As an example, for the generator generator-pdf.js, the command line argument is --pdf

Adding more parameters for alien details:

Add the parameter as a key-value pair to the alienDetails Javascript object in the alien-details.js file by the following specification - '<PARAMETER NAME>': []. For example, 'Number of Eyes: [].

aliensonearth's People

Contributors

kishore-narendran avatar

Stargazers

Aneesh Neelam avatar

Watchers

James Cloos avatar  avatar

aliensonearth's Issues

Too much dependency on the prompts for the application to work

If you look at the line https://github.com/kishore-narendran/AliensOnEarth/blob/master/aliens.js#L50 or https://github.com/kishore-narendran/AliensOnEarth/blob/master/aliens.js#L61, the prompts are governing what the attributes are going to be called.

If there is an error (such as a simple typo in the name of an attribute), the entire application would stop working since there is too much coupling between how the user is prompted to enter data and the actual alien attributes. This needs to change to such a way that the prompts are driven by a data source and not the other way around.

add-generator.js could be more modularized

The delegation of the addition of new plugins to a different unit is great. But the add-generator.js code could use a bit more of modularization. It may seem trivial, but the fundamentals of good-quality code include readability and easy maintenance. From that perspective, this new file can be improved.

Further segregation of code required

The aliens.js file is driving every aspect of the application, for instance, deciding alien attributes, prompting for the values for these attributes, deciding which format to use and even importing the required file and invoking the export. The code should be a little more modularized.

Remove code duplication

If you observe lines https://github.com/kishore-narendran/AliensOnEarth/blob/master/aliens.js#L50 and https://github.com/kishore-narendran/AliensOnEarth/blob/master/aliens.js#L61, they are the exact same lines of code. This is a bigger problem in this context because to do something as simple as add a new attribute during prompt, the change has to be done in two places.

This is similar to the issue mentioned here - #2 - but the effect of the duplication is different here.

User experience at the prompt

Consider this was a live system being used by real people. The menu that would be displayed to them would prompt asking using names such as noOfAntennas. The menu should present more human-friendly terms such as Number of Antennas.

No centralized point for managing data

If I wanted to add a new property for aliens, say number of eyes, there's no single point where I can just add it and get everything working as expected. I have to make changes in multiple points, including the plugins themselves. This coupling should be broken up.

Addition of a new plugin (generator) requires changes in the code for it to work

To add a new plugin, I see two steps would be required. One is to add it to the generators folder and the other is to add an entry in the command line arguments file (https://github.com/kishore-narendran/AliensOnEarth/blob/master/command-line-arguments.js).

The expectation we have is that by simply introducing the appropriate file for the plugin in the correct location will cause the system to automatically support the new plugin. No changes should be required anywhere in the codebase other than this.

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.