Skip to content

theRealZing/Liber-Abaci

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Liber-Abaci

An example web service that deals with Fibonacci sequence as a sample purpose.

##purpose of this repository This repository is being created as a sample of my design thinking, orgainization, and some programming. It isn't meant to break any new ground mathematically. The main purpose is to create a simple API and flesh it out a bit, as if it were being done for commercial use - except the licensing of this exercise may not be appropriate for a commercial venture.

history

"Liber Abaci", or Book of Calculation was written in 1202 by Leonardo Pisano Bigollo, also known as Leonardo Bonacci or more popularly just Fibonacci. This book is one way that the famous sequence was introduced to Europe. (reference: wikipedia "Fibonacci")

Note that the sequence as introduced only works on positive integers (including zero) and is usually thought of that way; but mathematically it can operate on negative numbers as well.

Another branch from the original is to specify any two starting integers and then following the same basic algorithm. I probably won't venture there.

##the stack At the outset, the entire stack is flexible and subject to change. Here are my initial thoughts:

  • python is a great choice to actually generate the Fibonacci sequence numbers since it has built-in support for very large integers.
  • Originally I toyed with doing the API in Node.js/express, However, since it would also be instructive to use python for the API, I chose to use python along with the "micro-framework" flask for defining the API routes.

##the vision ###more than just Fibonacci sequences Not only provide something that can generate Fibonacci sequences, but also values in the sequence, and well as floor() and ceiling functions which provide the sequence below or above a non-Fibonacci number. ###built-in functional and performance comparisons of library vs library! The user can ask for functional tests of the Fibonacci libraries as well as comparative performance measurements. ###dynamic code loading allow easy addition of new libraries! The Fibonacci libraries are dynamically loaded, which means that a person can develop a new library and add it to the mix without changing any API code. ###API health check and status call The API also tracks status on the calls used and can report on that through the status API. ###running server is available for your use! A working server is running and available on the internet. I'll provide the web address in my email response.

the API

The API responses are all wrapped in JSON, ready for ingestion by some future enterprise bus or client front-end.

There are three Fibonacci libraries available to use through the API, as well as compare results and performance of. These are:

### LoopFib Uses a for-loop and simple list storage for performance improvement of subsequent calls. Produces accurate large numbers. ### TableFib Uses limited recursion along with simple list storage to avoid deep recursion. Fairly fast but can still get itself into stack trouble with large sequences. ### GoldFib Uses an approximation of the golden ratio to directly estimate any given number in the Fibonacci sequence. However, since it is an approximation method, the accuracy drops off as n increases. Fastest at calculating a single number out of sequence, but otherwise isn't that great due to rounding issues.

My liber-abaci resource will use HTTP methods as follows:

HTTP MethodURIAction
GEThttp://[hostname]/apiListRetrieve list of api calls
GEThttp://[hostname]/statusHealth check and operational stats
GEThttp://[hostname]/fibSequence/[method]/[n]Retrieve a Fibonacci sequence of length n using the specified method
GEThttp://[hostname]/fibValue/[method]/[n]Retrieve the value of the Fibonacci sequence at step n using the specified method
GEThttp://[hostname]/fibFloor/[method]/[n]Retrieve the values of the Fibonacci sequence lower than n
GEThttp://[hostname]/fibCeiling/[method]/[n]Retrieve the values of the Fibonacci sequence higher than n
GEThttp://[hostname]/userMethods/List the Fibonacci libraries available for use. Create your own Fibonacci routines and compare it with mine!
GEThttp://[hostname]/test/[method1,method2]/Compare two fibonacci methods for generating a sequence of n items on several tests, including performance runs

installation

See the separate install instructions and API examples

a word on testing

  1. Unit tests were written for most of the classes
  2. Most of the classes have a 'main' with examples of how to invoke the class and also represents a level of functional testing
  3. The application API itself allows for user-driven functional testing of the Fibonacci libraries
  4. Additional functional tests (for example, for regression testing) could be automated using either curl or something fancier like jsonium. I didn't write any automation around other functional testing that I did.

About

an example web service that deals with Fibonacci sequence as a sample purpose.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages