Subscribe for automatic updates: RSS icon RSS

Login icon Sign in for full access | Help icon Help
Advanced search

Pages: [1]
  Reply  |  Print  
Author Topic: Ask Reuben 36 - Length of Array and Char  (Read 5467 times)
Reuben B.
Four Js
Posts: 1116


« on: July 09, 2020, 02:11:21 am »

Many years ago when I first transformed an Informix-4gl application to Genero, one of the things we investigated and actioned was changing CHAR variables to STRING variables, and similarly static ARRAY to DYNAMIC ARRAY‘s.  In particular we paid a lot of attention to CHAR and ARRAY that were an arbitrary length e.g. 1000, and said that if there was not a sound underlying reason for that length to be what it was, then we should consider using a STRING or DYNAMIC ARRAY instead.  The STRING and DYNAMIC ARRAY datatypes rather than having a fixed length allow for an unlimited length and allocate memory as required, as well as allowing better code practises and more functionality.

Advantages of using STRING and DYNAMIC ARRAY over CHAR and static ARRAY include

   • improved memory usage
   • more reliable code as don’t run into possibility of arbitrary length being exceeded.
   • less code as I don’t have to explicitly avoid arbitrary length being exceeded
   • access to methods for STRING and DYNAMIC ARRAY  datatypes
   • pass by reference, not by value

I still see a lot of code that uses CHAR and static ARRAY of arbitrary length that could be coded using STRING and DYNAMIC ARRAY respectively.

Read more at https://4js.com/ask-reuben/ig-36/

Product Consultant (Asia Pacific)
Developer Relations Manager (Worldwide)
Author of https://4js.com/ask-reuben
Contributor to https://github.com/FourjsGenero
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines