Monday, June 20, 2016

Demitri Muna, Languages 101 (.astronomy8)

Opinion: for a cross-platform user interface, use a web interface.

In python, you need to use a third party library to create a user interface.

MVC Design: Model * View * Controller

Model: the representation of the data you're working with (typically a database)
View: how you present your model data (e.g. a web page)
Controller: retrieves data from model and passes it to view for display (e.g. a python script)

Model doesn't care how data is viewed; View doesn't care how data is stored.

Flask & Django are python frameworks that employ MVC design.

Avoid PHP - it grossly violates MVC design.

Create maps, add markers and pan/zoom, with JavaScript library Leaflet:

JSON (JavaScript Object Notation) to exchange data with another program.  In python, "import json" and use json.dumps() & json.loads()

If you need a database, use only one of these two:
*PostgreSQL - must be installed on a server; can handle many users, easy support for indexing points on a sphere, e.g. cone searches (q3c)
*SQLite - already installed on your computer.  For your convenience.

* Object Relational Mapper (ORM) - sits between a database and objects/classes
* You interact with an ORM in an individual Session

* SQLAlchemy: Demitri, Brian C, ...
import sqlalchemy
... # create org and student objects
session.commit() # saves data

***Advice: Learn to write in an object-oriented coding style***

* APIs: Dan F-M, Tom R, Brian C, Demitri M, ...
* To let other people build their own applications on top of your data, you will need to design an API, e.g. using Flask, and host it on a server.  Example:
* In principle, the View can stay the same as the Model changes, but the Controller must change if the Model changes.
(The API can stay the same as the data format changes.)

* JavaScript visualization: D3.js is the premiere data visualization library for JavaScript.  Very low-level and therefore complicated.  

* Convert C/C++/Fortran to JavaScript:
e.g. CFITSIO conversion:

Question: How to figure out how new a computer needs to be to run a particular application?
Answer: everything discussed here can be run on a Raspberry Pi $30 computer... can get a free Windows license for same.

No comments:

Post a Comment