IOP Support for Python (Experimental)

Related tags

MiscellaneousTAGS-IOP
Overview

TAGS

Experimental IOP Framework for Python

WARNING: Currently, this project has NO EXCEPTION HANDLING. USE AT YOUR OWN RISK!


I. Introduction to Interface Oriented Programming

I believe that each piece of code shall be reused as much as possible, so I came up with this paradigm called "Interface Oriented Programming" IOP), as well as its experimental implementation in Python.

The fundamental idea of "Interface Oriented Programming" (IOP) is that one class should be able to be reused as multiple interfaces without making changes to the class itself as long as configuration for such operation is presented, even if there were no intentions to make that possible in the designing of the class.

Here, a "class" is considered as definition of a functional entity, containing declarations and implementations for its methods and variables; whereas an "interface" is considered just a specification, containing only declarations but no implementations.

An interface instance is an instance of a class mapped to an interface with certain configuration, specifying how certain methods and variables in the class correspond to that in the interface. An interface instance can be easily converted to an instance of another interface, as long as configuration for such conversion is presented.

One of the most powerful features of IOP is that new classes, as well as functions can be defined on interface types, and new interfaces can be defined on existing interfaces as well. This allows the types of function arguments, as well as class or interface variables to vary. For example, if the variables of a class are of interface types, the the class may be instantiated using any class / interface instances as long as those instances offer configurations using which they may be used as instances of the interfaces required for the class instantiation.


II. Usages

1. Requirements for class definitions

TAGS does not require you to change the way you code very much, but you should include a "GET_variableName (self): return self.variableName" method and a "SET_variableName (self, obj): self.variableName = obj" method for each variable in your class if you wish that class to be used as an interface (of course, you can write code to generate those functions automatically). Otherwise, you will not be able to get and set variables through interface normally.


2. Importing TAGS

To import TAGS, simply import "interface.py"


3. Writing Interface Configurations

Interface configurations are written in JSON format. Basically, a JSON configuration of an interface consists of two parts: a specification that specifies what methods and varables the interface should have ("interfaceSpecification" in json files) and an array of configurations that specifies how the interface may be converted into other interfaces (tagConfigurations in json files).

To learn more about how to write interface configurations, take a look at "Koala_INTERFACE.json", the example file for configurating interfaces.


Writing Class Configurations

To use a class as a specific interface, you do not need to change the definition of the class (after you have written/generated the GET and SET methods). However, you do need to specify how the class can be mapped to the interface by writing a configuration in JSON format.

To learn more about how to write class configurations, take a look at "Koala_Binder.json". It should be noticed that the name of the methods and variables in the json file must correspond to those in the class definition.


Using the "interface" module

The interface module contains only the "Interface" class, which contains several sub-classes. Among all these classes, what you should use are the "Interface" class and the "Interface.Object" class.

To load an interface, as well as its configurations that specifies how it can be converted into other interfaces from your JSON configuration, simply initiate the interface using its "init" method, with the file name of your json file as the argument.

To load the configuration for mapping a class to an instance, first create a configuration object using "Interface.Object.Configuration()", then call the "LoadFromFile" method of that object, with the file name of your json file as the argument.

To initiate an interface instance using a class instance and an interface, simply use the "Interfacialize" method of that interface, with your class instance as the first argument and the configuration object containing the configuration for mapping the class to the interface as the second.

Interface instances correspond to instances of the "Interface.Object" class in the module.To convert an interface instance to instance of another interface, use the "As" method of the instance, with the interface to which you wish the instance to be converted as the argument. This method will return an instance of the interface to which you wish the interface to be converted, and will retain the original instance. However, the newly created interface instance and the originial one will have the same class instance attached. This means changing the properties of the class instance of one interface instance will result in changes to that of the other interface instance.

To call a method of an interface instance, use the "Call" method of that instance, with the method name you wish to call as the first argument and a dictionary of the arguments that method takes in as the second.

To Get a variable of an interface instance, use the "Get" method of that instance, with the variable name you wish to get as the argument.

To Set a variable of an interface instance, use the "Set" method of that instance, with the variable name you wish to set as the first argument, and the value you wish to set as the second.

For more information, check out "example.py".


III. Friendly Reminders

1. About Reliability

This project, named "TAGS", is an EXPERIMENTAL IOP framework for Python. The word "EXPERIMENTAL" means there is currently NO EXCEPTION HANDLING and that anything might go wrong in anyway if you use it incorrectly, but if you write your code, as well as your json configurations unerringly, it should work as expected.

Of course, as the idea and the implementations of IOP develops, new features such as exception handling will be added.

2. Performance

The performance of this framework depends on how you use it. Type conversions of the framework are done using the "eval" function, so if you use the framework to call simple functions in a high frequency, the performance may drop dramatically. However, if you have complicated functions and classes that naturally take a lot of time to be called or instantiated (for example, game development), cost of performance for using TAGS should be insignificant.

We are building an open database of COVID-19 cases with chest X-ray or CT images.

🛑 Note: please do not claim diagnostic performance of a model without a clinical study! This is not a kaggle competition dataset. Please read this pa

Joseph Paul Cohen 2.9k Dec 30, 2022
mypy plugin for PynamoDB

pynamodb-mypy A plugin for mypy which gives it deeper understanding of PynamoDB (beyond what's possible through type stubs). Usage Add it to the plugi

1 Oct 21, 2022
Tracing and Observability with OpenFaaS

Tracing and Observability with OpenFaaS Today we will walk through how to add OpenTracing or OpenTelemetry with Grafana's Tempo. For this walk-through

Lucas Roesler 8 Nov 17, 2022
DOP-Tuning(Domain-Oriented Prefix-tuning model)

DOP-Tuning DOP-Tuning(Domain-Oriented Prefix-tuning model)代码基于Prefix-Tuning改进. Files ├── seq2seq # Code for encoder-decoder arch

Andrew Zeng 5 Nov 02, 2022
Pylexa - Artificial Assistant made with Python

Pylexa - Artificial Assistant made with Python Alexa is a famous artificial assistant used massively across the world. It is a substitute of Alexa whi

\_PROTIK_/ 4 Nov 03, 2021
Tutorial on Tempo, Beat and Downbeat estimation

Tempo, Beat and Downbeat Estimation By Matthew E. P. Davies, Sebastian Böck and Magdalena Fuentes Resources and Jupyter Book for the ISMIR 2021 tutori

49 Nov 06, 2022
This is a library which aiming to save all my code about cpp. It will help me to code conveniently.

This is a library which aiming to save all my code about cpp. It will help me to code conveniently.

Paul Leo 21 Dec 06, 2021
A script that convert WiiU BotW mods to Switch

UltimateBoTWConverter A script that convert WiiU BotW mods to Switch. It uses every resource I could find under the sun that allows for conversion, wi

11 Nov 08, 2022
SciPy library main repository

SciPy SciPy (pronounced "Sigh Pie") is an open-source software for mathematics, science, and engineering. It includes modules for statistics, optimiza

SciPy 10.7k Jan 09, 2023
Repo created for the purpose of adding any kind of programs and projects

Programs and Project Repository A repository for adding programs and projects of any kind starting from beginners level to expert ones Contributing to

Unicorn Dev Community 3 Nov 02, 2022
The docker-based Open edX distribution designed for peace of mind

Tutor: the docker-based Open edX distribution designed for peace of mind Tutor is a docker-based Open edX distribution, both for production and local

Overhang.IO 696 Dec 31, 2022
An addin for Autodesk Fusion 360 that lets you view your design in a Looking Glass Portrait 3D display

An addin for Autodesk Fusion 360 that lets you view your design in a Looking Glass Portrait 3D display

Brian Peiris 12 Nov 02, 2022
Small C-like language compiler for the Uxn assembly language

Pyuxncle is a single-pass compiler for a small subset of C (albeit without the std library). This compiler targets Uxntal, the assembly language of the Uxn virtual computer. The output Uxntal is not

CPunch 13 Jun 28, 2022
A simple app that helps to train quick calculations.

qtcounter A simple app that helps to train quick calculations. Usage Manual Clone the repo in a folder using git clone https://github.com/Froloket64/q

0 Nov 27, 2021
Materials for the Introduction in Python , Linux , Git and Github

This repository contains all the materials of the presentation on the introduction of python, linux, git and Github.

AMMI 3 Aug 28, 2022
Fisherman is a free open source fishing bot written in python.

Fisherman is a free open source fishing bot written in python.

Pure | Cody 33 Jan 29, 2022
Uproot - A script to bring deeply nested files or directories to the surface

UPROOT Bring deeply nested files or folders to the surface Uproot helps convert

Ted 2 Jan 15, 2022
This program generates automatically new folders containing old version of program

Automated Folder Versions Generator by Sergiy Grimoldi - V.0.0.2 This program generates automatically new folders containing old version of something

Sergiy Grimoldi 1 Dec 23, 2021
A program to calculate the are of a triangle. made with Python.

Area-Calculator What is Area-Calculator? Area-Calculator is a program to find out the area of a triangle easily. fully made with Python. Needed a pyth

Chandula Janith 0 Nov 27, 2021
Python-Course-V1 - This Repo contains a series of Python Jupyter Notebooks and assignments

This Repo contains a series of Python Jupyter Notebooks and assignments. The assignments are taken from Python Crash Course book by Eric Matthes.

2 Nov 15, 2022