Pesquisar

Article
· Dec 12 2m read

Archivos temporales y Singletons: limpiad lo que generéis.

Hay un patrón con el que me he encontrado varias veces en el que necesito usar un archivo o carpeta temporal y que se limpie en algún momento más adelante.

Lo natural aquí es seguir los patrones de "Robust Error Handling and Cleanup in ObjectScript" usando un try/catch/pseudo-finally o un objeto registrado para gestionar la limpieza en el destructor. %Stream.File* también tiene una propiedad “RemoveOnClose” que podéis activar… pero usadla con cuidado, porque podríais eliminar accidentalmente un archivo importante, y este indicador se reinicia al llamar a %Save(), así que tendréis que volver a ponerlo a 1 después de hacerlo.

Pero hay un caso complicado: imaginad que necesitáis que el archivo temporal sobreviva en un nivel de pila superior. Por ejemplo:

ClassMethod MethodA()
{
    Do ..MethodB(.filename)
    // Do something else with the filename
}

ClassMethod MethodB(Output filename)
{
    // Create a temp file and set filename to the file's name
    Set filename = ##class(%Library.File).TempFilename()
    
    //... and probably do some other stuff
}

Siempre podríais pasar objetos %Stream.File* con RemoveOnClose puesto a 1, pero aquí realmente estamos hablando solo de archivos temporales.

Aquí es donde entra el concepto de “Singleton”. En IPM tenemos una implementación base en %IPM.General.Singleton que podéis extender para cubrir distintos casos de uso. El comportamiento general y el patrón de uso son:

  • En un nivel de pila superior, llamáis a %Get() en esa clase y obtenéis la única instancia, que también será accesible mediante llamadas a %Get() en niveles inferiores.
  • Cuando el objeto sale de ámbito en el nivel de pila más alto que lo usa, se ejecuta el código de limpieza.

Esto es un poco mejor que usar una variable %, porque no necesitáis comprobar si está definida, y además sobrevive a los NEW sin argumentos en los niveles de pila inferiores gracias a cierta magia profunda de objetos.

Pasando a los archivos temporales, IPM también tiene un singleton gestor de archivos temporales. Aplicándolo a este problema, la solución es:

ClassMethod MethodA()
{
    Set tempFileManager = ##class(%IPM.Utils.TempFileManager).%Get()
    Do ..MethodB(.filename)
    // Do something else with the filename
    // The temp file is cleaned up automatically when tempFileManager goes out of scope
}

ClassMethod MethodB(Output filename)
{
    Set tempFileManager = ##class(%IPM.Utils.TempFileManager).%Get()
    // Create a temp file and set filename to the file's name
    Set filename = tempFileManager.GetTempFileName(".md")
    
    //... and probably do some other stuff
}
Discussion (0)1
Log in or sign up to continue
Announcement
· Dec 12

[Video] SQL Tricks and Tips

Hey Community!

We're happy to share a new video from our InterSystems Developers YouTube:

⏯  SQL Tricks and Tips @ Ready 2025

This presentation introduces two helpful SQL features in InterSystems IRIS: Common Table Expressions (CTEs) and Limit/Offset. CTEs, available since version 24.1, let users simplify complex queries by breaking them into reusable, readable blocks that can be used with SELECT, INSERT, UPDATE, and DELETE statements.
The Limit/Offset feature, added in version 25.1, provides a flexible alternative to the TOP clause, allowing users to limit returned rows and skip specific records, ideal for pagination. Together, these features make queries easier to write, read, and optimize, while the SQL engine automatically handles efficient execution and plan optimization.

Presenters:
🗣 Ismail Ben Atitallah, Principal Systems Developer, InterSystems
🗣 Yiwen Huang, Systems Developer, InterSystems

Enjoy watching, and subscribe for more videos! 👍

Discussion (0)1
Log in or sign up to continue
Announcement
· Dec 12

[Video] Enhancing Customer Engagement with Vector Search - Building a Customer Facing Chatbot

Hey Developers,

Enjoy the new video on InterSystems Developers YouTube

⏯ Enhancing Customer Engagement with Vector Search - Building a Customer Facing Chatbot @ READY 2025

Explore how InterSystems IRIS vector search anchors chatbot capabilities by delivering fast, relevant, and context-aware responses. In this session, we’ll walk through the key benefits and best practices for using vector search in conjunction with your LLM to power your chatbots. You’ll also meet our new chatbot AskMe, available on our documentation and learning sites; it’s designed to help you find answers quickly and navigate content with ease. Whether you’re building AI-driven support or optimizing existing solutions, you’ll leave with actionable insights to improve and enhance self-service experiences.

Presenters:
🗣 @Brenna Quirk, Sr. Technical Online Course Developer at InterSystems
🗣 @Jim Breen, Director of Global Learning at InterSystems
🗣 @Kim Koehler, Manager, Learning Technology at InterSystems 

Enjoy watching, and look forward to more videos!👍

