Coding Guidelines

Syndicate content 12 

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.

Last comment 5 days ago
+ 19   1 13
4652

views

+ 19

rating

Hi all,

I'm wonder what could be the best way convert the sentence "Switch" C# into Cache code.

int caseSwitch = 1;

switch (caseSwitch)
{
    case 1:
    Console.WriteLine("Case 1");
    break;

    case 2:
    Console.WriteLine("Case 2");
    break;

    default:
    Console.WriteLine("Default case");
    break;

}

My first attempt was:

Last answer 3 July 2018 Last comment 20 July 2018
+ 1   1 7
885

views

+ 1

rating

Hi, Community!

Coding guidelines discussion. Consider you have For with one command in the cycle. Here are the options:

One

For i=1:1:1000 set ^Test(i)=""

Two

For i=1:1:1000 {

 set ^Test(i)=""

}

Same for the "If":

if a set b=a

or

if a {

 set b=a

}

Your choice? Or maybe even other options? 

Last comment 27 April 2018
0   1 14
879

views

0

rating

As a developer, usually I'm concerned about how my code health is, and how the other coders code can affect to my own work.  And I'm quite sure most of us feel very similar.

In our company we use a Static Code Analysis tool to analyze code for different languages to ensure we are writing high quality and easily maintainable code by following a few best practices in terms of code structure and content. And the question was: why should be different for Caché ObjectScript language?

Last comment 1 August 2018
+ 6   4 4
587

views

+ 6

rating

I am trying to write an application that will take some information on the database make a call to the Google API distance matrix and get the information to use with rest of the application without using the ensemble part of the development is this possible and how can I do my communication with the  API from a cache class thanks in  advance

Last answer 30 January 2018 Last comment 31 January 2018
0   0 4
470

views

0

rating

Hi Community!

Sometimes I meet a method which accepts 10+ parameters.

And often I need only the 8th parameter  to  pass. And I call the method something like:

do ##class(Some.Feature).Method(,,,,,,,"flag")

And I don't like this method when I call it like this cause, you know, often I just miss the number of commas and raise some other flag I wanted.

How do you avoid this situations? 

If you meet such a code, how do you call it and sure that you didn't miss the number of ","?

What is a good number of parameters in a method and f you need to pass more parameters in a method what do you do?

Last answer 5 May 2019 Last comment 9 June 2019
+ 2   0 9
351

views

+ 2

rating

Our development server is set up to automatically keep the .INT code of compiled classes and routines, but the live servers are set to not keep the .INT code.

I know how to set the system to keep this code ($SYSTEM.OBJ.SetQualifiers() ?)  but what are the ramifications of keeping this code on the live servers?  Is it just a space issue?  I always thought it was to keep the code more private.

Last answer 6 February 2019 Last comment 8 February 2019
0   0 2
249

views

0

rating

We are trying to get a custom header that I have added to a request to Cache, and I have seen the following in another post, however it doesn't work for us:

You can do it as in any CSP page/class. With %request, which is object of class %CSP.Request

And headers available in property CgiEnvs, where every http header appear with a prefix HTTP_

So, you may try this code.

Last answer 9 November 2018 Last comment 1 December 2018
0   0 4
213

views

0

rating

Documentation here lists the kinds of members a class definition may contain. In summary:

  • Parameters
  • Methods
  • Properties
  • Class queries
  • XData blocks
  • Projections
  • (and some that are relevant only for persistent classes):
    • Storage definitions
    • Indices
    • Foreign keys
    • SQL triggers

Later in the same document, a section headed "Class Member Names" contains this warning:

Last answer 13 February 2018 Last comment 13 February 2018
+ 1   0 5
204

views

+ 1

rating

Hi! We have received a request to create a new rule on CachéQuality to identify when a developer uses double quotes (" ") within any SQL statement.

We have been asked many times about SQL validation rules, and we would like to open a debate to allow everyone discuss what would you like to be checked on a SQL statement.

Current examples are for basic situations:

Last answer 1 April 2019 Last comment 28 March 2019
0   0 3
188

views

0

rating

Hi guys,

I have never used regular expressions with caché object script before, so I've read through the documentation, but I am struggling with things that I'd like some help on.

My need is to identify specific html tags and transform them out to something else. Example:

I need to identify those guys in a wider string:
"<span style=\""font-family: '';font-weight: bold;\"" >BOLD TEXT</span>"
"<span font-style:italic;\" >ITALIC TEXT</span>"

Last answer 17 June 2019 Last comment 17 June 2019
0   0 1
180

views

0

rating

Hi All,

Actually, I'm developing few restful API's. I want to create a authentication tokens and display it on my login restful API. If I'm using CSP sessionId, how can I validate the session Id's in another or continues restful API's. else, is there any other approach to handle this task. 

My Primary goal is, I have to integrate 2 different front end applications. One is Zen framework another one is web pages from Python. 

If any lead, it would be appreciated. 

Thanks,

Arun Kumar Durairaj. 

0   0 1
0

answers

0

comments

125

views

0

rating

I am new to Intersystems Cache, so please bear with me. We are using HealthShare 2013.1. 

I have a routine to compare databases from separate instances where I want to ignore values that begin with %sqlcq. I thought this would be easy with pattern matching operator '?' but it is proving difficult and it seems to be because of the percent character. 

For example:

Last answer 21 February 2019 Last comment 18 February 2019
0   0 4
114

views

0

rating

Say I have a property in  a persistent class that stores list of colours and I would like to query that field and return  a list and be able to loop that list to get individual colours how will l go about achieving this I have tried something like this but its not working as expected

 

 

 &sql(SELECT colour INTO :colourList FROM favouritecolours)
 While (SQLCODE = 0) 
{
 for i=1:1:$LENGTH($P(colourList,","))
 {
 set fvalue=$P(colourList,",",i) 
write "the first"_fvalue,i, 
} 
}

 

 

Last answer 3 June 2019
0   0 1
0

comments

102

views

0

rating