#Coding Guidelines

0 Followers · 56 Posts

Recommendations and best practices for writing code.

Article Andrew Sklyarov · Nov 8 4m read

When I started my journey with InterSystems IRIS, especially in Interoperability, one of the initial and common questions I had was: how can I run something on an interval or schedule? In this topic, I want to share two simple classes that address this issue. I'm surprised that some similar classes are not located somewhere in EnsLib. Or maybe I didn't search well? Anyway, this topic is not meant to be complex work, just a couple of snippets for beginners.

0
0 0
Article Andrew Sklyarov · Nov 2 7m read

Over time, while I was working with Interoperability on the IRIS Data Platform, I developed rules for organizing a project code into packages and classes. That is what is called a Naming Convention, usually. In this topic, I want to organize and share these rules. I hope it can be helpful for somebody.

 

0
0 0
Question Justin Millette · Jun 23

I have a class with a projection that creates some persistent classes (chunks) and a non-persistent "Daemon" class that I want to have running in the background, doing some processing. The daemon needs to look at the "chunk" classes, and I want it to be simple to start the daemon -- I am currently calling the daemon's start method at the end of the CreateProjection method. When I do this, I get a <CLASS DOES NOT EXIST> error from the daemon when it tries to query against one of the chunk tables. But, if I add a "HANG 5" at the beginning of the daemon start method, this runs fine. I am assuming

0
0 0
Article Sergei Sarkisian · Jul 1, 2022 8m read

Before we start with some intermediate and advanced topics, I would like to sum up some more general points. They are subjective, of course, so I will be happy to discuss them if you have other opinion or better arguments for any of them.

The list is not comprehensive and this is intended, cause I will cover some topics in future articles.

Tip 1. Follow official styleguide

1
2 491
Article Keren Skubach · May 5 4m read

An extension “extends” or enhances a FHIR resource or a data element in a custom way. The extension can be added to the root of a resource, such as “Patient.ethnicity” in US Core profile, and they can be added to individual elements such as HumanName, Address or Identifier.

Did you know that you can also add an extension to a primitive data type?

Primitives usually store a single item and are the most basic element in FHIR. For example: "Keren", false, 1234, 12/08/2024 etc.

For example, the patient resources might look like this:

0
0 0
Article David Hockenbroch · Apr 22 7m read

The Good Old Days

The %Library.DynamicObject class has been in IRIS since before it became IRIS. If you have been using it since the Cache days, you may want to brush up on some of its changes.

In Cache 2018, the %Get method only had one argument. It was the key to retrieving from the JSON, meaning that if your JSON object called myObj, it would look like the following:

0
0 0
Article David Hockenbroch · Nov 5, 2024 7m read

As we keep updating our software, we often realize that we require more and more modern solutions. So far, only one major piece of our software relies on reading barcodes in documents and images. Since Cache did not have a means of reading barcodes in the past, we have always achieved our goals by using a Visual Basic 6 application. However, it is no longer an ideal solution because it is currently complicated to maintain it. IRIS also lacks this capability, but it has recently got an option that makes up for it: embedded Python!

0
0 0
Article David Hockenbroch · Oct 14, 2024 9m read

Many programming languages use the try-and-catch construct to handle runtime errors gracefully. If the code within the try block encounters an error, it will throw an exception to the catch block, where the error handling occurs. Today we will dive into the ObjectScript implementation of this construct and discuss some ways to clean things up.

ObjectScript Implementation Basics

To get started, we will first look at the basic structure of the try/catch block:

try{
    //some code here
}
catch ex{
    //some error handling here
}
0
0 0
Question Stefan Cronje · Jul 18, 2024

Hi folks,

We are in the process of migrating from Ensemble to IRIS.

After the migration I would like to find all usages of deprecated classes and methods in all of our code. This is to align with the changes in package like %SYSTEM.SQL for example.

Is there an easy way to do this, or maybe a tool that can assist?

Thanks.

0
0 0
Article Hiroshi Sato · Apr 25, 2024 1m read

InterSystems FAQ rubric

For naming conventions, please check the respective document pages below.

About table name (class name): Identifier rules and guidelines - classes

About column names (property names): Identifier rules and guidelines - class members

As stated here, only alphanumeric characters and characters with Unicode code points larger than ASCII 128 can be used in column names (property names).

0
0 232
Article Ward De Backer · Apr 21, 2023 5m read

When you install an IRIS or Caché instance on Windows Server, you'll usually need to install it under a specific user account that has network access permissions. This is very handy when you needs to access network resources for creating files or directly accessing printers.

