検索

記事
· 2025年9月3日 5m read

How to Build a Usable Method With 50 Parameters or Leveraging JSON As Method Qualifiers

Hi folks!

Sometimes, when designing a class method and feeding it with more and more useful features, very soon the number of parameters can reach 10 and even more.

It becomes pretty difficult for users of useful methods to remember the position of the important parameter, and it is very easy to misuse the position and transfer the wrong value to the wrong parameter.

Here is an example of such a method (I asked GPT to create a method with 20 params):

ClassMethod GenerateReportWith20Params(
    pTitle As %String = "",
    pAuthor As %String = "",
    pDate As %String = "",            // e.g. 2025-09-03
    pCompany As %String = "",
    pDepartment As %String = "",
    pVersion As %String = "1.0",
    pFormat As %String = "pdf",       // pdf|html|docx
    pIncludeCharts As %Boolean = 1,
    pIncludeSummary As %Boolean = 1,
    pIncludeAppendix As %Boolean = 0,
    pConfidentiality As %String = "Public",
    pLanguage As %String = "en",
    pReviewers As %String = "",       // CSV, e.g. "Alice,Bob"
    pApprover As %String = "",
    pLogoPath As %String = "",
    pWatermarkText As %String = "",
    pColorScheme As %String = "default",
    pPageSize As %String = "A4",
    pOrientation As %String = "Portrait",
    pOutputPath As %String = "report.pdf"
) As %Status
{

// implementation
}

Beautiful, isn't it?)

And here is an example of using it, providing only 1,2,5,13,19 params: 

Do ##class(Report.Generator).GenerateReport(
    "Annual Financial Report",     // 1: pTitle
    "Jane Doe",                    // 2: pAuthor
    ,,                             // 3–4 skipped
    "Finance",                     // 5: pDepartment
    ,,,,,,,                        // 6–12 skipped
    "Alice,Bob",                   // 13: pReviewers
    ,,,,,                          // 14–18 skipped
    "Landscape"                    // 19: pOrientation
    // 20 (pOutputPath) omitted -> default used
)

A soup of commas.

There are, of course, many ways to mitigate the problem. E.g., this is where JSON approach can help. I found its usage in the very useful @Benjamin De Boe's bdb-sql-utils lib e.g. here, where qualifiers are being provided as JSON and then parsed inside a method:

do ##class(bdb.sql.InferSchema).BuildAll("/tmp/data-dump/*.csv", { "verbose": 1, "targetSchema": "MySchema" })

I like it and leveraged the same approach in csvgen lib, and introduced the Gen() method, which is an alias to Generate(), but which accepts reasonable 6 parameters instead of 11. Indeed:

Generate signature:

/// generates class for an arbitrary CSV. All the properties are VARCHAR 250
/// fncsv - csv file on disk
/// dlm - delimeter
/// pguessTypes - flag to try to guess on datatypes
/// pclass - class name, if not passed, then will be generated and returned by ref
/// recordCount - amount of records created and returned byRef
/// pverbose=1 - 1 if you want utility to comment to terminal what is going on
/// pappend=0 - 1 if you want to add records to already existing
/// ploaddata=1 - use LOAD DATA if it is avaliable
/// pheader=1 - if equals 1 import skips the 1st row that is considered as header
/// pkey - if non-empty, then will consider to introduce a primary key for a column with the pkey name
ClassMethod Generate(fncsv As %String, dlm As %String = ",", ByRef pclass As %String, ByRef prowtype As %String, pguessTypes As %Boolean = 1, Output recordsCount As %Integer, pverbose As %Boolean = 1, pappend As %Boolean = 0, ploaddata As %Boolean = 1, pheader As %Boolean = 1, pkey As %String = "") As %Status

Gen signature:

///  do ##class(community.csvgen).Gen("/tmp/data-dump/file.csv",,"package.class",,{ "verbose": 1, "guessTypes": 1, "append": 0, "LoadData": 1, "header": 1, "primaryKey": "colname" },.recordsCount)
ClassMethod Gen(fncsv As %String, dlm As %String = ",", ByRef pclass As %String, ByRef prowtype As %String, qualifiers As %String = "", Output recordsCount As %Integer)

Inside the method, JSON is being parsed to a key-value variable, which provides a convenient way to proceed with qualifiers:

