IOP Support for Python (Experimental)

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.

You might also like...
My qtile config with a fresh-looking bar and pywal support

QtileConfig My qtile config with a fresh-looking bar and pywal support. Note: This is my first rice and first github repo. Please excuse my poor codin

You can easily send campaigns, e-marketing have actually account using cash will thank you for using our tools, and you can support our Vodafone Cash +201090788026

*** Welcome User Sorry I Mean Hello Brother ✓ Devolper and Design : Mokhtar Abdelkreem ========================================== You Can Follow Us O

Irrigation Component V4 providing support for a custom card
Irrigation Component V4 providing support for a custom card

Irrigation Component V4 This release sees the delivery of a custom card https://github.com/petergridge/irrigation_card to render the program options s

Library support get vocabulary from MEM

Features: Support scraping the courses in MEM to take the vocabulary Translate the words to your own language Get the IPA for the English course Insta

Kellogg bad | Union good | Support strike funds

KelloggBot Credit to SeanDaBlack for the basis of the script. req.py is selenium python bot. sc.js is a the base of the ios shortcut [COMING SOON] Set

Custom Weapons 3 attribute support for Custom Weapons X

CW3toX Allows use of Custom Weapons 3 attributes in Custom Weapons X. Requiremen

Wordler - A program to support you to solve the wordle puzzles

solve wordle (https://www.powerlanguage.co.uk/wordle) A program to support you t

HatAsm - a HatSploit native powerful assembler and disassembler that provides support for all common architectures

HatAsm - a HatSploit native powerful assembler and disassembler that provides support for all common architectures.

[x]it! support for working with todo and check list files in Sublime Text
[x]it! support for working with todo and check list files in Sublime Text

[x]it! for Sublime Text This Sublime Package provides syntax-highlighting, shortcuts, and auto-completions for [x]it! files. Features Syntax highlight

Owner
null
Acesse seus investimentos da NuInvest pelo Python (Experimental)

Acesse seus investimentos da NuInvest pelo Python (Experimental)

André Roggeri Campos 5 Dec 6, 2022
Experimental proxy for dumping the unencrypted packet data from Brawl Stars (WIP)

Brawl Stars Proxy Experimental proxy for version 39.99 of Brawl Stars. It allows you to capture the packets being sent between the Brawl Stars client

null 4 Oct 29, 2021
Verification of Monty Hall problem by experimental simulation.

Verification of Monty Hall problem by experimental simulation. |中文|English| In the process of learning causal inference, I learned about the Monty Hal

云端听茗 1 Nov 22, 2022
Webcash is an experimental e-cash (electronic cash)

Webcash Webcash is an experimental new electronic cash ("e-cash") that enables decentralized and instant payments to anyone, anywhere in the world. Us

Mark Friedenbach 0 Feb 26, 2022
pgvector support for Python

pgvector-python pgvector support for Python Great for online recommendations ?? Supports Django, SQLAlchemy, Psycopg 2, Psycopg 3, and asyncpg Install

Andrew Kane 37 Dec 20, 2022
Null safe support for Python

Null Safe Python Null safe support for Python. Installation pip install nullsafe Quick Start Dummy Class class Dummy: pass Normal Python code: o =

Paaksing 13 Nov 17, 2022
That is a example of a Book app on Python, made with support of all JS libraries on React framework

React+Python Books App You can use this repository whenever you want Used for a video Create the database: python -m dbutils Start the web server: pyt

Koma Human 1 Apr 20, 2022
An open letter in support of Richard Matthew Stallman being reinstated by the Free Software Foundation

An open letter in support of RMS. To sign, click here and name the file <username>.yaml (replace <username> with your name) with the following content

null 2.4k Jan 7, 2023
A repository containing an introduction to Panel made to be support videos and talks.

?? Awesome Panel - Introduction to Panel THIS REPO IS WORK IN PROGRESS. PRE-ALPHA Panel is a very powerful framework for exploratory data analysis and

Marc Skov Madsen 51 Nov 17, 2022
No more support server flooding with questions about unsupported hosting.

No more support server flooding with questions about unsupported hosting.

null 3 Aug 9, 2021