TL;DR: see key takeaways at the bottom!

When you need to change the Windows user account the IRIS/Caché service is running as, you can configure (after installation):

0
0 571
Article Timothy Leavitt · May 12, 2016 6m read

The topic of for/while loop performance in Caché ObjectScript came up in discussion recently, and I'd like to share some thoughts/best practices with the rest of the community. While this is a basic topic in itself, it's easy to overlook the performance implications of otherwise-reasonable approaches. In short, loops iterating over $ListBuild lists with $ListNext or over a local array with $Order are the fastest options.

As a motivating example, we will consider looping over the pieces of a comma-delimited string.

A natural way to write such a loop, in minimal code, is:

21
5 10006
Article Danny Wijnschenk · Jul 19, 2022 4m read

Mixing Object syntax with SQL is one of the nice features in Object Script. But in one case, it gave strange results, so I decided to isolate the case and describe it here.

Let's say you need to write a classmethod that updates a single property on disk. Usually, i would write that using SQL like this :

ClassMethod ActivateSQL(customerId) as %Status
{
   &sql(Update Test.Customer Set Active=1 Where ID=:customerId)
   If SQLCODE'=0 {
      Set exception = ##class(%Exception.SQL).CreateFromSQLCODE(SQLCODE, $Get(%msg))
      Quit exception.AsStatus()
   } Else {
      Quit $$$OK
   }
}
 
5
0 350
Article Sergei Sarkisian · Jul 18, 2022 12m read

Hi! Today I would like to talk about one of the most important architectural patterns in Angular.

The pattern itself is not related to Angular directly, but as Angular is component-driven framework, this pattern is one of the most essential for building modern Angular applications.

Container-Presentation pattern

It is believed that good components should be small, focused, independent, testable and most important - reusable.

0
0 1164
Question GUSTAVO MARQUES · Mar 3, 2022

Does any one could tell me how can I access the target properties from inside SQL in DTL Subtransform? For example, if I use the following statement:

SELECT ID INTO :target.SetIDPID  FROM firstlook.person WHERE  FirstName = 'Paul' - as said in documentation :

  SELECT Name INTO :target.Name FROM MainFrame.EmployeeRecord WHERE SSN = :source.SSN AND City = :source.Home.City

I get an Error: ERROR <Ens>ErrException: <PROPERTY DOES NOT EXIST>

But if I pass the value for a variable "SetIDPID" I can use it in a set action without any problem: 

1
0 338
Question Joao Lazaroni · Feb 8, 2022

I have created a Class method to list employees that are subordinated to a certain boss. But I don´t know how to relate the data in the way it was given to me.

For Example:

  • ^Employee(IdEmployee) = Name

                  ^Employee(1) = "Jessica"

                    ^Funcionario(10) = "Rose"

  • ^HistEmployee(IdEmployee, Date) = Salary^Job^IdEmployeeBoss

                    ^HistEmployee(10, 64628) = "3500^Secretary^1"

So, based on this seetings, Jessica is Rose's boss. But I don't know how I can make a relation between that string and the subscript. Can someone help me?

2
0 245
Article Nigel Salm · Aug 18, 2021 15m read

Why I love ObjectScript and why I think I might love Python More

I was looking at the thread of messages on the topic of "Performance when constructing a comma-separated string", and I started writing a response but got distracted, the page refreshed, and I lost my text. I couldn't spend the time rewriting my response, so I started writing this document instead.

17
4 1579
Question Warren Oyco · Jul 16, 2021

Hi! I am working on a project where I use record map to transform a flat file and split it into two output text file and in the future will need to split four output files.

I only want to use one  target business operations instead of multiple. Is there a way to set the output file and the target folder path in my business process class?

Any advice on how I can achieve this or is this possible? Thanks!

5
0 518
Question Jack Huser · Feb 10, 2021

Hello everyone,

I have an issue with using "Open" function.

My goal is to execute a shell script with parameters like as:

/trak/FRXX/config/shells/transportIDE.sh "login|password|NOMUSUEL|PRENOM|NOMDENAISSANCE|1234567891320|199999999999999999999999|09%2099%2099%2099%2099|31%2F12%2F1999|242%20IMPASSE%20DES%20MACHINCHOOOOOOOOSE%20||99999|SAINT%20BIDULETRUC%20DE%20MACHINCHOSE|isc%24jhu|123456|123456798"" 2>&1"

But when some parameters are too long, I have a <NAMEADD> error.

4
0 425