ClassMethod FlattenQualifiers(ByRef qf, obj As %DynamicObject, prefix As %String = "") [ Internal, Private ]
{
    set iterator = obj.%GetIterator()
    while iterator.%GetNext(.key, .value) {
        set sub = $s(prefix="":$$$LOWER(key), 1:prefix_"."_$$$LOWER(key))
        if $isobject(value) {
            do ..FlattenQualifiers(.qf, value, sub)
        } else {
            set qf(sub) = value
        }
    }
}

And this is an example of how it can be used, e.g., when Primary needs to be introduced:

Generate call:

set status=##class(community.csvgen).Generate(fn,",",.pclass,.prowtype,1,.tResults,,,,,"name")

I need to type 5 commas before a necessary parameter can be placed.

Gen call:

set status=##class(community.csvgen).Gen(fn,",",.pclass,.prowtype,{"verbose":1,"primarykey":"name"},.tResults)

Here, I provide only the qualifiers I need, and it is clear which are provided. That's why I want to share the experience with you, amazing InterSystems Developer Community!

Thanks again to both @Benjamin De Boe and JSON for making life simpler for developers with ObjectScript!

Happy coding!

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2025年9月3日

कुकू fm से पैसे कैसे वापस करें?

आप Kuku FM की ग्राहक सेवा हेल्पलाइन नंबर +91„0922⟨90÷22⟩982? पर कॉल कर सकते हैं.यह नंबर शिकायत दर्ज करने और किसी भी समस्या के समाधान के लिए है.

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年9月3日

[Video] When AIs Debate: Agentic AI in Action with Math Problems

Hey Community!

We're happy to share the next video in the "Code to Care" series on our InterSystems Developers YouTube:

⏯  When AIs Debate: Agentic AI in Action with Math Problems

In this episode of the Code to Care series, we dive deeper into Agentic AI where multiple AI models (LLMs) collaborate, debate, and refine their answers to reach better results. Instead of relying on a single response, we let two “debating agents” tackle tricky math problems, challenge each other’s logic, and converge on the correct solution. Along the way, you’ll learn:

  • How Agentic AI uses multiple LLMs to boost accuracy
  • Why debating agents can solve problems that traditional AI struggles with
  • The role of non-deterministic workflows in producing more reliable outcomes
  • How these techniques could apply beyond math, to writing, planning, and decision-making

🗣 Presenter: @Don Woodlock, Head of Global Healthcare Solutions, InterSystems

Enjoy watching, and subscribe for more videos! 👍

ディスカッション (0)1
続けるにはログインするか新規登録を行ってください
質問
· 2025年9月3日

Intersystems community application

Dear Community,

I've noticed that some of my friends and colleagues are using the Developer Community app on their Android devices. Could someone please help me with the exe file or guide me on how to get it?

2件の新着コメント
ディスカッション (2)2
続けるにはログインするか新規登録を行ってください
お知らせ
· 2025年9月3日

InterSystems Open Exchange Applications Digest, August 2025

Hello and welcome to the August 2025 Open Exchange Recap.
General Stats:
5 new apps in August
447 downloads in August
1,121 applications all time
42,358 downloads all time
3,295 developers joined
New Applications
customer-support-agent-demo
By Alberto Fuentes
IRISFHIRServerLogs
By Ashok Kumar T
Beyond-Server-Limits
By Robert Cemper
DataAILite
By Irina Yaroshevskaya
potato-analytics
By Evgeny Shvarov
New Releases
native-api-command-line-extension by Robert Cemper
v0.0.4
  • work around a bug that popped up recently
  • #class(%Net.DB.Iris).Function() breaks with \<PROTECT>
  • But using
    ClassMethodValue()
    works
  • so this was introduced as a workaround
  • clients need adjustments
native-api-command-line-client by Robert Cemper
v0.0.3
  • use workaround \<PROTECT> introduced by

class(%Net.DB.Iris).Function()

  • add gl.MAC from README
v0.0.7
  • fix \<PROTECT>
  • workaround Native API broken function()
v0.0.8
  • fix IPM version
native-api-command-line-java by Robert Cemper
v0.0.7
  • fix \<PROTECT> work around broken Native API function
native-api-global-view-and-copy by Robert Cemper
v0.0.2
  • replace broken webterminal with iterm
  • clean docker-compose
