Tuesday, November 7, 2017

Dawo 0.0.5 Connector, version 1, inspirational ideas for learning.

Beginner Dart programmer sketching class, that allows objects to 
participate in #commonOperation, and connect to other objects there.
Project in early stage, a bunch of inspirational ideas, not meant
to be developed to production app. Learning process.
Structure and documents of Connector class:
/// * Usability: 7%
/// * Hist: hkl  10.9.2017  0.0.1  dawo/lib  connector.dart
#name:  connector ..is not nice. change to: ______ ??
Connector is in deeply planning state. pp -mission - chore work 
together in same sphere, and there must be something, that they 
have in common; abstraction layer, in which they must work together.
* Every #little operation is "connector-operation", and connector has
knowledge for all of them and can interact with them.
* Sending messages between objects. Stance, approach
* "Connector-operations" have access to certain up-level variables.
* Using GlobalOpClass might be too heavy.!!
* ADD IS-GLOBAL bool field to Operation-classes.
* Connector classes might have precedence in Mill-op.
Might trig some action in their connected sister-operations.
Find common interests, "I have been here".. follow-me, give-take
Other objects also handle things connected to this. So connector might
be just  a simple message (plea) mediator.
Global op does something
devNote: tracking begins.
//  ***********************************************************************
/*      connector:  very weak idea, how to accomplish this. 10 %
        Not much of this functionality is yet done.
        Name:   #connector is not the right one. Not nice.
        #clients: = app - mission's - chore's

* Get "service calls" from #members:  app - mission - chore; and 
solve them.
* Have rules of privilege for precedence of missions - chores.
* Give TO > mill commands, "work-orders".
* Should have access to class-buffers to seek data.
* Special language #dawolang, to force commands to certain shape.
* #baton : to carry only-one-can-have-at-a-same-time magic thing.
* 1. get command, handle parameters.
* 2. Check command against rules. Take - return - reject.
* 3. Full-fill command;  void obey(sender, receiver, baton, msg, flags)
* 4. Get answer, serve back.
* 5. Mark done.
* Questions:
* 1. Where do connector work?  Is it upper-level loop?
*    ..  or is it available all the time.  No need to wake it.
* 2. Where, how, and why is #connector invoked?
* 3. ?
* IDEA:  All (commands) might happen in #mill. ( an order processor system ).
* IDEA:  #Callback-like service calls.
* IDEA:  #serviceKey #baton, that only one client can have at a time.
* IDEA:  Privilege key.
* MAYBE: Incoming commands have certain form. Classes?  Strings?
* MAYBE: Access to #GOAL aso. variables.
* NOT:  Handle #area #resource #time #money aso. properties.
* NOT:
* NOT:
Properties and methods
///  This class gets same structure base, as other important classes.
///  Connecting clients (app-mission-chore) to work together.
class Connector extends BaseStruct {
  String name = 'connector class';
  String info = 'connecting app - mission - chore together, mediating them';
  String motto = 'do my job, connector, mediates';
  ///  devNote: PLAN: Two fields for to better shape outPut stuff in console.
  String seal; //  like:  ":CONNECTOR:";
  /// emblem can be used in flowC
  String emblem = ':con:X:';  //  or this emblem.
  String indent; // like:  "      ";  3-5-7 empty marks or something visible.
  String clause;  //  Combination of #LANG words in sentence.
  String master; //  Object that owns this.
  // Buffer inside class for output.
  StringBuffer buf = new StringBuffer();
///  Controlling connectors state, working-condition-state values.
bool offB = true;
bool onB = false;
bool pauseB;
bool doneB = false;

///  *****************************************************************
///  GlobalOperation ?* Using GlobalOpClass might be too heavy.!!
///  var msgBus * Sending messages between objects. Stance, approach

///  #New: #Gear Something turns around this.
///  the sail pivots around the axis of a virtually static mast
var pivot;

///  or: void metro() {}   for putting messages to move.
///  PING, Putting messages in queue or sending them immediately.
void ping(var sender, var receiver, var key) {
  ///  code
///  Members, that are participating in this connector.
///  Member is a class in base_struct.
Map<String, Member> memberM = {};

///  get / collect bindings
///  Processes, that are bind inside connector.
Map<String, Map<dynamic, dynamic>> bindingM = {};

//  Connect Members action to one or many other Members action.
String bind(var senderProcess, var receiverProcess, var thing) {
  //  Idea: Have some binding-models and types.
  //  add / find from bindingM Map
  return 'binding: #one to: #second';
///  Connector base activity, keep list of Members / their operations.
///  devNote: Or should it be something smaller?  abstract class BasePlacard?
List<GlobalOpClass> opL = new List();

///  Join "clients" / Members to opList. placardM mediates necessary info.
void opJoin(Map<String, String> plcM, String caller) {
  ///  Operations register to Connector with placardM.
  //  'actor': 'Chore',
  //  'sender': 'Chore instance',
  //  'receiver': '',
  //  'command': 'Ch-cmd:',
  //  'msg': 'Ch-msg:',
  //  *******************************
  ///  code:
  print('-->>-->>--  :connector:  C:$caller  -->>-->>--');
  print('--<<--<<--  :connector: done   C:$caller  --<<--<<--');

///  Here goes normal init-build-roll-show-done -round. No loop.
///  Method for setting class field values to their run-time-values.
///  Called by: roll.
void init() {
  buf.writeln('---  Connector buffer output initialized  ---');
  //  Set fields values.
  buf.writeln('init done');
///  Method for setting class in working condition.
///  CalledBy:  roll.
void build(String _emblem, String _master) {
  offB = false; //  off-state ends
  onB = true; //   Connector is in on-state.
  buf.writeln('build done');
///  #run / roll method
void roll() {
  buf.writeln('Connector::    $info   :: roll engaged ');
  init(); //  calling init and build methods in this class.
  //  TODO  connector Build parameters.
  //  code for roll
  //  ***   code missing, see on top of this file
  //  code here

///  Method for #Members to take part in common operations.
void rollCommon() {

///  Gives members privileges in common operations..
void sharer() {
///  Presentation method.
void show() {

///  close method
void done() {
  print('Connector::    $info   :: engaged ');
  //  code here
  buf.write('---  Connector buffer output app: done  ---');
  buf.clear(); //  empty buffer
And now section, that handles last small details:
/// TODO Name for next 3 fields might be opTouche aso. /// Solve one unambiguous textual find-decide problem. /// NOTE: might be separate Touche class. String touch(String sender, String key, String source) { // TODO problem return 'solved:toucheStr: '; } /// Search big amount of #clay data for #customer:s key / order. /// .. solve textual problems based on keywords / search in textual data /// NOTE: might be separate Solver class. String solve(String sender, String key, String source) { // TODO problem return 'solved: solveString'; } /// TODO: connector one-time calls must have parameters; /// Sketching one-time commands, coming from clients. void obey(String sender, receiver, baton, msg) { /// #baton to carry only-one-can-have-at-a-same-time magic thing // TODO code, badly missing // handle command / message } // ***************************************************************** /// Calling print/print-to-buffer function from base_lib. /// Getting local variables; Actor and Buffer right. void flowC(String msg, bool p) { /// Call flowServe with #LOCAL variables. flowServe(':con:', buf, msg, p); } /// constructor Connector(this.name, this.info); } /// Create instance of Connector. var con = new Connector('DawoAppconnector', 'Connection operations');
Chore calls this: con.opJoin(placardM, ':Chr:');
///  Testing placardM inside chore.///  Present info for outer process calls.
Map<String, String> placardM = {
  'actor': 'Chore',
  'sender': 'Chore instance',
  'receiver': '',
  'command': 'Ch-cmd:',
  'msg': 'Ch-msg:',

No comments:

Post a Comment