Profile picture for user RBeddoe

Overview

Two key factors in OOP (Object Oriented Programming) are:

  • Loose Coupling - making objects as discrete as possible so they can function on their own as well as functioning as resources for other objects.
  • Tight Cohesion - consistency within the object so that all members work together strictly for the purpose of the object. In other words, if you have an object that manipulates data rows, it should not have any members that work with presentation of the rows.

Another concept that helps programmers maintain consistency is to follow a defined Design Pattern. There are dozens (maybe hundreds) of defined Design Patterns. Design Patterns can be mixed and matched to form a custom design pattern. Really though, any 'pattern' that you use on a consistent basis can be considered a Design Pattern.

For reports, I use a pattern I call Data-Presentation-Control. We've already discussed Presentation. In this article I will discuss Data.

By using a Data object to work with data you extract from ARIS objects, you will have an easy-to-use and consistent way to package data for use in any presentation format including Excel, Word, HTML, XML, etc.

The MY_DATA class

For the MY_DATA class, I used Microsoft's .NET Data objects as a guide. I used the following members from the .NET Data library:

  • DataSet - a collection of DataTables
  • DataTable - a collection of rows and columns
  • DataRow - a collection of cells (data items based on a particular column)
  • DataRowCollection - a collection of DataRows
  • DataColumn - a single column in the table
  • DataColumnCollection - a collection of columns

Each of these members in turn will have their own members such as 'name' and 'type'.

Below (and attached) is the class

In the next article, I will bring this class and MY_EXCEL_REPORT class together in a report so you can see how they function.

Enjoy!

Rick Beddoe

Cargill Aris Technical Analyst

Minneapolis, MN, USA

 

//**********************************
// Javascript Library for ARIS
// Author : Rick Beddoe
// Date : 11/2011
//**********************************

function MY_DATA() {
    
    //public objects
    this.DataSet = function(){
        this.DataTables = [];
    }    
    
    this.DataTable = function(oTableName) {
        this.Rows = [];
        this.Columns = [];
        this.TableName = oTableName;
        
    }
    
    this.DataRow = function(){
        this.Columns = [];
        //row type: "header", "data"
        this.Type = "";
        //key/value pair
        this.Item = function(_column){
            return columnCheck(this.Columns, _column);
        }
        //collection of fields in the row
        this.ItemArray = [];
        
    }
    
    this.AddRow = function(oData, oTable){
       var  oDataRow = new this.DataRow;
       newRow(oData, oTable, oDataRow);       
       oTable.Rows.push(oDataRow);       
    };
        
    this.DatarowCollection = [];
    this.DataColumn = {};        
    this.DataColumnCollection = [];
    this.DataSortASC = function(a,b){
            return a.index-b.index;
       };       
    this.DataSortDESC = function(a,b){
            return b.index-a.index;
       };
    
    
    
    
    
    //private objects    
    function columnCheck(_columns, _column){
        
        var oColumnMatch = JSLINQ(_columns)
                           .Where(function(col) {return col.key == _column;})                    
                           .Select(function(col) {return col.key;}).ToArray();
        
        if(oColumnMatch.length == 0)
        {
            return null;
        }
        else
        {
            return _column;
        }
        
    }
    
    
    
  //Row Handling Functions      
    function writeRow(oData, oTable, oRow){ 
              var oDataRow = newRow(oData, oTable, oRow);
              oTable.Rows.push(oDataRow);
    }             
   
    
    function newRow(oData, oTable, oDataRow){
         oDataRow.Columns = oTable.Columns;
         oDataRow.Type = "data";
         oDataRow.ItemArray = {};    
         
         for (oField in oData){
             oDataRow.ItemArray[oDataRow.Item(oData[oField].key)] = oData[oField].value;
         }
         return oDataRow;
    }
}

by Rick Beddoe Author
Posted on Thu, 01/19/2012 - 15:26

Note: I have updated the class to include a function for adding new rows to the table. Prior to this, I was using the calling report to create rows.

Rick Beddoe

Cargill Aris Technical Analyst

Minneapolis, MN, USA

0

Featured achievement

Rookie
Say hello to the ARIS Community! Personalize your community experience by following forums or tags, liking a post or uploading a profile picture.
Recent Unlocks

Leaderboard

|
icon-arrow-down icon-arrow-cerulean-left icon-arrow-cerulean-right icon-arrow-down icon-arrow-left icon-arrow-right icon-arrow icon-back icon-close icon-comments icon-correct-answer icon-tick icon-download icon-facebook icon-flag icon-google-plus icon-hamburger icon-in icon-info icon-instagram icon-login-true icon-login icon-mail-notification icon-mail icon-mortarboard icon-newsletter icon-notification icon-pinterest icon-plus icon-rss icon-search icon-share icon-shield icon-snapchat icon-star icon-tutorials icon-twitter icon-universities icon-videos icon-views icon-whatsapp icon-xing icon-youtube icon-jobs icon-heart icon-heart2 aris-express bpm-glossary help-intro help-design Process_Mining_Icon help-publishing help-administration help-dashboarding help-archive help-risk icon-knowledge icon-question icon-events icon-message icon-more icon-pencil forum-icon icon-lock