Discussion (0)1
Log in or sign up to continue
Question
· Dec 12

Classic Essentials Hoodie for Men and Women – A Casual Must-Have

In the world of fashion, few items have achieved the timeless appeal of the hoodie. Among the most versatile and comfortable pieces in any wardrobe, the Classic Essentials Hoodie for men and women has become a staple that blends style, comfort, and practicality seamlessly. Whether you are lounging at home, heading out for a casual day in the city,        Essentials hoodie  
   or layering for outdoor adventures, this hoodie proves to be an indispensable part of modern fashion.

Timeless Design Meets Everyday Comfort

The Classic Essentials Hoodie is designed with simplicity and functionality in mind. Its clean lines and minimalistic style make it a perfect match for almost any outfit. Unlike hoodies with excessive branding or complicated designs, the classic hoodie embraces a more understated aesthetic that appeals to people of all ages and tastes. The soft fabric, usually a blend of cotton and polyester, provides a cozy feel while ensuring durability. This combination allows the hoodie to maintain its shape and softness even after multiple washes, making it a reliable choice for everyday wear.

One of the most appealing aspects of this hoodie is its universal fit. Designed to suit both men and women, it offers a flattering silhouette that doesn’t compromise comfort. The adjustable hood and ribbed cuffs add to its practical design, allowing wearers to stay warm and snug during cooler weather. Whether paired with jeans, joggers, or even shorts, the hoodie adapts effortlessly to different looks, making it an essential piece for any casual wardrobe.

Versatility That Fits Any Lifestyle

The Classic Essentials Hoodie isn’t just about comfort; it’s about versatility. Its neutral tones and simple design make it suitable for a variety of occasions. For students and young professionals, it offers a relaxed yet polished look that can be worn to class, casual office settings, or weekend meetups. For athletes or fitness enthusiasts, it serves as a comfortable layer for warm-ups, cool-downs, or outdoor exercises. Its lightweight nature ensures ease of movement, while the hood provides additional protection from wind and light rain.

Moreover, this hoodie is perfect for layering. It can be worn over t-shirts, long sleeves, or even under jackets, providing both style and warmth. This adaptability makes it an ideal choice for transitional seasons like spring and fall, when the weather can be unpredictable. Unlike other seasonal apparel that becomes obsolete after a few months, the Classic Essentials Hoodie remains relevant year after year, cementing its status as a wardrobe essential.

A Wardrobe Staple for Everyone

One of the reasons the Classic Essentials Hoodie has become so popular is its universal appeal. It transcends gender, age, and fashion trends, making it a reliable option for everyone. The hoodie’s simplicity allows wearers to personalize their style effortlessly. Some may prefer a monochromatic look, pairing it with matching pants or sneakers, while others might layer it with patterned or textured clothing to create a more dynamic outfit. Regardless of personal style, the hoodie serves as a comfortable canvas for self-expression.

In addition to style, the hoodie offers practical benefits that enhance everyday life. The front pocket provides convenient storage for small essentials like phones, keys, or wallets,      Essentials T-Shirt 
   while the soft inner lining adds warmth and coziness during cooler days. Its breathable fabric prevents overheating, ensuring comfort during extended wear. This balance between style and functionality is what makes the Classic Essentials Hoodie a must-have item for anyone seeking both fashion and practicality.

Investing in Timeless Comfort

Purchasing a Classic Essentials Hoodie is more than just buying a piece of clothing; it’s an investment in timeless comfort and style. Unlike trendy items that quickly go out of fashion, this hoodie maintains its appeal across seasons and years. Its durable construction ensures long-lasting use, while its versatile design makes it easy to pair with other wardrobe staples. Whether you’re dressing for a casual outing, relaxing at home, or layering for outdoor adventures, the hoodie delivers consistent comfort and style.

In conclusion, the Classic Essentials Hoodie for men and women is not just another casual clothing item—it is a lifestyle choice. Its timeless design, unmatched comfort, and incredible versatility make it a wardrobe essential for people of all ages. By investing in this hoodie, you are choosing a piece that adapts to your lifestyle, enhances your daily comfort, and allows you to express your style effortlessly. If there is one item that deserves a place in every closet, the Classic Essentials Hoodie undoubtedly earns that spot.

Discussion (0)1
Log in or sign up to continue
Announcement
· Dec 12

InterSystems sera présent au Health&Tech Summit 2025

Salut la communauté,

Rejoignez-nous pour notre présentation lors du Health&Tech Summit 2025 !

📅  Dates : 16 - 17 décembre, 2025

📌 Lieu : Palais du Pharo & AP-HM, Marseille, France

Nous prendrons la parole lors d’une intervention dédiée à l’innovation en santé, autour des enjeux de transformation numérique et des solutions qui accompagnent les professionnels au quotidien.

Réservez la date, préparez vos questions et rejoignez-nous pour des échanges, nous avons hâte de vous rencontrer !

Inscrivez-vous dès maintenant !

Discussion (0)1
Log in or sign up to continue