The singleton design pattern has its place in the desktop environment where there will be only one user running the application, and when that user quits the app the singleton is destroyed. This doesn’t fit the requirements of a multi-user environment such as the web where many users will be accessing the application at once. I recently came across this issue when porting a desktop app to the web which required me to design a singleton class that is session sensitive. Here’s a walk through of how I achieved my goal. Please note that scopes are particularly important when creating this class.
With so many programming languages and development environments around … why you should try Xojo? I could tell you more than 400,000 reasons to just jump-in right away; reasons I’ve heard for over 10 years now from Xojo users around the world that are building all kind of apps, products and solutions in all kinds of fields. Nevertheless, if I really think about, all of these reasons can be condensed into the following 10 main points. Continue reading and I’m pretty sure you will want to give Xojo a try too!
Xojo is an Object Oriented Programming Language and, among other things, that means that it supports Methods Overloading. We have seen in other posts that some of these overloaded methods can be Class Constructors, but, there are others things you can do. For example, we can overload the operators. These are the methods in charge of adding two instances of the same class, subtracting, multiplying or dividing them. But we also have at our disposal another operator we can overload: Lookup. What advantages does this give us and how it does it work? Let’s explore it while building a Preferences class we can use in any of our projects.
Object Oriented Programming (OOP) puts in our hands the ability to create apps in a flexible and powerful way. Xojo embraces that philosophy in the Xojo language itself, allowing us to implement code in a flexible way for reuse, extension and maintainability that reduces the development cycles. One of these language tools is, in fact, common in other low level programming languages: Casting or type conversion. If you are interested in this (and you should be), continue reading and discover what it is, why you should be interested in it and how can you use it in your next Xojo app!