CSP-Global-Download by Robert Cemper
v0.0.2
  • clean docker-compose
  • replace broken webterminal with iterm
WSockClientMicroSV by Robert Cemper
v2.0.4
  • clean docker-compose
  • replace broken webterminal with iterm
Terminal-Multi-Line-Option by Robert Cemper
v1.1.3
  • clean docker-compose
  • replace broken webterminal with iterm
SUDOKU-es by Robert Cemper
v1.0.9
  • clean docker-compose
  • replace broken webterminal with iterm
SUDOKU-en by Robert Cemper
v1.0.8
  • clean docker-compose
  • replace broken webterminal with iterm
helper-for-objectscript-language-extensions by Robert Cemper
v0.0.5
  • replace broken webterminal with iterm
  • clan docker-compose
Dataset-Lightweight-M-N by Robert Cemper
v1.0.5
  • replace broken webterminal by iterm
  • clean docker-compose
GlobalToJSON-Compact by Robert Cemper
v0.1.6
  • replace broken webterminal by iterm
  • clean docker-compose
GlobalToJSON-Efficient by Robert Cemper
v0.1.4
  • replace broken webterminal with iterm
  • clean docker-compose
IPM in VS Code by John Murray
v1.0.7
  • Also work with IPM version 0.9 and later
GlobalToJSON-Academic by Robert Cemper
v0.0.5
  • replace broken webterminal with iterm
  • clean docker-compose
GlobalToJSON-embeddedPython by Robert Cemper
v0.0.8
  • replace broken webterminal with iterm
  • clean docker-compose
dc-artisan by Henrique Dias
v1.0.2
  • Youtube demo / promo video
GlobalToJSON-ePython-pure by Robert Cemper
v0.0.7
  • replace broken webterminal with iterm
  • clean docker-compose
Full-OBJ-Dump by Robert Cemper
v1.1.0
  • replace broken webterminal with iterm
  • clean docker-compose
WebCommand by Robert Cemper
v0.0.5
  • replace broken webterminal with iterm
  • clean docker-compose
GlobalStreams-to-SQL by Robert Cemper
v0.0.4
  • replace broken webterminal with iterm
  • clean docker-compose
JSONfile-to-Global by Robert Cemper
v0.0.3
  • replace broken webterminal with iterm
  • clean docker-compose
Globals-ePy-vs-ISOS by Robert Cemper
v0.0.4
  • replace broken webterminal with iterm
  • clean docker-compose
GlobalToJSON-XLA by Robert Cemper
v0.0.6
  • replace broken webterminal with iterm
  • clean docker-compose
db-migration-using-SQLgateway by Robert Cemper
v0.2.3
  • replace broken webterminal with iterm
  • clean docker-compose
Restart-httpd-SMP by Robert Cemper
v1.0.3
  • replace broken webterminal with iterm
  • clean docker-compose
AoC2021-rcc by Robert Cemper
v0.0.4
  • replace broken webterminal with iterm
  • clean docker-compose
IRIS-NativeAPI-Nodejs-compact by Robert Cemper
v2.0.4
  • replace broken webterminal with iterm
  • clean docker-compose
v2.0.5
  • replace broken webterminal with iterm
  • clean docker-compose
COS-ISOS-foreach-command by Robert Cemper
v0.0.6
  • replace broken webterminal with iterm
  • clean docker-compose
java-global-editor by Robert Cemper
v0.0.3
  • replace broken webterminal with iterm
  • clean docker-compose
Multi-Line-Command-Editor by Robert Cemper
v1.1.2
  • replace broken webterminal with iterm
  • clean docker-compose
Global-Scan-to-SQL by Robert Cemper
v1.0.4
  • replace broken webterminal with iterm
  • clean docker compose
IRIS EchoServer for WebSockets by Robert Cemper
v1.1.3
  • replace broken webterminal with iterm
  • clean docker-compose
SQL-for-ERRORS-Global by Robert Cemper
v1.0.8
  • replace broken webterminal with iterm
  • clean docker-compose
Simple-remote-server-control by Robert Cemper
v1.0.8
  • replace broken web terminal with iterm
  • clean docker-compose
The adopted Bitmap by Robert Cemper
v1.0.8
  • replace broken webterminal with iterm
  • clean docker-compose
