NIANIO Pattern Błażej Chodarcewicz Warsaw, 2006-02-22 Presentation Plan • • • • • Current UI problems The Nianio introduction Test application Java patterns Genrap UI future Current prblems • • • • • Incomplete application state A lot of state full objects Synchronization and threads Models, MM, listeners – loops Un clear event flow The NIANIO • State type definition • Command type definition • External command type definition • Function – nianio implementation – logic Test application – Nianio in practice Java implementation of Nianio • State - schema structure • Command - schema variant • External command - schema variant • State = { … } • Cmd = variant [java mm] { … } • ExtCmd = variant [java mm] {…} Nianio = public State invoke(State, Cmd, ExtCmd.MM) • Function • No side efects • ExtCmd.MM accumulates commands AppState = { reportFile, xmlFile, xsdFile, outputFile : SelectFileState = { fileName : string ? fileChooserState : FileChooserParams= { kind : FileChooserKind = variant {open | save} extensions : array of string description : string } } outputKind : OutputKind = variant {html | pdf | xls} status : Status = variant { generatingReport of int | ready } messageDialogStates : MsgDialogs } MsgDialogs = [java dict [key]] array of Entry = { key : MsgDialogKey = string value : MessageDialogParams = { dialogKind : MessageDialogKind = variant { info | warning | error } message : string } } AppLogicCmd = [java mm] variant { run | close | setPdfOutput | setHtmlOutput | setXlsOutput | generateRequest | reportGenerated of GenrapPluginEvent | reportFileCmd of SelectFileCmd | xmlFileCmd of SelectFileCmd | xsdFileCmd of SelectFileCmd | outputFileCmd of SelectFileCmd | messageDialogClosed of MsgDialogKey } SelectFileCmd = [java mm] variant { setFileName of string | selectFromFileChooser | fileSelected of FileChooserResult = { ? path : string } } GenrapPluginEvent = [java mm] variant { success of ReportParams | failure of ReportGenerationFailure = { params : ReportParams cause : string } } AppLogicExtCmd = [java mm] variant { generate of ReportParams | showMainFrame of MainFrame = { reportFileName, xmlFileName, xsdFileName, outputFileName : string outputKind : OutputKind status : string } | setOutput of OutputKind | setStatus of string | reportFile of SelectFileExtCmd | xmlFile of SelectFileExtCmd | xsdFile of SelectFileExtCmd | outputFile of SelectFileExtCmd | showMessage of ShowMessageCmd = { key : MsgDialogKey params : MessageDialogParams } | closeMainFrame | exit } SelectFileExtCmd = [java mm] variant { openFileChooser of FileChooserParams | setFileName of string } More Nianio examples – Test Application Source • • • • Nianio implementation Nianio invocation Nianio parameterization Connecting nianios Genrap UI future • Nianio and functional code everywhere (no models, listeners) • Small part of code which touch threads, synchronization etc. • Controlled event flow • Clear core structure Genrap core architecture Thank you Questions?