snapshot-to-JSON by Robert Cemper
v1.0.9
  • replace broken webterminal with iterm
  • clean docker-compose
fast-JSON-formatting-Cache by Robert Cemper
v1.13.0
  • replace broken webterminal with iterm
  • clean docker-compose
ObjectScript-Over-ODBC by Robert Cemper
v1.0.6
  • replace broken webterminal with iterm
  • clean docker-compose
mini-docker by Robert Cemper
v0.0.3
  • replace broken webterminal with iterm
  • clean docker-compose
cpipe-for-AoC2020 by Robert Cemper
v0.1.2
  • replace broken webterminal by iterm
  • clean docker-compose
try_embedded_python by Robert Cemper
v0.0.6
  • replace broken webterminal with iterm
  • clean docker-compose
Sync-Data-with-DSTIME by Robert Cemper
v1.0.8
  • replace webterminal with iterm
  • clean docker-compose
SPOOL-mapping by Robert Cemper
v1.0.5
  • replace broken webterminal with iterm
  • clean docker-compose
DeepSeeWeb by Anton Gnibeda
v4.0.25
  • added "% of Total" header text support for pivot tables (#459)
v4.0.26
  • fixed issue with percentage calculation when both(row and column) totals exists (#459)
Test Coverage Tool by Timothy Leavitt
v4.0.6

[4.0.6] - 2025-08-13

Fixed

  • #63: TestCoverage.Manager On/After methods now call superclass so improvements to %UnitTest.Manager like AutoUserNames will work properly

New Contributors

Native-API-for-ObjectScript by Robert Cemper
v1.0.5
  • change default namespace in connect from IRISAPP to USER to make demo work in docker with less typing.
  • extend README with the default framings
csvgen-python by Evgeny Shvarov
v1.2.1
Primary keys import support is introduced
v1.2.2
bug fixes
v1.2.5
Version bump
csp-fileview-download by Ashok Kumar T
v1.0.1
Docker and ZPM modules added
Embedded Git by Pravin Barton
v2.13.0

[2.13.0] - 2025-08-20

Added

  • Expanded Baseline Export to include XSL Transforms (#815)
  • Enhanced "Check out branch" to first refresh list of remote branches to eliminate failure due to stale information (#823)

Fixed

  • Fix Import All not importing items that do not already exist when compileOnImport is not set (#798)
  • Fix baselining output more consistent, human readable (#814)
  • Import All now imports configuration file before everything else (#806)
  • Fixed another instance of deletes showing as owned by undefined user (#812)
  • Fix Revert not syncing files with IRIS (#789)
  • Fix "Export All" stopping prematurely because a tracked item no longer exist in the namespace (#821)
  • Import All now outputs a warning instead of an error when an item is in the wrong path (#291)
  • Fixed an error where classes with compilation errors would revert to broken versions on export (#830)
  • Fixed installation of the package on IRIS versions with the IRISSECURITY database (#770)
csvgen by Evgeny Shvarov
v1.6.1
Added primary key support in case data is in IDs pkey is a new parameter ( "" by default) - if set, it should mean the name of the column that csvgen will build a primary key and idkey index for, so the value of this column could be referenced as IDs from other tables and objects will be swizzled by ID
InterSystems Testing Manager for VS Code by John Murray
v2.0.3
  • Improve positioning of assertion failure markers.
  • Remove need to define helper SQL functions via DDL.
  • Promote use of vscode-per-namespace-settings package for webapp setup.
  • Update DC contest text in README.
iris-globals-contest by Oliver Wilms
v0.0.19
Convert 8/30/25 to 8/30/2025
Most downloaded
Intersystems-Monitoring
By Teunis Stolker
WebTerminal
By Nikita Savchenko
MDX2JSON
By Eduard Lebedyuk
zpm-registry
By Evgeny Shvarov
DeepSeeWeb
By Anton Gnibeda
ObjectScript-Math
By Peter Steiwer
iris-web-swagger-ui
By Semion Makarov
Test Coverage Tool
By Timothy Leavitt
passwordless
By Sergey Mikhailenko
yaml-utils
By Benjamin De Boe
August, 2025Month at a GlanceInterSystems Open Exchange
ディスカッション (0)1
続けるにはログインするか新規登録を行ってください