<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Object-Oriented &#8211; Xojo Programming Blog</title>
	<atom:link href="https://blog.xojo.com/tag/object-oriented/feed/" rel="self" type="application/rss+xml" />
	<link>https://blog.xojo.com</link>
	<description>Blog about the Xojo programming language and IDE</description>
	<lastBuildDate>Tue, 04 Mar 2025 12:52:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>Understanding Interfaces in Object-Oriented Programming with Xojo</title>
		<link>https://blog.xojo.com/2025/01/15/understanding-interfaces-in-object-oriented-programming-with-xojo/</link>
		
		<dc:creator><![CDATA[Gabriel Ludosanu]]></dc:creator>
		<pubDate>Wed, 15 Jan 2025 14:00:00 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Interfaces]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[OOP]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=14294</guid>

					<description><![CDATA[If you are learning Object-Oriented Programming (OOP) or are curious about software development, you have probably heard the term Interfaces. This article explains the concept of&#8230;]]></description>
										<content:encoded><![CDATA[
<p>If you are learning Object-Oriented Programming (OOP) or are curious about software development, you have probably heard the term <a href="https://documentation.xojo.com/getting_started/object-oriented_programming/interfaces.html" data-type="link" data-id="https://documentation.xojo.com/getting_started/object-oriented_programming/interfaces.html" target="_blank" rel="noreferrer noopener">Interfaces</a>. This article explains the concept of Interfaces in OOP, how they work, and provides two code examples.</p>



<h2 class="wp-block-heading" id="what-is-an-interface"><strong>What is an Interface?</strong></h2>



<p>An Interface in Object-Oriented Programming acts as a contract or a blueprint. It defines a set of methods (functions) that a class must implement, but it does not provide the actual implementation of those methods. Think of it as a list of rules or requirements that a class agrees to follow. This approach makes your code more flexible, reusable, and easier to maintain.</p>



<p>For example, imagine you are building a game with different types of characters, such as warriors, wizards, and archers. Each character might have an attack method, but the way they attack is different. An Interface ensures that all characters have an attack method, but each class can implement it in its own unique way.</p>



<h2 class="wp-block-heading" id="why-use-interfaces"><strong>Why Use Interfaces?</strong></h2>



<ol class="wp-block-list">
<li><strong>Flexibility</strong>: Interfaces allow different classes to be used interchangeably if they implement the same Interface. This makes your code adaptable and scalable.</li>



<li><strong>Reusability</strong>: You can write code that works with any class that implements the Interface, promoting code reuse.</li>



<li><strong>Consistency</strong>: Interfaces enforce consistency across classes, ensuring they all have the required methods.</li>



<li><strong>Polymorphism</strong>: Interfaces enable polymorphism, allowing you to handle different objects through the same interface.</li>
</ol>



<h2 class="wp-block-heading" id="how-to-use-interfaces-in-xojo"><strong>How to Use Interfaces in Xojo</strong></h2>



<p>In Xojo, you can create and implement Interfaces to define a set of methods that multiple classes can share, even if they do not share a common superclass. Follow these steps to use Interfaces in Xojo:</p>



<ol class="wp-block-list">
<li><strong>Create an Interface</strong>: Go to the Insert menu in the Xojo IDE and select Class Interface. Give the Interface a descriptive name.</li>
</ol>



<figure class="wp-block-image size-full"><img fetchpriority="high" decoding="async" width="349" height="200" src="https://blog.xojo.com/wp-content/uploads/2025/01/image-2.png" alt="" class="wp-image-14351" srcset="https://blog.xojo.com/wp-content/uploads/2025/01/image-2.png 349w, https://blog.xojo.com/wp-content/uploads/2025/01/image-2-300x172.png 300w" sizes="(max-width: 349px) 100vw, 349px" /></figure>



<ol class="wp-block-list">
<li><strong>Define Methods</strong>: Add methods to the Interface. These methods have no code; they only define the method names and parameters.</li>
</ol>



<figure class="wp-block-image size-full"><img decoding="async" width="260" height="59" src="https://blog.xojo.com/wp-content/uploads/2025/01/image-3.png" alt="" class="wp-image-14352"/></figure>



<ol class="wp-block-list">
<li><strong>Implement the Interface in a Class</strong>: For a class to use the Interface, select the class and from the Inspector, press the Choose button and mark the newly created Interface.</li>
</ol>



<div class="wp-block-columns is-layout-flex wp-container-core-columns-is-layout-9d6595d7 wp-block-columns-is-layout-flex">
<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-full"><img decoding="async" width="297" height="140" src="https://blog.xojo.com/wp-content/uploads/2025/01/image-4.png" alt="" class="wp-image-14353"/></figure>
</div>



<div class="wp-block-column is-layout-flow wp-block-column-is-layout-flow">
<figure class="wp-block-image size-full"><img loading="lazy" decoding="async" width="741" height="532" src="https://blog.xojo.com/wp-content/uploads/2025/01/image-5.png" alt="" class="wp-image-14354" srcset="https://blog.xojo.com/wp-content/uploads/2025/01/image-5.png 741w, https://blog.xojo.com/wp-content/uploads/2025/01/image-5-300x215.png 300w" sizes="auto, (max-width: 741px) 100vw, 741px" /></figure>
</div>
</div>



<h2 class="wp-block-heading" id="example-1-beginner-friendly-interface"><strong>Example 1: Beginner-Friendly Interface</strong></h2>



<p>Let’s start with a simple example. Create an Interface called&nbsp;<code>IAnimal</code>&nbsp;that defines a&nbsp;<code>Speak</code>&nbsp;method. Then, create two classes,&nbsp;<code>Dog</code>&nbsp;and&nbsp;<code>Cat</code>, that implement this Interface.</p>



<h3 class="wp-block-heading" id="step-by-step-guide"><strong>Step-by-Step Guide</strong></h3>



<ol class="wp-block-list">
<li><strong>Define the Interface</strong>
<ul class="wp-block-list">
<li>From the Insert menu, select Class Interface, name it&nbsp;<code>IAnimal</code>&nbsp;and then create a new method&nbsp;<code>Speak</code>.</li>
</ul>
</li>



<li><strong>Create the Dog Class</strong>
<ul class="wp-block-list">
<li>Create a class named&nbsp;<code>Dog</code>&nbsp;(Insert menu &gt; Class) and from the Inspector, make sure to select the Interface. Xojo will automatically add the&nbsp;<code>Speak</code>&nbsp;method to the class so let’s add some code:<code>MessageBox("Woof!")</code></li>
</ul>
</li>



<li><strong>Create the Cat Class</strong>
<ul class="wp-block-list">
<li>Create another class, named&nbsp;<code>Cat</code>&nbsp;(Insert menu &gt; Class) and add the following code to the&nbsp;<code>Speak</code>&nbsp;method:<code>MessageBox("Meow!")</code></li>
</ul>
</li>



<li><strong>Test the Interface</strong></li>
</ol>



<p>Add the following code, to test the Interface, either in the&nbsp;<code>Pressed</code>&nbsp;event of a DesktopButton, or to the&nbsp;<code>Opening</code>&nbsp;event of a DesktopWindow:</p>



<pre class="wp-block-code"><code>Var animals() As IAnimal
animals.Add(New Dog)
animals.Add(New Cat)

For Each animal As IAnimal In animals
  animal.Speak()
Next</code></pre>



<h2 class="wp-block-heading" id="example-2-advanced-interface-with-parameters"><strong>Example 2: Interface with Parameters</strong></h2>



<p>Now, create a new Class Interface called&nbsp;<code>ICalculator</code>&nbsp;that defines a&nbsp;<code>Calculate</code>&nbsp;method. This method takes two numbers as parameters and returns a result. Then, create two classes,&nbsp;<code>Adder</code>&nbsp;and&nbsp;<code>Multiplier</code>, that implement this Interface.</p>



<h3 class="wp-block-heading" id="step-by-step-guide-1"><strong>Step-by-Step Guide</strong></h3>



<ol class="wp-block-list">
<li><strong>Define the Interface</strong>
<ul class="wp-block-list">
<li>Add the following method to define the Interface:<code> Public Function Calculate(a As Integer, b As Integer) As Integer</code></li>
</ul>
</li>



<li><strong>Create the Adder Class</strong>
<ul class="wp-block-list">
<li>Add the following code to the<code>Calculate</code>&nbsp;function:<code> Return a + b</code></li>
</ul>
</li>



<li><strong>Create the Multiplier Class</strong>
<ul class="wp-block-list">
<li>Add the following code to the<code>Calculate</code>&nbsp;function:<code> Return a * b</code></li>
</ul>
</li>



<li><strong>Test the Interface</strong></li>
</ol>



<pre class="wp-block-code"><code>  Var calculators() As ICalculator
  calculators.Add(New Adder)
  calculators.Add(New Multiplier)

  For Each calc As ICalculator In calculators
    MessageBox("Result: " + calc.Calculate(7, 2).ToString)
  Next</code></pre>



<h2 class="wp-block-heading" id="practical-use-cases-for-interfaces">Some <strong>Practical Use Cases for Interfaces</strong></h2>



<p>Interfaces are versatile and can be used in many situations to make your code more modular and easier to maintain. Here are some practical use cases for Interfaces in Object-Oriented Programming:</p>



<h3 class="wp-block-heading" id="data-access-abstraction"><strong>1. Data Access Abstraction</strong></h3>



<p>Abstract data access using Interfaces. For example, define an&nbsp;IDatabase&nbsp;Interface with methods&nbsp;Connect,&nbsp;Query, and&nbsp;Disconnect. Classes that implement this Interface can interact with different database systems (like MySQL, PostgreSQL, SQLite), allowing you to switch databases without changing your core code.</p>



<h3 class="wp-block-heading" id="cross-platform-development"><strong>2. Cross-Platform Development</strong></h3>



<p>Abstract platform-specific functionality using Interfaces. For instance, define an&nbsp;IFileSystem&nbsp;Interface with methods&nbsp;ReadFile&nbsp;and&nbsp;WriteFile. Implement this Interface differently for Windows, macOS, and Linux. Your main code can remain the same across platforms.</p>



<h3 class="wp-block-heading" id="polymorphism"><strong>3. Polymorphism</strong></h3>



<p>Enable polymorphism with Interfaces. This lets you process objects differently based on their actual class, but through the same Interface. This is useful when you want to write code that works with any class that implements a particular Interface.</p>



<h2 class="wp-block-heading" id="key-takeaways"><strong>Key Takeaways</strong></h2>



<ul class="wp-block-list">
<li><strong>Interfaces define a set of methods</strong>&nbsp;that classes must implement.</li>



<li>They make your code&nbsp;<strong>flexible, reusable, and easier to understand</strong>.</li>



<li>Interfaces enforce&nbsp;<strong>consistency</strong>&nbsp;across different classes.</li>



<li>They enable&nbsp;<strong>polymorphic behavior</strong>, allowing you to write generic code.</li>
</ul>



<h2 class="wp-block-heading" id="conclusion"><strong>Conclusion</strong></h2>



<p>Whether you&#8217;re building a simple application or a complex system, interfaces are a powerful tool in your Object-Oriented Programming toolkit, and Xojo makes them incredibly easy to use. They promote better code organization, flexibility, and reusability. Start experimenting with Interfaces in your projects, and you will see how they can improve your code!</p>



<p>Additional info on Interfaces: <a href="https://documentation.xojo.com/getting_started/object-oriented_programming/interfaces.html" target="_blank" rel="noreferrer noopener">https://documentation.xojo.com/getting_started/object-oriented_programming/interfaces.html</a></p>



<hr class="wp-block-separator has-alpha-channel-opacity"/>



<p>If you have questions or want to share your own Interface examples, feel free to start a forum discussion. Happy coding! <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f680.png" alt="🚀" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p><em>Gabriel is a digital marketing enthusiast who loves coding with Xojo to create cool software tools for any platform. He is always eager to learn and share new ideas!</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>The One Person Framework for the Rest of Us</title>
		<link>https://blog.xojo.com/2024/05/02/the-one-person-framework-for-the-rest-of-us/</link>
		
		<dc:creator><![CDATA[Paul Lefebvre]]></dc:creator>
		<pubDate>Thu, 02 May 2024 14:00:00 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Xojo Cloud]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[Development Tools]]></category>
		<category><![CDATA[Enterprise Software]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[One-Person Framework]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Small Business]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=12882</guid>

					<description><![CDATA[The technology and development world is always changing. First released in 1998, Xojo&#8217;s longevity is a testament to its ability and willingness to adapt from&#8230;]]></description>
										<content:encoded><![CDATA[
<p>The technology and development world is always changing. First released in 1998, Xojo&#8217;s longevity is a testament to its ability and willingness to adapt from the early days of desktop apps, to web apps and on to mobile apps.</p>



<p>Throughout that time, software development has generally become more difficult with developers having to learn a wide variety of tools and programming languages, many of which are the hot thing for a short while and then disappear afterwards for the next hot new thing as the cycle repeats.</p>



<p>Up until recently this was not as big a deal for tech companies because they could just hire their way out of the problem. Teams got big and bloated, often because the tools being used were large, complex, rapidly changing and difficult to learn. So the solution, in opposition of the <a href="https://en.wikipedia.org/wiki/The_Mythical_Man-Month">Mythical Man Month</a>, was to throw more people at it. This was feasible because of 0% interest rates and the relative ease of raising capital.</p>



<figure class="wp-block-image"><a href="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c4ae90-9d8d-4b2a-8301-2ee4be611df7_1152x640.jpeg" target="_blank" rel="noreferrer noopener"><img decoding="async" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2Ff4c4ae90-9d8d-4b2a-8301-2ee4be611df7_1152x640.jpeg" alt=""/></a></figure>



<p>But that era is over. Interest rates are no longer historically low and raising capital for companies is now much harder and less desirable than it once was. This means technology companies are reducing staff and hiring more judiciously. Fewer people now have to do more with less.</p>



<p>The idea of a “one person framework” is that there should be a way for a single developer to create software using just one development framework. This is not a new idea, but it is being talked about again because of these recent changes with how technology companies work. In many ways, Xojo is the original one person framework. From its inception, with inspiration from Visual Basic, Xojo let you make complete apps more efficiently without having to also learn other tools, languages or frameworks.</p>



<p>So what can Xojo, as a one person framework, do for you? Xojo lets you build most of the apps your company is likely to need, using only Xojo itself and its easy-to learn object-oriented programming language (which is similar to Visual Basic and Python, languages that many people already are familiar with). Xojo is a cross-platform, integrated development environment (IDE) that combines an object-oriented programming language, visual designer, code editor, debugger and more into one tool and one framework.</p>



<p>With Xojo you can make apps for most of the commonly used platforms that your business is likely to need.</p>



<p><strong>Desktop Apps</strong></p>



<p>Xojo has been a great way to make desktop apps since its inception in 1998. Unlike Java, Electron or other frameworks you’ve seen throughout the years, Xojo makes native apps and can do so for the major desktop platforms: Windows, macOS and Linux. Yes, that includes native ARM and x86 apps as well.</p>



<p>With a single project, you can click one button to have Xojo build separate native apps for each of those platforms. To further drive that point home, the Xojo IDE itself is a desktop app made with Xojo that runs on Windows, macOS and Linux.</p>



<p>With Xojo you have access to many commonly-used controls and the Xojo framework with support for databases, JSON, XML, RegEx, Zip/Unzip, networking and so much more.</p>



<p><strong>Web Apps</strong></p>



<p>Since 2010, Xojo has been able to make web apps. Xojo uses a somewhat unique approach to web apps by running compiled code on the web server. This code communicates to the app running on the web browser using an internal JavaScript framework and Bootstrap for the UI, which you don’t really need to worry about. It’s all handled automatically.</p>



<p>This approach is great for business purposes as it lets you make web apps using a development pattern that is very similar to what is used to make desktop apps.</p>



<p>If you don&#8217;t want to deal with the hassle of managing your own web app server, Xojo even offers Xojo Cloud as a fully managed web hosting service with 1-click deployment of your Xojo web apps.</p>



<p><strong>Mobile Apps</strong></p>



<p>Mobile support first appeared for iOS in 2013 and Android support was recently added in 2023. Using Xojo to make native mobile apps that can be deployed in their respective app stores is yet another way Xojo can help one person make more apps.</p>



<p>A developer that already knows how to use Xojo can jump right into mobile development without having to learn yet another IDE and programming language.</p>



<p><strong>Console Apps</strong></p>



<p>Console apps are text apps that run from the command line. These app are great for automating internal processes or other command-line tools. You can even build Console apps that communicate with other console apps to build a chain of tools for processing or converting data, for example.</p>



<h4 class="wp-block-heading">Xojo Framework</h4>



<p>A single person can create all of the above types of apps because Xojo uses the same programming language for all of them. And as mentioned above, the Xojo framework has many built-in features and is broadly compatible across all the different project types. There are differences, of course, but we strive for consistency and compatibility.</p>



<p>For just a few of its many capabilities, all platforms have the same framework classes and methods for things such as Dictionary, Set, URLConnection, files, SQLite, and most graphics. And speaking of examples, Xojo includes over 400 example projects from which to learn.</p>



<figure class="wp-block-image is-resized"><a href="https://substackcdn.com/image/fetch/f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62cdb62a-4fe8-4d7a-ac61-cf301408c2dc_1152x640.jpeg" target="_blank" rel="noreferrer noopener"><img decoding="async" src="https://substackcdn.com/image/fetch/w_1456,c_limit,f_auto,q_auto:good,fl_progressive:steep/https%3A%2F%2Fsubstack-post-media.s3.amazonaws.com%2Fpublic%2Fimages%2F62cdb62a-4fe8-4d7a-ac61-cf301408c2dc_1152x640.jpeg" alt="" style="width:915px;height:auto"/></a></figure>



<h2 class="wp-block-heading">Could Xojo Work For You?</h2>



<p>As you should now realize, a single developer using Xojo could reasonably create a desktop app (for Windows, macOS and Linux), a web app, and mobile apps for iOS and Android. If you previously had multiple teams of multiple people creating that many apps, then Xojo could really save you a lot of money and time.</p>



<p>Will you use Xojo to make the next Photoshop, FaceBook, Excel or Google Docs clone? Perhaps not, but most companies don&#8217;t create those types of apps. Xojo does a lot, but it does not and cannot do everything. There is a limit to what any single framework can do, otherwise it becomes too large for its own good, collapsing under its own weight.</p>



<p>Instead, most businesses have much different needs and often require specially created software. For business apps, especially bespoke small-business apps, Xojo can often be an ideal solution by allowing apps to be created faster, more easily and at less cost than can be done with other tools. This saves you money and time, both of which are in short supply these days.</p>



<p><a href="https://www.xojo.com/download/">Xojo is free</a> for learning, development and testing! Give it a spin to see what it can do for you.</p>



<p><em>Paul learned to program in BASIC at age 13 and has programmed in more languages than he remembers, with Xojo being an obvious favorite. When not working on Xojo, you can find him talking about retrocomputing at <a href="https://goto10.substack.com" target="_blank" rel="noreferrer noopener">Goto 10</a> and </em>on Mastodon @lefebvre@hachyderm.io.</p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Creating a Number Class</title>
		<link>https://blog.xojo.com/2023/06/13/creating-a-number-class/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Tue, 13 Jun 2023 13:25:48 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Constructor]]></category>
		<category><![CDATA[Method Overload]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=11585</guid>

					<description><![CDATA[In this tutorial I will show you how to create a Number class that can tell you when its value has been actually set, along with other methods to manage how it is used while demonstrating some common object-oriented techniques and features such as operator overloading. You'll be able to create a Number from an Integer, Double or String.]]></description>
										<content:encoded><![CDATA[
<p>In this tutorial I will show you how to create a Number class that can tell you when its value has been actually set, along with other methods to manage how it is used while demonstrating some common object-oriented techniques and features such as operator overloading. You&#8217;ll be able to create a Number from an Integer, Double or String.</p>



<span id="more-11585"></span>



<h3 class="wp-block-heading">The Basics of the Number Class</h3>



<p>Let&#8217;s start with the bare bones of this Number class. Add a new Class to a Xojo project and name it Number in the Inspector Panel.</p>



<p>The value of the Number class is going to be backed by a primitive double property. So add a new Property to the Number class and use the Inspector Panel with the following values:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> Value</li>



<li><strong>Type:</strong> Double</li>



<li><strong>Scope:</strong> Protected</li>
</ul>



<p>We also want to know when a value is set to any of the Number instances, so go ahead and add a new Property to the Class using the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> IsSet</li>



<li><strong>Type:</strong> Boolean</li>



<li><strong>Scope:</strong> Protected</li>
</ul>



<p>And of course we want to have the ability to enable or disable any Number instance, so its assigned value may or may not be taken into account when used in any mathematical operation, for example. Add the third of the properties required by our Number class:</p>



<ul class="wp-block-list">
<li><strong>Name:</strong> Enabled</li>



<li><strong>Type:</strong> Boolean</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>The next step is to add some constructor Methods to our class, so we can create new instances of it covering several common cases:</p>



<ul class="wp-block-list">
<li>Creating a new instance with no value provided: IsSet property will be set to False, and the Enabled property will be set to True.</li>



<li>Creating a new instance with the Integer/Double provided: IsSet property will be set to True, and the Enabled property will be set to True.</li>



<li>Creating a new instance with the numeric value from the provided String: IsSet property will be set to True and the Enabled property will be set to True too.</li>
</ul>



<p>The default constructor for the class will be the one with no parameters. So add a new method to the Number class using the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Constructor</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And type the following line of code in the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Self.Enabled = True</pre>



<p>Add a second method to the class and use the following values in the Inspector Panel (this constructor will create a new instance from the received Integer/Double value):</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Constructor</li>



<li><strong>Parameters:</strong> value As Double</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And type the following lines of code in the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Self.Constructor
Self.Value = value
Self.IsSet = True</pre>



<p>Let&#8217;s add the third constructor, the one taking a String as the parameter. Add a third method to the class using the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Constructor</li>



<li><strong>Parameters:</strong> value As String</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And type the following lines of code in the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Self.Constructor

Self.Value = Double.FromString(value, Locale.Raw)
Self.IsSet = True</pre>



<p>But, wait! Wouldn&#8217;t it be great if we could create new Number instances from another Number instance received as the parameter? Of course it would! So add a new Method again using the following values in the Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Constructor</li>



<li><strong>Parameters:</strong> value As Number</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And type the following lines of code in the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Self.Constructor

If value &lt;&gt; Nil and value.IsSet And value.Enabled Then
  Self.Value = value.Value
  Self.IsSet = True
End If</pre>



<p>By now our class has four special methods, all of them with the same name: Constructor. If defined in any of your classes, this is the method that will be called/executed every time your code uses the New keyword in combination with the class data type. For example:</p>



<pre id="Xojo" class="wp-block-preformatted">Var n As New Number // This calls the by default Constructor.
Var i As New Number(10) // This calls the Constructor taking an Integer/Double as the parameter.
Var s As New Number("120.20") // This calls the Constructor taking a String as the parameter.
Var objNumber As New Number(n) // This calls the Constructor taking a Number instance as the parameter.</pre>



<p>When several methods are added to a class using the same method name but with different number of arguments or arguments data types (or returned values), that is called <strong>Method Overloading</strong> and you will find it in any object-oriented programming language. So our constructor method is overloaded to cover all the expected cases.</p>



<p>As you see, there is nothing fancy in the previous examples. I mean, creating a new instance from the received value in the constructor method is ok, but it would be even better and more simple if we could do something like:</p>



<pre id="Xojo" class="wp-block-preformatted">Var i As Number = 10
Var s As Number = "120.20"
Var objNumber = n</pre>



<h3 class="wp-block-heading">Overloading the Assignment Operator</h3>



<p>The good news is that we can do that! The Xojo programming language has the ability to overload operators too, just like we did with the constructor method! And when it is about to overload the assignment operator we implement the <a href="https://documentation.xojo.com/api/math/operator_convert.html#operator-convert">Operator_Convert</a> method. This one will be called every time our class receives a value from another data type or needs to convert itself to the expected data type; for example:</p>



<pre id="xojo" class="wp-block-preformatted">Var i As Number = 10 // 10 Integer value needs to be converted to a Number instance.
Var intValue As Integer = i // The variable "i" (Number data type) needs to be converted to an Integer data type.</pre>



<p>The most important thing to remember is that when Operator_Convert gets into play, the class Constructor is never called! So the code in the Operator_Convert method implementation needs to take care of properly initialising the instance as you expect.</p>



<p>So let&#8217;s start implementing the Operator_Convert that will be called every time a Number instance needs to be converted to an Integer or Double value.</p>



<p>Add a new method to the Number class using the following values:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_Convert</li>



<li><strong>Return Type:</strong> Double</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And type the following line of code in the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Return If(Self.Enabled, Self.Value, 0)</pre>



<p>Add a second Operator_Convert method, this time change the returned value to a String so our Number instances internal values can be easily assigned to a String variable (or used in other operations with Strings) like this:</p>



<pre id="Xojo" class="wp-block-preformatted">Var i As Number = 10
Var s As String = i</pre>



<p>Use the following values in the associated Inspector Panel and type the line of code in the associated Code Editor:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_Convert</li>



<li><strong>Return Type:</strong> String</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<pre id="Xojo" class="wp-block-preformatted">Return If(Self.Enabled, Self.Value.ToString(Locale.Raw), "")</pre>



<p>We need to overload the Operator_Convert method two more times so it can handle the assignment operation when the received value is at the right of the equal operator instead of the left.</p>



<p>Use the following values in the Inspector Panel for every one of the new two overloaded methods (typing the line(s) of code following each of these):</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_Convert</li>



<li><strong>Parameters:</strong> value As Double</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<pre id="Xojo" class="wp-block-preformatted">Self.Enabled = True
Self.Value = value
Self.IsSet = True</pre>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_Convert</li>



<li><strong>Parameters:</strong> value As String</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<pre id="Xojo" class="wp-block-preformatted">Self.Enabled = True
Self.Value = Double.FromString(value, locale.Raw)
Self.IsSet = True</pre>



<h3 class="wp-block-heading">Overloading the Add Operator</h3>



<p>Assigning values to Number variables or properties or Number instances to Integer / Double or String variables and properties is fine, but not so useful now. So the next step is adding Number instances with another Number instances, Integer / Double data types and also even with all the values from an array. To do this we need to overload the &#8220;+&#8221; (Add) operator implementing the <a href="https://documentation.xojo.com/api/math/operator_add.html#operator-add">Operator_Add</a> method in the Number class.</p>



<p>This will allow us to write code like this:</p>



<pre id="Xojo" class="wp-block-preformatted">Var n2 As Number = i + 10</pre>



<p>Here the &#8220;10&#8221; value is first converted to a Number instance that is going to be added to the &#8220;i&#8221; Number instance and then assigned to the &#8220;n2&#8221; variable.</p>



<pre id="Xojo" class="wp-block-preformatted">Var n3 As Integer = i + 10</pre>



<p>Here the &#8220;10&#8221; value is first converted to a Number instance that is added to the &#8220;i&#8221; number instance and, then, the result converted to an integer value assigned to the &#8220;n3&#8221; variable.</p>



<p>So we need to implement the Operator_Add taking a Number parameter and returning also a Number data type.</p>



<p>Add a new method to the Number class using the following values in the Inspector Panel, and typing the lines of code following them in the associated Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_Add</li>



<li><strong>Parameters:</strong> Value As Number</li>



<li><strong>Return Type:</strong> Number</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<pre id="Xojo" class="wp-block-preformatted">If value &lt;&gt; Nil Then
  Var no As New Number(If(Self.Enabled, Self.Value, 0) + value.Value)
  Return no
End If</pre>



<p>That one works well when we have a Number instance to the left of the add operation, but not when the Number instance is to the right. For that scenarios we need to overload another method: <a href="https://documentation.xojo.com/api/math/operator_addright.html">Operator_AddRight</a>.</p>



<p>Add another method to the Number class using the following values in the associated Inspector Panel:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_AddRight</li>



<li><strong>Parameters:</strong> value As Double</li>



<li><strong>Return Type:</strong> Double</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And type this line of code in the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Return If(Self.Enabled, Self.Value, 0) + value</pre>



<h3 class="wp-block-heading">Adding Number Instances to an Array of Integers</h3>



<p>It would be also really helpful if we could add a Number to an array of integer values or even a Number instance to an array containing other array instances. For example, it would look like this in code:</p>



<pre id="Xojo" class="wp-block-preformatted">Var arrayNumbers() As Number
Var arrayIntegers() As Integer

For z As Integer = 0 To 10
  arrayNumbers.Add(System.Random.InRange(10, 200))
  arrayIntegers.Add(System.Random.InRange(10, 200))
Next

Var z1 As Number = i + arrayNumbers
Var z3 As Integer = i + arrayIntegers</pre>



<p>Of course this implies implementing new overloaded methods both for Convert_Add and Convert_AddRight. These are the implementations for overloading Convert_Add taking an Array of Doubles and also taking an Array of Number instances. I will let the Convert_AddRight implementation to you as exercice:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_AddRight</li>



<li><strong>Parameters:</strong> value() As Integer</li>



<li><strong>Return Type:</strong> Double</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<pre id="Xojo" class="wp-block-preformatted">Var sum As Double

For Each item As Double In values
  sum = sum + item
Next

Return sum + If(Self.Enabled, Self.Value, 0)</pre>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Operator_AddRight</li>



<li><strong>Parameters:</strong> value() As Number</li>



<li><strong>Return Type:</strong> Number</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<pre id="Xojo" class="wp-block-preformatted">Var sum As Double

For Each item As Number In values
  If item &lt;&gt; Nil And item.Enabled Then sum = sum + item.Value
Next

Return sum + If(Self.Enabled, Self.Value, 0)</pre>



<h3 class="wp-block-heading">Unset Number Instances</h3>



<p>The last step in this Number class is to implement the Method that will take care of Unset the instance; that is, kind of &#8220;reset&#8221; state where the value is still not defined.</p>



<p>Add a new Method to the Number class using the following values:</p>



<ul class="wp-block-list">
<li><strong>Method Name:</strong> Unset</li>



<li><strong>Scope:</strong> Public</li>
</ul>



<p>And adding the following lines of code to the associated Code Editor:</p>



<pre id="Xojo" class="wp-block-preformatted">Self.IsSet = False
Self.Value = 0</pre>



<h3 class="wp-block-heading">Conclusion</h3>



<p>As you see, method overloading is a powerful technique as we have done with the constructor method and also with the Operator_Convert, Operator_Add and Operator_AddRight methods. This Number class, with a little work, can be made to to cover other scenarios like the subtract, multiply or divide operations, among others. That wouldn&#8217;t be too difficult based on the implementations already exposed for the overloaded Operator_Add and Operator_AddRight methods. <a href="https://drive.google.com/file/d/1DfRL8WofvmdIp6dM__s_fmnswO4cx6-5/view?usp=share_link">Download</a> the Numbers class project.</p>



<p>Further Reading from the Xojo Blog Archives</p>



<p><a href="https://blog.xojo.com/2016/05/25/methods-overloading-computed-properties-setters-and-getters/">Methods Overloading: Computed Properties, Setters and Getters</a></p>



<p>More on Object-Oriented Programming from the <a href="https://blog.xojo.com/tag/object-oriented/">Xojo Blog</a> and <a href="https://documentation.xojo.com/getting_started/object-oriented_programming/index.html">Xojo Documentation</a></p>



<p><em>Javier Menendez is an engineer at Xojo and has been using Xojo since 1998. He lives in Castellón</em>, <em>Spain and hosts regular Xojo hangouts en español. Ask Javier questions on Twitter at <a href="https://twitter.com/xojoes" target="_blank" rel="noreferrer noopener">@XojoES</a> or on the <a href="https://forum.xojo.com/u/javier_menendez/summary" target="_blank" rel="noreferrer noopener">Xojo Forum</a>.</em></p>



<ul class="wp-block-social-links has-normal-icon-size is-content-justification-center is-layout-flex wp-container-core-social-links-is-layout-16018d1d wp-block-social-links-is-layout-flex"><li class="wp-social-link wp-social-link-facebook  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.facebook.com/goxojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12 2C6.5 2 2 6.5 2 12c0 5 3.7 9.1 8.4 9.9v-7H7.9V12h2.5V9.8c0-2.5 1.5-3.9 3.8-3.9 1.1 0 2.2.2 2.2.2v2.5h-1.3c-1.2 0-1.6.8-1.6 1.6V12h2.8l-.4 2.9h-2.3v7C18.3 21.1 22 17 22 12c0-5.5-4.5-10-10-10z"></path></svg><span class="wp-block-social-link-label screen-reader-text">Facebook</span></a></li>

<li class="wp-social-link wp-social-link-x  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://x.com/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M13.982 10.622 20.54 3h-1.554l-5.693 6.618L8.745 3H3.5l6.876 10.007L3.5 21h1.554l6.012-6.989L15.868 21h5.245l-7.131-10.378Zm-2.128 2.474-.697-.997-5.543-7.93H8l4.474 6.4.697.996 5.815 8.318h-2.387l-4.745-6.787Z" /></svg><span class="wp-block-social-link-label screen-reader-text">X</span></a></li>

<li class="wp-social-link wp-social-link-linkedin  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.linkedin.com/company/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M19.7,3H4.3C3.582,3,3,3.582,3,4.3v15.4C3,20.418,3.582,21,4.3,21h15.4c0.718,0,1.3-0.582,1.3-1.3V4.3 C21,3.582,20.418,3,19.7,3z M8.339,18.338H5.667v-8.59h2.672V18.338z M7.004,8.574c-0.857,0-1.549-0.694-1.549-1.548 c0-0.855,0.691-1.548,1.549-1.548c0.854,0,1.547,0.694,1.547,1.548C8.551,7.881,7.858,8.574,7.004,8.574z M18.339,18.338h-2.669 v-4.177c0-0.996-0.017-2.278-1.387-2.278c-1.389,0-1.601,1.086-1.601,2.206v4.249h-2.667v-8.59h2.559v1.174h0.037 c0.356-0.675,1.227-1.387,2.526-1.387c2.703,0,3.203,1.779,3.203,4.092V18.338z"></path></svg><span class="wp-block-social-link-label screen-reader-text">LinkedIn</span></a></li>

<li class="wp-social-link wp-social-link-github  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://github.com/topics/xojo" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M12,2C6.477,2,2,6.477,2,12c0,4.419,2.865,8.166,6.839,9.489c0.5,0.09,0.682-0.218,0.682-0.484 c0-0.236-0.009-0.866-0.014-1.699c-2.782,0.602-3.369-1.34-3.369-1.34c-0.455-1.157-1.11-1.465-1.11-1.465 c-0.909-0.62,0.069-0.608,0.069-0.608c1.004,0.071,1.532,1.03,1.532,1.03c0.891,1.529,2.341,1.089,2.91,0.833 c0.091-0.647,0.349-1.086,0.635-1.337c-2.22-0.251-4.555-1.111-4.555-4.943c0-1.091,0.39-1.984,1.03-2.682 C6.546,8.54,6.202,7.524,6.746,6.148c0,0,0.84-0.269,2.75,1.025C10.295,6.95,11.15,6.84,12,6.836 c0.85,0.004,1.705,0.114,2.504,0.336c1.909-1.294,2.748-1.025,2.748-1.025c0.546,1.376,0.202,2.394,0.1,2.646 c0.64,0.699,1.026,1.591,1.026,2.682c0,3.841-2.337,4.687-4.565,4.935c0.359,0.307,0.679,0.917,0.679,1.852 c0,1.335-0.012,2.415-0.012,2.741c0,0.269,0.18,0.579,0.688,0.481C19.138,20.161,22,16.416,22,12C22,6.477,17.523,2,12,2z"></path></svg><span class="wp-block-social-link-label screen-reader-text">GitHub</span></a></li>

<li class="wp-social-link wp-social-link-youtube  wp-block-social-link"><a rel="noopener nofollow" target="_blank" href="https://www.youtube.com/c/XojoInc" class="wp-block-social-link-anchor"><svg width="24" height="24" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false"><path d="M21.8,8.001c0,0-0.195-1.378-0.795-1.985c-0.76-0.797-1.613-0.801-2.004-0.847c-2.799-0.202-6.997-0.202-6.997-0.202 h-0.009c0,0-4.198,0-6.997,0.202C4.608,5.216,3.756,5.22,2.995,6.016C2.395,6.623,2.2,8.001,2.2,8.001S2,9.62,2,11.238v1.517 c0,1.618,0.2,3.237,0.2,3.237s0.195,1.378,0.795,1.985c0.761,0.797,1.76,0.771,2.205,0.855c1.6,0.153,6.8,0.201,6.8,0.201 s4.203-0.006,7.001-0.209c0.391-0.047,1.243-0.051,2.004-0.847c0.6-0.607,0.795-1.985,0.795-1.985s0.2-1.618,0.2-3.237v-1.517 C22,9.62,21.8,8.001,21.8,8.001z M9.935,14.594l-0.001-5.62l5.404,2.82L9.935,14.594z"></path></svg><span class="wp-block-social-link-label screen-reader-text">YouTube</span></a></li></ul>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Creating your own ComboBox Subclass with Sorted Menu Items</title>
		<link>https://blog.xojo.com/2021/03/25/creating-your-own-combobox-subclass-with-sorted-menu-items/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Thu, 25 Mar 2021 10:00:00 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[ComboBox]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Xojo API 2.0]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=8206</guid>

					<description><![CDATA[The Xojo ComboBox desktop control is a powerful one. It combines the capabilities of a TextField with the PopupMenu. That means that you can choose from the available options in the associated menu or you can type another value in the ComboBox text field. What about getting the ComboBox to do things not included in the class?]]></description>
										<content:encoded><![CDATA[
<p>The Xojo <a href="https://documentation.xojo.com/api/deprecated/combobox.html"><strong>ComboBox</strong></a> desktop control is a powerful one. It combines the capabilities of a <a href="https://documentation.xojo.com/api/deprecated/textfield.html"><strong>TextField</strong></a> with the <a href="https://documentation.xojo.com/api/deprecated/popupmenu.html"><strong>PopupMenu</strong></a>. That means that you can choose any of the available options from the associated menu (for example those assigned using the <strong>Appearance &gt; Initial value</strong> option in the Inspector Panel) or simply type another value in the ComboBox text field.</p>



<p>What about getting the ComboBox to do things not included in the class? In this tutorial you will learn how to add the text typed by the user as an option in the associated ComboBox menu. We&#8217;ll make sure entries are not duplicated and that they are sorted alphabetically. We&#8217;ll use the <code>AddAllRows</code> method to add a strings array to those already available in the ComboBox menu. In addition, we will add a new method to the ComboBox so you can retrieve all the menu entries as an Array of Strings.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="505" class="wp-image-8212 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2021/03/SortedComboBox-1024x505.png" alt="" srcset="https://blog.xojo.com/wp-content/uploads/2021/03/SortedComboBox-1024x505.png 1024w, https://blog.xojo.com/wp-content/uploads/2021/03/SortedComboBox-300x148.png 300w, https://blog.xojo.com/wp-content/uploads/2021/03/SortedComboBox-768x378.png 768w, https://blog.xojo.com/wp-content/uploads/2021/03/SortedComboBox-1536x757.png 1536w, https://blog.xojo.com/wp-content/uploads/2021/03/SortedComboBox.png 1648w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>


<p>You&#8217;ll find it very convenient that Xojo is an&nbsp;Object-Oriented Programming language as you create any subclass from any existing one. Creating your own specialized subclasses adds tons of extra functionality to <em>any</em> of your projects since they can be used in your other desktop projects. Keep reading to create your own subclasses! <a href="https://bit.ly/2OS99hO">Download this Xojo project</a></p>
<h2>1. Adding a Class to the Project</h2>
<p>Start a new Xojo Desktop project and select the <strong>Insert &gt; class</strong> option from the menu in order to add a new class to the Navigator.</p>
<p>With the new <code>Class1</code> item selected in the Navigator, change the following values in the associated Inspector Panel:</p>
<ul>
<li><strong>Name:</strong> MyComboBox (you may use any other class name you want).</li>
<li><strong>Super:</strong> ComboBox</li>
</ul>
<p>Confirm the changes.&nbsp;You&#8217;ll see how the new class item is now named&nbsp;<code>MyComboBox</code> in the Navigator, while its icon has changed to the one for the ComboBox control.</p>
<h2>2. Adding Event Handlers to the Class</h2>
<p>Keep <code>MyComboBox</code> selected in the Navigator and then select the <strong>Insert &gt; Event Handler</strong> option from the menu. That action will open a new window listing all the available Event Handlers for the ComboBox class and, thus, also for all the subclasses created from it &#8211; like our new class.</p>
<p>Select the <code>Change</code>, <code>KeyDown</code>, <code>Open</code> and <code>LostFocus</code> entries from the list and confirm the changes by clicking on the &#8220;OK&#8221; button. The &#8220;Add Event Handler&#8221; window will close and the selected entries will be added to the <code>MyComboBox</code> item in the Navigator.</p>
<p>Use the <code>KeyDown</code> and <code>LostFocus</code> event handlers to add the text typed by the user as new entries in the ComboBox menu.</p>
<p>Select the <code>KeyDown</code> event under the <code>MyComboBox</code> item in the Navigator and type the following code in the associated Code Editor:</p>
<pre>AddNewEntry(key)
Return RaiseEvent KeyDown(Key)</pre>
<p>The <code>AddNewEntry</code> method will add the new entry to our ComboBox menu.&nbsp;Notice the <code>RaiseEvent KeyDown(Key)</code> line of code. Because our subclass makes use of this event handler, that means that it will not be available to any instances (objects) created from the class, as for example those created when adding the class to a Window in the Layout Editor.</p>
<h2>3. Adding Event Definitions</h2>
<p>With <code>MyComboBox</code> still selected in the Navigator, choose the <strong>Insert &gt; Event Definition</strong> menu option and add the following values in the associated Inspector Panel:</p>
<ul>
<li><strong>Event Name:</strong> KeyDown</li>
<li><strong>Parameters:</strong> Key As String</li>
<li><strong>Return Type:</strong> Boolean</li>
</ul>
<p>This creates the same Event Handler for the class so it can be implemented by any of the instances created from the class, while the <code>RaiseEvent KeyDown(Key)</code> line of code will make sure that this event will also be called for its instances.</p>
<p>Now select the <code>LostFocus</code> event handler from the <code>MyComboBox</code> item in the Navigator and type the following code in the associated Code Editor:</p>
<pre>Me.AddRow(Me.Text)
RaiseEvent LostFocus</pre>
<p>Once again, because we are implementing this event handler, we need to make it available for our class instances. With <code>MyComboBox</code> selected, choose the <strong>Insert &gt; Event Definition</strong> menu option adding the following value in the associated Inspector Panel:</p>
<ul>
<li><strong>Event Name:</strong> LostFocus</li>
</ul>
<p>Now select the <code>Open</code> event handler under <code>MyComboBox</code>, typing the following code in the associated Code Editor:</p>
<pre>Var selectedIndex As Integer = Me.mSelectedRowIndex

Var s() As String = Me.Rows
s.Sort
Me.RemoveAllRows
Me.AddAllRows(s)

If selectedIndex = -1 Then
  Me.mSelectedRowIndex = -1
  Me.Text = ""
End If

RaiseEvent Open</pre>
<p>Once again, we need to create a new Event Definition for the class using the values:</p>
<ul>
<li><strong>Event Name:</strong> Open</li>
</ul>
<p>And repeat the last operation to add the last Event Definition with the following:</p>
<ul>
<li><strong>Event Name:</strong> Change</li>
</ul>
<p>Type this snippet of code in the associated Code Editor for the <code>Change</code> Event Handler:</p>
<pre>Var s() As String = Me.rows
Var n As Integer = s.LastRowIndex

For i As Integer = 0 To n
  If s(i) = Me.Text Then
    Me.mSelectedRowIndex = i
    Exit For
  End If
Next

RaiseEvent Change</pre>
<h2>4. Adding Methods to the Class</h2>
<p>While <code>MyComboBox</code> is still selected in the Navigator, select the <strong>Insert &gt; Method</strong> option from the menu, using the following values in the associated Inspector Panel:</p>
<ul>
<li><strong>Method Name:</strong> AddNewEntry</li>
<li><strong>Parameters:</strong> Key As String</li>
<li><strong>Scope:</strong> Protected</li>
</ul>
<p>And type the following snippet of code in the Code Editor associated with the new method:</p>
<pre>// If return key or tab key is pressed then we add the current text to the menu options

If (key.Asc = 13 Or key.Asc = 9) And Me.Text &lt;&gt; "" Then

  Me.AddRow(Me.Text)

End If</pre>
<p>Now add a second method to the class, using the following values:</p>
<ul>
<li><strong>Method Name:</strong> Rows</li>
<li><strong>Return Type:</strong> String()</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<p>And type the following code in the method&#8217;s Code Editor:</p>
<pre>Var r() As String
Var i As Integer = Me.RowCount - 1

For n As Integer = 0 To i
  r.Add(Me.RowValueAt(n))
Next

Return r</pre>
<h2>&nbsp;</h2>
<h2>5. Overriding existing Methods</h2>
<p>You always want your ComboBox menu items to be sorted alphabetically. And that means taking care of the default functionality of the <code>AddRow</code> and <code>AddAllRows</code> methods. At the same time, we don&#8217;t want the <code>AddRowAt</code> ComboBox method to be available for our subclass (it wouldn&#8217;t make much sense to add a new entry at a particular spot in the menu if it wouldn&#8217;t stay at that position afterwards).</p>
<p>Add a couple of new methods to <code>MyComboBox</code> using the following values:</p>
<ul>
<li><strong>Method Name:</strong> AddAllRows</li>
<li><strong>Parameters:</strong> Items() As String</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<ul>
<li><strong>Method Name:</strong> AddRow</li>
<li><strong>Parameters:</strong> Item As String</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<p>Select the <code>AddAllRows</code> method and type the following code in the associated Code Editor:</p>
<pre>Var selectedItem As String = Me.SelectedRow
Var lastAddedItem As String = items(items.LastIndex).Trim.Titlecase

Var d As New Dictionary

Var s() As String = Me.Rows

For n As Integer = 0 To s.LastIndex

  d.Value(s(n)) = Me.RowTagAt(n)

Next

For Each item As String In items
  If Not d.HasKey(item) And item &lt;&gt; "" Then s.Add(item.Trim.Titlecase)
Next

s.Sort
Me.RemoveAllRows

// Calling the overridden superclass method.
Super.AddAllRows(s)

For n As Integer = 0 To s.LastIndex

  If d.HasKey(s(n)) Then
    Me.RowTagAt(n) = d.Value(s(n))
  End If

  If s(n) = selectedItem Then
    Me.mSelectedRowIndex = n
  End If

  If s(n) = lastAddedItem Then
    Me.mLastAddedRowIndex = n
  End If

Next</pre>
<p>Select next the <code>AddRow</code> method and type the following code in the associated Code Editor:</p>
<pre>If item = "" Then Return

item = item.Trim.Titlecase

If Not Me.HasMember(item) Then

  Var selectedItem As String = Me.SelectedRow

  Var d As New Dictionary

  Var s() As String = Me.rows

  For n As Integer = 0 To s.LastIndex

    d.Value(s(n)) = Me.RowTagAt(n)

  Next

  s.Add(item)
  s.Sort

  Me.RemoveAllRows
  Super.AddAllRows(s)

  // Let's restore the original rowtags to their new spot in the menu

  For n As Integer = 0 To s.LastIndex

    If d.HasKey(s(n)) Then
      Me.RowTagAt(n) = d.Value(s(n))
    End If

    If s(n) = selectedItem Then
      Me.mSelectedRowIndex = n
    End If

    If s(n) = item Then
      Me.mLastAddedRowIndex = n
    End If

  Next
End If</pre>
<p>We still need a last method to our class that will check if an item is already among the current entries for the menu. So, add it using the following values:</p>
<ul>
<li><strong>Method Name:</strong> HasMember</li>
<li><strong>Parameters:</strong> Item As String</li>
<li><strong>Return Type:</strong> Boolean</li>
<li><strong>Scope:</strong> Protected</li>
</ul>
<p>Type the following code in the associated Code Editor:</p>
<pre>Var b As Boolean

For Each s As String In Me.Rows
  If s = item Then
    b = True
    Exit For
  End If
Next

Return b</pre>
<h2>&nbsp;</h2>
<h2>6. Overriding Existing Properties</h2>
<p>Because we are sorting the entries in the menu, we also need to make sure that the <code>LastAddedRowIndex</code> and <code>SelectedRowIndex</code> properties are pointing to the right item and selected row index. That means that we need to override the current functionality of the base class.</p>
<p>In order to do that, select the <strong>Insert &gt; Property</strong> option from the menu with the following values in the associated Inspector Panel:</p>
<ul>
<li><strong>Name:</strong> LastAddedRowIndex</li>
<li><strong>Type:</strong> Integer</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<p>With the new property still selected in the <code>MyComboBox</code> class, access the contextual menu and choose the <code>Convert to Computed Property</code> option. That action will add a <code>Get</code> and <code>Set</code> method under the property item, in addition of adding a new <code>mLastAddedRowIndex</code> property whose scope will be Private.</p>
<p>Let&#8217;s add the second Property using these values:</p>
<ul>
<li><strong>Name:</strong> SelectedRowIndex</li>
<li><strong>Type:</strong> Integer</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<p>Once again, with the just added property still selected under the <code>MyComboBox</code> class in the Navigator, select the <code>Convert to Computed Property</code> option from the contextual menu. Then select the <code>Set</code> method under <code>SelectedRowIndex</code> and type the following code in the associated Code Editor:</p>
<pre>Var r() As String = Me.Rows

If value &gt; r.LastIndex Then Raise New OutOfBoundsException

If value &gt; 0 Then
  Me.Text = r(value)
Else
  value = -1
  Me.Text = ""
End If

mSelectedRowIndex = value
RaiseEvent Change</pre>
<p>This is the code that will be executed every time our code sets a new value to the property, so we need to make sure it is between the allowed range, raising a new <code>OutBoundsException</code> exception if it is beyond the limits of the available entries in the menu.</p>
<p>At the same time, if it is not a positive number that would mean that the we don&#8217;t want to select any entry, so we can set the text property of the ComboBox to an empty string and the inner <code>mSelectedRowIndex</code> value to -1.</p>
<h2>7. Putting it to Work</h2>
<p>Now that you have the ComboBox subclass ready to work, choose the <code>Window1</code> item in the Navigator in order to access its Layout Editor. Next, drag the <code>MyComboBox</code> item from the Navigator and drop it over the <code>Window1</code> in the Layout Editor. You can use the layout guides in order to keep it aligned with the window margins.</p>
<p>With the <code>MyCombobox1</code> item still selected in the Layout Editor, access its Panel Inspector in order to assign some initial values for its menu from the <strong>Appearance &gt; Initial Value</strong> section. For our example, you could enter <code>"One"</code>, <code>"Two"</code> and <code>"Three"</code> as the values in the associated editor. And you can&nbsp;also enable the autocomplete option for the control under <strong>Behavior &gt; Allow <a href="https://documentation.xojo.com/api/deprecated/combobox.html#combobox-allowautocomplete">Auto Complete</a></strong>.</p>
<p>Run the example app and observe how every new entry made by the user is added to those already available in the ComboBox menu, while keeping them sorted.</p>
<p>You can add more UI controls to Window1 in order to use the other methods and properties, or just <a href="https://bit.ly/2OS99hO">download the example project</a> and run it from the Xojo IDE. I hope you have found this tutorial helpful and that you can learn from it and adapt it to your needs. If you have questions about this post or the Xojo programming language you can find me at the <a href="https://forum.xojo.com/u/javier_menendez/summary">Xojo Forums</a> and on Twitter <a href="https://twitter.com/xojoes">@xojoES</a>.</p>


<p></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>14 Days: A Beginner&#8217;s Gateway to Coding</title>
		<link>https://blog.xojo.com/2020/03/23/14-days-a-beginners-guide-to-coding/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Mon, 23 Mar 2020 21:39:19 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Beginner Tips]]></category>
		<category><![CDATA[Intro to Xojo Programming Textbook]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=6778</guid>

					<description><![CDATA[If you are going to add programming to your skillset, it's logical to begin with a language that makes it simple to learn the basics of programming. Let me show you a learning path you can follow over 14 days that is aimed at giving you a confident and capable to start to programming. ]]></description>
										<content:encoded><![CDATA[
<p>It&#8217;s always a good time to learn something new! And maybe you have some free time on your hands now? We know our screen time is up this year, so let&#8217;s put that extra screen time to good use and learn a new skill &#8211; programming. If you are going to add programming to your skillset, it&#8217;s logical to begin with a language that makes it simple to learn the basics of programming. Let me show you a learning path you can follow over 14 days that is aimed at giving you a confident and capable to start to programming. </p>



<span id="more-6778"></span>



<h2 class="wp-block-heading">Day 1: Wet your Feet!</h2>



<p><a href="https://www.xojo.com/download/">Download Xojo</a> to your platform of choice, Mac, Windows or Linux. Xojo is free for learning and development, you can write, run and debug your apps all without a license. Everyday in  the 14 Day Guide can be done without  a Xojo license. So go ahead and download Xojo to get started!</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Tip</strong>: You can find the Xojo System Requirements for your operating system (OS) of choice <a href="https://documentation.xojo.com/resources/system_requirements_for_current_release.html">here</a>.</mark></p>
</blockquote>



<p>Once downloaded, launch the Xojo IDE (Independent Development Environment, i.e. the Xojo app) and you will be presented with a window pointing you to many of Xojo&#8217;s resources. I&#8217;ll show you where to start this time, so go ahead and click <em>Start Using Xojo</em> in the bottom left corner to get to the Project Chooser.</p>



<figure class="wp-block-image size-large"><img loading="lazy" decoding="async" width="1024" height="789" src="https://blog.xojo.com/wp-content/uploads/2023/08/ProjectChooser-1024x789.png" alt="" class="wp-image-11892" srcset="https://blog.xojo.com/wp-content/uploads/2023/08/ProjectChooser-1024x789.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/08/ProjectChooser-300x231.png 300w, https://blog.xojo.com/wp-content/uploads/2023/08/ProjectChooser-768x592.png 768w, https://blog.xojo.com/wp-content/uploads/2023/08/ProjectChooser-1536x1184.png 1536w, https://blog.xojo.com/wp-content/uploads/2023/08/ProjectChooser.png 1762w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>



<p>If you&#8217;re interested in developing Desktop apps, point your browser to the <a href="https://documentation.xojo.com/getting_started/quickstarts/desktop_quickstart.html">Xojo Desktop QuickStart</a>&nbsp;and follow the steps to  build a simple desktop application with Xojo in 30 minutes or less. You can do the same both for <a href="https://documentation.xojo.com/getting_started/quickstarts/web_quickstart.html">Web</a> and <a href="https://documentation.xojo.com/getting_started/quickstarts/ios_quickstart.html">iOS</a> projects if you are interested in starting there. You can find resources in other languages in the <a href="https://documentation.xojo.com/Resources:International">International</a> section of the Xojo Dev Center.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Video</strong>: If you prefer to video, there are videos you can listen to as your follow the QuickStarts on <a href="https://www.youtube.com/c/XojoInc">Xojo&#8217;s YouTube channel</a>.</mark></p>
</blockquote>



<p>The QuickStarts will introduce you to main concepts and have you writing your first lines of code in Xojo! If you have extra time today, try the <a href="https://documentation.xojo.com/getting_started/tutorials/index.html">Tutorials</a> next. They are just a bit more in depth than the QuickStart and will likely take you less than an hour to complete. The tutorials focus on further familiarizing you with the main areas in Xojo like the Editors and how to layout and interact with some of the native controls.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><strong>Tip:</strong> After completing these, try to reproduce the projects without relying on the documentation. Doing is a great way to learn, so try to do your own simple project from scratch. </p>
</blockquote>



<h2 class="wp-block-heading">Day 2: Getting Programming Basics</h2>



<p>Whether you know other programming languages or if Xojo is your first language to learn, understanding the fundamentals of programming will give you a leg up. For day 2, I recommend that you download the <a href="https://www.xojo.com/resources/learn.php"><em>Introduction to Programming with Xojo</em></a> textbook (available in PDF and iBooks formats) and work along with the first 2 chapters.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large is-resized"><a href="https://www.xojo.com/resources/learn.php"><img loading="lazy" decoding="async" src="https://blog.xojo.com/wp-content/uploads/2020/12/Ebook-Cover-1.png" alt="" class="wp-image-7945" width="154" height="241" srcset="https://blog.xojo.com/wp-content/uploads/2020/12/Ebook-Cover-1.png 512w, https://blog.xojo.com/wp-content/uploads/2020/12/Ebook-Cover-1-192x300.png 192w" sizes="auto, (max-width: 154px) 100vw, 154px" /></a></figure>
</div>


<p>This book will introduce you to more of the Xojo language and walk you through writing projects complete with code snippets that will help you grasp the basic concepts behind: variables, programming structures like loops, functions and parameters, plus you&#8217;ll get your first contact with the Xojo Debugger (the Debugger allows you to find and fix bugs in your app).</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Tip:</strong> Don&#8217;t get discouraged if you don&#8217;t know a word or concept. You are learning a new language after all. Take a moment to Google it, yep, Google it, programmers Google things all the time or search the </mark><a href="https://documentation.xojo.com">Xojo Documentation</a><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color">.</mark></p>
</blockquote>



<p>It will take some time to get through the content and all the examples in the textbook. The important thing is not how much you advance in one day, but to understand and retain what you learned! Don&#8217;t get down if you feel like you still don&#8217;t understand what the code does; it&#8217;s only day 2!</p>



<h2 class="wp-block-heading">Day 3: Find Out More</h2>



<p>On Day 3, continue with the <em>Introduction to Programming with Xojo</em> <a href="https://www.xojo.com/resources/learn.php">textbook</a>.  Try and get through chapter 5 today.  Perhaps some broader aspects of coding are coming into focus. While going through the chapters of the textbook, you might have questions or want more information. </p>



<p>As with the <em>Introduction to Programming with Xojo</em> book, you will not read the Documentation in one day! But it will help you as you develop your own apps that put into practice what you have learned from the QuickStart, Tutorials and textbook. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Watch The Video:</strong> Watch the first video in our <a href="https://youtube.com/playlist?list=PLPoq910Q9jXiG-ruH4DVc49ER0n_tTZAA">Programming with Xojo Course</a>. It&#8217;s a on-going series of videos focused on taking you from zero coding knowledge to writing your own apps. And it&#8217;s just another way you can learn how to code with Xojo.</mark></p>
</blockquote>



<h2 class="wp-block-heading">Day 4: Get Object-Oriented!</h2>



<p>There are many Object-Oriented programming languages and OOP languages offer many advantages. As you have hopefully already learned, the Xojo language is OOP and that is one of the reasons it can be easy to grasp and start using. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Tip:</strong> <a href="https://en.wikipedia.org/wiki/Object-oriented_programming">Object-Oriented</a> programming (OOP) is a style of programming based on &#8220;objects&#8221;, which are data structures that contain data (properties) and code (methods). These data structures are called &#8220;classes&#8221;. Classes are the fundamental building blocks of all Xojo applications.</mark></p>
</blockquote>



<p>To speed up that way of thinking, today I recommend you that you watch the <a href="https://www.youtube.com/watch?v=qaELXLMv3MQ">Understanding Object-Oriented Programming with Xojo</a> video. It&#8217;s 1 hour long so you should be able to also get through chapter 9 of the textbook <img src="https://s.w.org/images/core/emoji/17.0.2/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>



<p>You want to start thinking and writing code so you can reuse it and evolve it without breaking what you have already done. Here is a good (and short!) <a href="https://documentation.xojo.com/topics/user_interface/creating_your_own_controls.html">tutorial that puts this into practice</a>. It will teach you how to do one of the first things most developers want to do &#8211; modify the behavior of an existing control so it fits a specific need&nbsp;<em>or</em> create your own controls.</p>



<h2 class="wp-block-heading">Day 5: Look at the Examples!</h2>



<p>At this point you should feel pretty comfortable using Xojo and writing simple apps using the Xojo language.</p>



<p>There are 400 project examples included with Xojo. If you are looking for an example about how to do something specific, these are a great starting point. Use the example code &#8220;as-is&#8221; then modify the code to adapt it to your particular needs or simply to learn a particular technique.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Tip:</strong> Not quite comfortable yet? Take an extra day and do a <a href="https://documentation.xojo.com/getting_started/tutorials/index.html">Tutorial</a> if you didn&#8217;t already, or try the Programming with Xojo <a href="https://youtube.com/playlist?list=PLPoq910Q9jXiG-ruH4DVc49ER0n_tTZAA">Video Course</a>.</mark></p>
</blockquote>



<h2 class="wp-block-heading">Day 6: Databases</h2>



<p>Modern apps make use of a wide variety of technologies and one of the most common you will hear about is databases. For a lot of projects, databases are a must. A <a href="https://en.wikipedia.org/wiki/Database">database</a> is &#8220;an organized collection of data generally stored and accessed electronically from a computer system.&#8221; Xojo comes bundled with the SQLite database and supports PostgreSQL, MySQL, Microsoft SQL Server and Oracle databases. Plus, you can use ODBC to connect to other databases such as Access, FoxPro, FileMaker, Firebird and even IBM iSeries.</p>



<p>The Xojo framework is large enough so you can find the classes you need, ready to use. Since Xojo comes bundled with SQLite, that&#8217;s a great place to start. Today, I recommend you do the &#8220;<a href="https://documentation.xojo.com/topics/databases/supported_engines/sqlite/sqlite_basics.html">SQLite Basics</a>&#8221; and &#8220;<a href="https://documentation.xojo.com/GettingStarted:SQLiteDatabase_and_iOSSQLiteDatabase_for_Beginners">SQLiteDatabase and iOSSQLiteDatabase for Beginners</a>&#8221; lessons that will teach you from the ground up, no previous experience working with databases is required. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Using Other Databases:</strong> In addition, there are <a href="https://www.youtube.com/watch?v=18juWHGytFg&amp;list=PLPoq910Q9jXhRoPw0_mHKdVUKPXpL9TKV">videos in the Xojo Database playlist</a>, topics range from designing a database, to the creation of a database based application, PostgreSQL, ODBC, or even creating REST web services in order to work with remote databases from mobile devices. </mark></p>
</blockquote>



<h2 class="wp-block-heading">Day 7: Create Your Own Project</h2>



<p>Doing is an excellent way to learn so today let&#8217;s start to create your own project from scratch. Start simple, something basic that can grow with you as a developer &#8211; a notes app, a shopping list, a time tracker&#8230;</p>



<p>Today is not about reproducing examples, but rather putting together all the pieces you&#8217;ve learned so far to make a new app. Sure you&#8217;ll may have questions about how to do something, so try using the multiple help features in the Xojo IDE. For example:</p>



<ul class="wp-block-list">
<li><strong>Autocompletion</strong>: Start typing and the IDE will help you to autocomplete the name of a function, method, class or object instance. You don&#8217;t have to remember every class or object property, press the tab key and a popup menu will list them for you.</li>



<li><strong>Controls</strong>: Remember that the lower area of the Library panel offers information about the purpose of every user interface (UI) control, and that they are grouped by functionality; you only need to put the mouse pointer over to get a description about what they do.</li>



<li><strong>Event Handlers</strong>: Not sure about the Event Handler you need to implement in a control so it reacts to the user&#8217;s actions as you expect? The Add Handler panel is very descriptive about the mission of every supported Event for a particular control. Just go through them and read the provided information.</li>



<li><strong>Contextual help</strong> is everywhere: put the mouse pointer over the name of a function and you&#8217;ll see the expected parameters and their types.</li>



<li><strong>Global Help</strong>: Of course you can access the global help to get to the documentation for all the available Classes, concepts, datatype and language keywords among other topics. In addition, the documentation is full of example code snippets you can simply copy and paste in the Code Editor to implement (probably with some modifications to adapt it to your app).</li>
</ul>



<h2 class="wp-block-heading">Day 8: Get Stuck Unstuck</h2>



<p>How&#8217;s your first project going? Don&#8217;t be down if it&#8217;s rough. It&#8217;s inevitable that you will reach a point when the information available is not enough to solve a particular problem. When that happens, I recommend <a href="http://forum.xojo.com">joining the Xojo Forum</a> and post your question there. Don&#8217;t be shy, the Xojo community is one of the best developer groups around. It&#8217;s likely you&#8217;re not the first one facing a particular problem and you may find your question and the answer already in the Forum! With the right search the solution could be in front of you in a few seconds!</p>



<p>Also check out this blog post on various ways to <a href="https://blog.xojo.com/2017/11/13/how-to-get-unstuck/">Get Unstuck</a>.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Pro</strong> <strong>Tip:</strong> Ask for help after you tried everything you already know and after looking for the answer in the Xojo Dev Center! People appreciate that you have tried to figure it out on your own first and it helps to let them know what you have already tried that didn&#8217;t work.</mark></p>
</blockquote>



<h2 class="wp-block-heading">Day 9: Be Cross-Platform</h2>



<p>Remember that Xojo is a cross-platform development tool. That means that you can develop <em>for</em> any platform <em>from</em> your preferred development platform, Mac, Windows or Linux. </p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>Note</strong>: A Mac is required to compile your apps for macOS. You can develop your desktop app on a Windows or Linux computer but ultimately, testing and compiling for macOS must be done from a Mac. A Mac is required for developing <em>and</em> compiling an iOS application.</mark></p>
</blockquote>



<p>The ability to write one app,  with one set of code, and deploy it for 3 operating systems is pretty excellent! Of course, you will likely need to do some amount of testing (and debugging) on each OS. There are several solutions that let you create virtual machines running on other operating systems. For example, you can choose between Parallels, VMware<strong> </strong>Fusion or VirtualBox on macOS.&nbsp;Any of these will let you install Windows and/or Linux on your Mac computer.&nbsp;</p>



<p>Creating a cross-platform app also means that you will need to make sure that the user interface behaves as expected on each different operating system. At some point, your app might need to change slightly for a particular operating system. For example, on Windows you might want to use the Registry, but on Mac you might want to use a plist. You can handle these special cases using&nbsp;<a href="http://documentation.xojo.com/topics/os_information/conditional_compilation.html">conditional compilation</a>. You can also use Target Attributes in the Attributes section of the Inspector Panel for items like classes, methods or properties, to decide what should be compiled for a particular target.</p>



<p>If you haven&#8217;t already try and finish the textbook today.</p>



<h2 class="wp-block-heading">Day 10: Make the Xojo IDE Fit You</h2>



<p>As you spend more time using Xojo, you&#8217;ll feel the need to change some preferences so they best fit the way you use it. Take a deep look at the Preference panels; you can chose your code font of choice, the <a href="https://blog.xojo.com/2017/04/05/menu-shortcut-editor/">keyboard shortcuts</a> you prefer to use, the <a href="https://blog.xojo.com/2019/09/05/navigator-keyboard-shortcuts/">Navigator behavior</a>, you can even choose your <a href="https://blog.xojo.com/2018/03/13/make-it-your-way-xojothemes/">theme</a> for the IDE.</p>


<div class="wp-block-image">
<figure class="aligncenter size-large"><img loading="lazy" decoding="async" width="1024" height="656" src="https://blog.xojo.com/wp-content/uploads/2023/08/XojoPreferences-1024x656.png" alt="" class="wp-image-11893" srcset="https://blog.xojo.com/wp-content/uploads/2023/08/XojoPreferences-1024x656.png 1024w, https://blog.xojo.com/wp-content/uploads/2023/08/XojoPreferences-300x192.png 300w, https://blog.xojo.com/wp-content/uploads/2023/08/XojoPreferences-768x492.png 768w, https://blog.xojo.com/wp-content/uploads/2023/08/XojoPreferences-1536x984.png 1536w, https://blog.xojo.com/wp-content/uploads/2023/08/XojoPreferences.png 1624w" sizes="auto, (max-width: 1024px) 100vw, 1024px" /></figure>
</div>


<p>These preferences, among others, will let you feel more comfortable and even code faster! For example, what if you prefer to have the Inspector Panel and Library in their own floating panels? Would that make a difference for you? And what if you edit the keyboard shortcuts so they fit better with the layout of your keyboard?</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>More</strong> <strong>From the Xojo Blog:</strong> <a href="https://blog.xojo.com/2017/04/05/menu-shortcut-editor/">Menu Shortcut Editor</a> and <a href="https://blog.xojo.com/2013/11/15/xojo-navigator-tip-show-or-hide/">Xojo Navigator Tip- Show or Hide</a></mark></p>
</blockquote>



<h2 class="wp-block-heading">Day 11: Advanced Topics</h2>



<p>As you move on in your 14 day learning path, let&#8217;s focus on more advanced topics for the development of more complex products. For example, <a href="https://documentation.xojo.com/topics/xojoscript/introduction_to_xojoscript.html">XojoScript</a> lets you execute new Xojo code dynamically in an already compiled application.</p>



<p>From the code and language sides, you should definitely learn about Design Patterns. The Xojo Blog has some great introductory posts about the <a href="https://blog.xojo.com/2016/06/08/design-patterns-in-xojo-singleton/">Singleton</a>&nbsp;and <a href="https://blog.xojo.com/2016/06/15/design-patterns-in-xojo-observer-part-1/">Observer</a> Design Patterns, among others.</p>



<p>Take a look at Modules, Interfaces, Delegates, Enumerations, Declares and the related Xojo data types that let you access external libraries from your code. Is also a good point in time to explore differences like Internal or External project Items, adding your own properties to the Inspector Panel, and the use of Git, SVN or other source control solutions. </p>



<p>In addition to debugging your apps, Xojo includes a feature that will Analyze and Profile the execution of your project, letting you know where your app bottlenecks are (if any) so you can put your efforts on optimizing that portions of code.</p>



<blockquote class="wp-block-quote is-layout-flow wp-block-quote-is-layout-flow">
<p><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"><strong>From the Xojo Blog:</strong> The </mark><a href="https://blog.xojo.com">Xojo Blog</a><mark style="background-color:rgba(0, 0, 0, 0)" class="has-inline-color has-vivid-cyan-blue-color"> has a lot of posts that offer examples on more advanced concepts and topics. </mark></p>



<p></p>
</blockquote>



<h2 class="wp-block-heading">Day 12: Let&#8217;s Review</h2>



<p>You&#8217;ve learned a lot in the last 12 days, so let&#8217;s take a breath today. Take some time to review, maybe look up in the <a href="http://documentation.xojo.com">Documentation</a> that question you were thinking about in the shower yesterday. Or watch some of the videos in the Programming with Xojo <a href="https://youtube.com/playlist?list=PLPoq910Q9jXiG-ruH4DVc49ER0n_tTZAA">Video Course</a>. Take today to reinforce and refine the skills you have acquired. And don&#8217;t forget to pat yourself on the back for a job well done!</p>



<h2 class="wp-block-heading">Day 13: Refactorization</h2>



<p>Compare the code you wrote the first days with the one you&#8217;re writing now with all the acquired knowledge. I bet you&#8217;ll find something that can be done better. Do it! Don&#8217;t hesitate to rewrite your code and optimize it so it runs faster, better and is more reusable, making it easier to maintain and evolve.</p>



<p>This is known as refactorization, aka spit and polish, and there are many books focused on the topic. Xojo includes some options that will help you to do that, mostly from the contextual menu, every time you select an item in the Navigator a block of code or even using the Search and Replace panel.</p>



<h2 class="wp-block-heading">Day 14: Keep Learning!</h2>



<p>Don&#8217;t stop here, coding is a journey! As you advance writing code, you&#8217;ll feel the need to learn new things, and there are tons of <a href="https://www.xojo.com/resources/">resources</a> at your disposal! </p>



<p>A good place to visit is the <a href="http://forum.xojo.com">Community</a><a href="http://documentation.xojo.com/Xojo_Documentation:Community_Portal"> Portal</a> and also the <a href="https://documentation.xojo.com/Resources:Open_Source_Projects">Open</a><a href="https://documentation.xojo.com/resources/third_party/open_source_projects.html"> </a><a href="https://documentation.xojo.com/Resources:Open_Source_Projects">Source</a> section of the Xojo Dev Center. Here you&#8217;ll find a number of ready-to-use libraries from other reputed Xojo developers, ready to download, inspect and, thus, to learn from!</p>



<hr class="wp-block-separator has-css-opacity"/>



<p>We hope you have enjoyed our 14 day coding adventure. Tweet to us <a href="https://twitter.com/xojo">@xojo</a> and let us know how it&#8217;s going and if you have any questions, reach out to us at <a href="mailto:hello@xojo.com">hello@xojo.com</a>.</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>3 Steps to Seamlessly Deploy SQLite Projects on Desktop, Web &#038; iOS</title>
		<link>https://blog.xojo.com/2020/03/17/3-steps-to-seamlessly-deploy-sqlite-projects-on-desktop-web-ios/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Tue, 17 Mar 2020 10:00:25 +0000</pubDate>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[Desktop]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[Web]]></category>
		<category><![CDATA[Xojo Cloud]]></category>
		<category><![CDATA[Deployment]]></category>
		<category><![CDATA[Mobile]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQLite]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=6725</guid>

					<description><![CDATA[This tutorial will show you how to deploy your SQLite based projects so they behave right on Desktop, Web and iOS, copying the database file to the right place on every target.]]></description>
										<content:encoded><![CDATA[<p>This tutorial will show you how to deploy your SQLite based projects so they behave right on Desktop, Web and iOS, copying the database file to the right place on every target.</p>
<h2>1. Adding the database file</h2>
<p>You probably created your SQLite database file using an external editor; so first add that file to your Xojo project.</p>
<p>You can do that in several ways, but usually it&#8217;s best to add a Build Step. This way, the file will be added automatically to the folder of your choice every time you compile your app. <em>Bonus: Doing this allows you to decide to use different paths when debugging or deploying your app.</em></p>
<p>In order to add a new Build Step in a <span style="text-decoration: underline;">Desktop</span> project select the target in the Build Settings then, from the contextual menu, choose the &#8220;Add to Build Settings &gt; Build Step &gt; Copy Files&#8221; option.</p>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6726 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.37.51-300x70.png" alt="" width="300" height="70" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.37.51-300x70.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.37.51.png 655w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p>The previous action will give you access to the Inspector Panel for the just-added item where you will be able to type a name for the Build Step, choose if the copy file action will be executed both for debugging or deployment and, most importantly, choose the location where the file should be copied when the app compiles.</p>
<p>In fact, the Destination menu contains a number of typical paths (or most relevant folders). For example, a good Destination option would be &#8220;Resources Folder&#8221;. Of course, don&#8217;t forget to add the database file itself using the buttons on the Build Editor toolbar.</p>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6727 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.42.04-300x173.png" alt="" width="300" height="173" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.42.04-300x173.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.42.04.png 359w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p>When you&#8217;re working with a <span style="text-decoration: underline;">Web project</span>, you&#8217;ll find exactly the same behavior, even if you choose to deploy with Xojo Cloud.</p>
<p>On <span style="text-decoration: underline;">iOS</span>, the only change is that you&#8217;ll have to choose the icon with an iPhone picture in it in order to access the Build Step contextual menu; in addition to the fact that every added resource needs to be signed with a certificate.</p>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6728 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.43.45-300x47.png" alt="" width="300" height="47" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.43.45-300x47.png 300w, https://blog.xojo.com/wp-content/uploads/2020/03/Screenshot-2020-03-04-at-12.43.45.png 608w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<h2>2. Copying the database file to a &#8220;Working&#8221; folder</h2>
<p>You may think that the previous step is all you need to do, because if the database file is already copied in a well know path then you only need to provide that path as the DatabaseFile property on a new SQLiteDatabase or iOSSQLiteDatabase instance. But this is not the case.</p>
<p>They are many reasons you shouldn&#8217;t do that, specifically because the database would be open in read/write mode and if you write to that database file inside an application bundle, then you&#8217;ll be modifying a resource that would invalidate any certificate signature on your app.</p>
<p>The best thing to do is o detect every time you run the app if the database file has already been copied from the app bundle (or folder) into a target folder that doesn&#8217;t have an access problem when it is time to use the database. The Application Support folder is a good place for Desktop apps, while the Documents folder is fine for Xojo Cloud and iOS apps.</p>
<p>For example, if our database file is named &#8220;EddiesElectronics.sqlite&#8221; and our app name is &#8220;Xojotest&#8221;, then we can add the following code fragment into the Open Event Handler of a Desktop app:</p>
<pre>Var source As FolderItem = SpecialFolder.Resource("EddiesElectronics.sqlite")
Var name As String = app.ExecutableFile.name.NthField(".",1)

// We check if there is a folder with the App name in special Application Data
// if not, we create it and copy the database file from Resources bundle/directory
If Not (SpecialFolder.ApplicationData.Child(name).Exists And SpecialFolder.ApplicationData.Child(name).IsFolder) Then SpecialFolder.ApplicationData.Child(name).CreateFolder
If Not SpecialFolder.ApplicationData.child(name).child(source).exists Then source.CopyTo(SpecialFolder.ApplicationData.Child(name))

Try
  // Create a SQLiteDatabase instance and try to open our database file from
  // the path
  pDatabase = New SQLiteDatabase
  pDatabase.DatabaseFile = SpecialFolder.ApplicationData.Child(name).Child("EddiesElectronics.sqlite")
  pDatabase.Connect

Catch e As DatabaseException
  MessageBox e.Message
End Try</pre>
<p>For an iOS app, the code would be:</p>
<pre>Var source As Xojo.IO.FolderItem = xojo.io.SpecialFolder.GetResource("EddiesElectronics.sqlite")

// We check if there is our database file already copied on the Documents Sandbox folder
// if not, we copy the database file from Resources bundle/directory
If Not xojo.io.SpecialFolder.Documents.Child("EddiesElectronics.sqlite").Exists Then
  source.CopyTo(xojo.io.SpecialFolder.documents)
End If

Try
  // Create a SQLiteDatabase instance and try to open our database file from
  // the path
  pDatabase = New iosSQLiteDatabase

  Var f As FolderItem = xojo.io.SpecialFolder.Documents
  pDatabase.DatabaseFile = f.Child("EddiesElectronics.sqlite")
  Call pDatabase.Connect

Catch e As RuntimeException
  MessageBox e.Reason
End Try</pre>
<p>If you&#8217;re working on Xojo Cloud, the code will be even shorter. First, make sure that the Copy File Build Step has the following values in the Inspector Panel:</p>
<ul>
<li><strong>Destination:</strong> Contents Folder</li>
<li><strong>Subdirectory:</strong> Documents</li>
</ul>
<p>Then, the code will be:</p>
<pre>Try
  pDatabase = new SQLiteDatabase
  pDatabase.DatabaseFile = SpecialFolder.Documents.Child("EddiesElectronics.sqlite")
  pDatabase.connect
Catch e as RuntimeException
  MessageBox e.Reason
End Try</pre>
<p>What about a Web app that you host? That would mean you are in control about the folder/directory you want to use to store the app resources. Thus, it wouldn&#8217;t make much sense to automatize this process (but it is certainly doable following the same principles).</p>
<h2>3. Simplifying the process</h2>
<p>What we have seen already works, but that means that you need to change the file database name and probably that would change on every app you build. That also means that you&#8217;ll have to write the same code snippet again and again on every new app. Wouldn&#8217;t it be great to be able to extend the SQLiteDatabase and iOSSQLiteDatabase classes in order to simplify that?</p>
<p>Well, you can do that! Start by adding a new Module to the example project (for example one named &#8220;DatabaseExtensions&#8221;) with a couple of methods on it. The first method will be the one executed on our Desktop, Web and Console apps, because all of these targets use the SQLiteDatabase class.</p>
<p>So, add a new method using the following signature in the just-created module:</p>
<pre>OpenDatabase( databaseName as String )</pre>
<p>It extends the SQLiteDatabase class, adding a new method that takes as parameter the name of the file we want to copy on the &#8220;work&#8221; folder/directory.</p>
<p>The code you should type on this method is:</p>
<pre>pDatabase = New SQLiteDatabase

#If TargetDesktop Or TargetConsole Or TargetWeb Then

  Var source As FolderItem = SpecialFolder.Resource( databaseName )
  Var name As String = app.ExecutableFile.name.NthField(".",1)
  // We check if there is a folder with the App name in special Application Data
  // if not, we create it and copy the database file from Resources bundle/directory
  If Not (SpecialFolder.ApplicationData.Child(name).Exists And SpecialFolder.ApplicationData.Child(name).IsFolder) Then
SpecialFolder.ApplicationData.Child(name).CreateFolder
If Not SpecialFolder.ApplicationData.Child(nam).Child(Source).exists Then source.CopyTo(SpecialFolder.ApplicationData.Child(name))

  Try
    // Create a SQLiteDatabase instance and try to open our database file from
    // the path
    pDatabase.DatabaseFile = SpecialFolder.ApplicationData.Child(name).Child(databaseName)
    pDatabase.Connect

  Catch e As DatabaseException
    MessageBox e.Message
  End Try

#ElseIf TargetXojoCloud
  Try
    pDatabase.DatabaseFile = SpecialFolder.Documents.Child( databaseName )
    pDatabase.connect
  Catch e As RuntimeException
    MessageBox e.Reason
  End Try
#EndIf</pre>
<p>Of course, we need to add the &#8220;pDatabase&#8221; property to our module too: pDatabase As SQLiteDatabase</p>
<p>Now, you&#8217;ll only need to use:</p>
<pre>OpenDatabase("EddiesElectronics.sqlite")</pre>
<p>With the method selected in the Project Browser, click on the Attributes section of the Inspector Panel (the Cog Wheel icon), and uncheck the &#8220;iOS 64&#8221; checkbox. This way, that method will not be included when compiling for iOS apps.</p>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6729 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2020/03/Captura-de-pantalla-2020-03-09-a-las-6.55.49-281x300.png" alt="" width="281" height="300" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Captura-de-pantalla-2020-03-09-a-las-6.55.49-281x300.png 281w, https://blog.xojo.com/wp-content/uploads/2020/03/Captura-de-pantalla-2020-03-09-a-las-6.55.49.png 420w" sizes="auto, (max-width: 281px) 100vw, 281px" /></p>
<p>Do the same thing with the &#8220;pDatabase&#8221; property, so it is only compiled on the supported targets.</p>
<p>The second method is the one we will be using for iOS apps. The method signature would be:</p>
<pre>OpenDatabase(databseName as String)</pre>
<p>And typing the following fragment of code in the associated Code Editor:</p>
<pre>pIOSDatabase = New iOSSQLiteDatabase

Var source As Xojo.IO.FolderItem = xojo.io.SpecialFolder.GetResource( databaseName )

// We check if there is our database file already copied on the Documents Sandbox folder
// if not, we copy the database file from Resources bundle/directory
If Not xojo.io.SpecialFolder.Documents.Child( databaseName ).Exists Then
  source.CopyTo(xojo.io.SpecialFolder.documents)
End If

Try
  // Create a SQLiteDatabase instance and try to open our database file from
  // the path

  Var f As FolderItem = xojo.io.SpecialFolder.Documents
  pIOSDatabase.DatabaseFile = f.Child( databaseName )
  Call db.Connect

Catch e As RuntimeException
  MessageBox e.Reason
End Try</pre>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6730 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2020/03/Captura-de-pantalla-2020-03-09-a-las-6.55.27-282x300.png" alt="" width="282" height="300" srcset="https://blog.xojo.com/wp-content/uploads/2020/03/Captura-de-pantalla-2020-03-09-a-las-6.55.27-282x300.png 282w, https://blog.xojo.com/wp-content/uploads/2020/03/Captura-de-pantalla-2020-03-09-a-las-6.55.27.png 423w" sizes="auto, (max-width: 282px) 100vw, 282px" /></p>
<p>Lastly, and with the method item still selected in the Project Browser, go to the Attributes section of the Inspector Panel and make sure that the &#8220;iOS 64&#8221; checkbox is the only one selected under the &#8220;Include In&#8221; section. This way, we make sure that the method will be compiled only on iOS targets.</p>
<p>And do the same thing with the &#8220;piOSDatabase&#8221;, so it is only compiled for iOS targets.</p>
<h2>To Summarize</h2>
<p>As we see, the use of Modules in combination with OOP Class Extension is a good way to get more flexibility when developing your apps; using a common function (or method) name no matter if you are working on Desktop, Web or iOS. Additionally, that leads to a more convenient reutilization of your codeand, of course, less code to maintain through all our projects!</p>
<p>(You can find this article in Spanish <a href="https://www.aprendexojo.com/2020/03/prepara-bases-de-datos-sqlite-para-despliegue-en-desktop-web-y-ios/">here</a>)</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>10 Reasons Why You Should Try Xojo</title>
		<link>https://blog.xojo.com/2020/01/21/10-reasons-why-you-should-try-xojo/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Tue, 21 Jan 2020 15:25:25 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Fun]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[XDC]]></category>
		<category><![CDATA[Intro to Xojo Programming Textbook]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Native App Development]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[RAD]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=6422</guid>

					<description><![CDATA[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!]]></description>
										<content:encoded><![CDATA[<p>With so many programming languages and development environments around why should you try Xojo? I could tell you more than 400,000 reasons to just jump-in right away; reasons I&#8217;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&#8217;m pretty sure you will want to <a href="http://xojo.com/download/">give Xojo a try</a> too!</p>
<h2>1. Xojo is for everyone</h2>
<p>It doesn&#8217;t matter if you are just starting to <a href="https://www.xojo.com/resources/learn.php">learn how to develop software</a> or if you are already a seasoned developer, Xojo is for everyone! If you are getting your feet wet in coding, then you&#8217;ll find that Xojo offers a programming language that is extremely easy to grasp from the start. In fact, you&#8217;ll find a lot of contextual help in Xojo while coding, and access to the global Help menu is only a click away.</p>
<p>In addition, the <a href="http://documentation.xojo.com">Xojo Documentation</a> website offers really easy-to-follow QuickStarts, Tutorials and Guides letting you make your own Desktop, Web, Android, iOS, Raspberry Pi or Console apps in no time! Add that to the more than 300 video-tutorials you can find in the <a href="http://youtube.com/goxojo">Xojo YouTube channel</a>, and the fact that all the Xojo language documentation is packed with code snippets showing how to implement a particular feature- copy, paste and you are set.</p>
<p>Need some starting points for a better understanding of how Xojo Projects work? The Examples folder included with the <a href="https://xojo.com/download/">Xojo Download</a> includes dozens of complete example projects you can open, run and inspect to see in detail how to implement a particular task or behavior; then you can  adapt and use these for your own projects. Even you can use the Search feature for filtering the example projects by platform, operating system or other criteria.</p>
<p>One thing you&#8217;ll notice the very first time you run Xojo is that you aren&#8217;t inundated with features you don&#8217;t even know what to do with yet! Everything is clear and concise in front of you, hiding the complexity generally associated with the development workflow.</p>
<p>As you advance in your learning process and get more experienced in coding, you can discover more advanced features at your own pace. And even then, things like Web debugging, iOS or Android deployment or truly multi-platform development, are still effortless. Xojo does all of this without installing thousands of files on each operating system or requiring the additional installation of other components in order to properly work.</p>
<p>What if you&#8217;re an experienced developer coming from another development environment or language? Then you&#8217;ll be able to learn and master the Xojo programming language in a blink while watching your productivity increase! In fact, Xojo is an Event-Driven OOP (Object Oriented Programming) language, sharing the same &#8220;dot notation&#8221; syntax used by the most modern programming languages; and Xojo offers guides to port your existing projects, for example, from <a href="http://documentation.xojo.com/topics/migrating_from_other_development_tools/migrating_from_visual_foxpro.html">FoxPro</a> or <a href="http://documentation.xojo.com/UserGuide:Migrating&lt;em&gt;from&lt;/em&gt;Visual&lt;em&gt;Basic">VB6</a> to modern and truly multi-platform deployment with Xojo. And even if you are coming from other development environments as FileMaker or 4D, Xojo makes your solutions available for a more wide range of platforms as native apps and without hidden or extra deployment costs.</p>
<p>Being an OOP language means that Xojo will share the same set of paradigms and/or syntax you are used to dealing with in other programming languages; ranging from PHP to C++, Objective-C, Swift, JavaScript, Python, and others. In fact, you&#8217;ll discover that several of the language keywords, instruction blocks and function or methods calling conventions are very similar to the ones found in those.</p>
<p>Add that to the rich and complete Xojo Framework and the fact that you can even use external libraries if you need to; and you&#8217;ll realize all the possibilities you have at your hands for creating apps and complete solutions that can be used by individuals or companies of all sizes.</p>
<h2>2. Make all kind of apps!</h2>
<p>While several languages and IDEs are more suited or focused on developing a particular kind of products (database driven, mobile, IoT, etc.), with Xojo you&#8217;ll be using the same IDE and programming language to create all of these and more!</p>
<p>For what it is worth, that means that even if you are a self-employed developer, a <a href="https://blog.xojo.com/2015/11/19/the-citizen-developer/">Citizen Developer</a> or need to develop a solution for a company, you&#8217;ll be saving a huge amount of time, money and resources in order to get all these things done with a single development environment. That translates into reduced costs and increased ROI in your development investments; from the simplest ones to the more complex and demanding, including Console apps acting as Daemons, background processes, task helpers… or APIs development as the middleware to interact with both Mobile, Web, Desktop or Raspberry Pi clients!</p>
<p>Do you offer consultancy services or are you working as a freelance developer? With Xojo you&#8217;ll significantly reduce the amount of time you usually spend following multiple changes and evolutions in programming languages, frameworks, SDKs, technologies and, probably, third parties IDEs (among other resources) in order to keep going with your business.</p>
<p>At the same time, due to the fact that Xojo shares the programming language and IDE among all the supported platforms (Desktop, Web, Android, iOS and Raspberry Pi) and architectures (both 32 and 64-bit / Intel and ARM), you can also expand the kind of solutions you can offer to you current or potential clients and keep them running as the technology evolves!</p>
<h2>3. Truly Native, Cross-Compiled, Multi-Platform Apps!</h2>
<p>Some development environments or programming languages are focused (or are more appropriate) to a particular platform or target. With Xojo you&#8217;ll find that all of your apps will be compiled to native binary code on every supported platform.</p>
<p>That means that they will not incur the performance penalties imposed by byte code translations or that they can be easily reverted to source code, even your Web products!</p>
<p>What&#8217;s more important: the compiled apps will look and behave as you expect on every one of the supported operating systems.</p>
<p>In general, all of this means that you can be more confident about the fact that your intellectual property will not be the targeted or exposed by the most common techniques or exploiting attacks; and that translates into additional <em>peace of mind</em> regarding how you protect your investment in developing and deploying your solutions.</p>
<p>Even Xojo is created with Xojo! That is, the IDE offers the same look and feel and set of features from Windows, macOS and Linux.</p>
<h2>4. Do more with less</h2>
<p>During the designing, coding, testing or deployment phases of the product you won&#8217;t need to do complex set-ups or check for ever-changing dependencies! The Xojo IDE abstracts you from all the inherent and underlaying complexity, so you can focus on what really matters: the features that make your product truly unique.</p>
<p>This kind of complexity abstraction is evident not only for Desktop apps, but also for Android and iOS deployments and is especially evident when deploy web apps in combination with <a href="https://www.xojo.com/cloud/">Xojo Cloud.</a></p>
<p>In this last case, you only need to click a button in Xojo to have your web app transferred from the IDE to your Xojo Cloud server. Your app will be up and running in a matter of seconds, without needing to deal with complex server configurations or investing all the required time in being sure that you have all the server security issues covered and under control. Think about that for a moment: if you are a small company or just an independent developer, you don&#8217;t need to invest  extra resources, time and money in order to have your web apps secured and running with confidence.</p>
<p>Of course, if you have the resources and/or the required knowledge, you can deploy your web apps yourself on any VPS or web hosting service of your choice that meets the Xojo Web deployment requirements.</p>
<p>But the best part is that it doesn&#8217;t mind if you&#8217;re developing for Web, Android, iOS, Desktop or Raspberry Pi: you can develop for any of the Xojo supported platforms from the operating system of your choice! In the case of macOS and iOS apps, development can be done on any platform a Mac computer is required for compilation.</p>
<p>In summary: it doesn&#8217;t matter what OS or platform you want or need to code for, you&#8217;ll be using the same IDE and programming language in all the cases, abstracting you from all the particularities and underlaying complexity on every case. And that means doing more in less time!</p>
<h2>5. Rapid Application Development</h2>
<p>It doesn&#8217;t matter if you are creating a Desktop, Web, Android or iOS app; or if you want to build your solutions for Intel or ARM based architectures. With Xojo you will be able to design the user interface via Drag &amp; Drop from a rich set of controls ready to use. It&#8217;s that simple. In fact, the Layout Editor provides visual clues to precisely align every control in the Window, View or Page of the app; and if you&#8217;re targeting for macOS, Web, Android or iOS you&#8217;ll be able to see how your designs react when used in Dark Mode!</p>
<p>Reacting to users&#8217; interactions in your apps is as easy as selecting a user interface control in the Layout Editor, adding the kind of event you&#8217;re interested in from a list (with contextual help about what it does and when it is fired), and writing the code you want to be associated and executed to that particular Event.</p>
<p>Add that to the fact you can reuse your already developed Classes, Modules and other resources; you can even reuse your code between different kinds of projects and targeted platforms!</p>
<h2>6. No chains!</h2>
<p>It doesn&#8217;t matter if the apps or solutions created with Xojo are intended to be used by dozens or thousands of users, even if they are database driven! With Xojo you don&#8217;t have to pay royalties for absolutely anything! Even better: you don&#8217;t need to buy a license in order to try, learn and use Xojo! There is no limited trial, feature limitations or other drawbacks when using the free IDE. Download Xojo and begin learning, developing, running and debugging your projects all without a license.</p>
<p>Features include, the access and use of the supported database engines: from SQLite to MySQL/MariaDB, PostgreSQL, or any other you can access using ODBC, and of course the included features to work with Reports.</p>
<p>You can <a href="https://www.xojo.com/store">buy a Xojo license</a> when you decide that is the time to build your projects. Further, all Xojo licenses are covered by a 90-day money-back guarantee.</p>
<p>In addition, you don&#8217;t even need to pay for what you are not going to use (or going to use right now). What does this mean? Well, let&#8217;s say that if you only work with Windows and only want to create apps for Windows, then you only need to buy the Windows Lite Edition license for that ($99 USD), while if you need your apps to be run from all the supported Desktop platforms (including Raspberry Pi), then the Xojo Desktop Edition license is probably what you&#8217;re looking for ($299 USD); or if you really want to grasp all the Xojo power and target all the Xojo supported platforms (Desktop, iOS, Web and Raspberry Pi), then Xojo Pro is undoubtedly for you ($699 USD)! Oh and Xojo Pi, for building desktop and console apps, <a href="https://xojo.com/redeem/pilicense.php">is free</a>!</p>
<p>You can even upgrade to Xojo Desktop or Pro at any time if you decide that you need to use more advanced features not present in your current edition. In other words, you don&#8217;t need to buy a new license from scratch if you don&#8217;t want to. You can even change your Xojo Cloud plan at any time you require!</p>
<h2>7. You&#8217;re not alone!</h2>
<p>With more than 400,000 users around the world and more than 20 years on the market, the awesome Xojo community is one of the best programming resources you can find around to join to. In the <a href="https://forum.xojo.com">Xojo Forum</a> you&#8217;ll find the largest community and best place to get your questions answered by a large group of enthusiastic and seasoned Xojo developers.</p>
<p>It doesn&#8217;t matter if it&#8217;s a simple or a more complex problem, you&#8217;ll feel welcomed and probably have your problem solved in record time! In fact, many of the replies come from members of the Xojo Staff, ranging from Customer Service to anyone on the Engineering Team or even the Founder and CEO of Xojo himself!</p>
<p>Of course, you have other resources you can (and should!) visit, ranging from a dedicated publication about Xojo development, to Users Groups and Xojo Pages in Facebook, developers blogs about Xojo, and of course the official Xojo channels in Twitter, Instagram or Facebook. Don&#8217;t worry, you don&#8217;t need to search the entire web to find these, we have collected some of these <a href="http://documentation.xojo.com/Resources:Communities,_Social_Media_and_Blogs">valuable resources here</a> and <a href="http://documentation.xojo.com/Resources:Books,_Magazines,_Videos_and_Tutorials">here</a>.</p>
<p>And if you need to get a richer experience and more in-depth knowledge, in a face to face way, then you won&#8217;t want to miss any of the usual <a href="https://www.xojo.com/events/">Xojo Events</a> taking place in several American and European cities each year! There you can chat with other Xojo developers to exchange experiences, attend technical sessions, socialize and create new relationships that can lead in new work projects, etc.</p>
<p>The biggest of these Events is <a href="https://www.xojo.com/xdc/">XDC</a>, with Xojo developers coming in from all around the world, and where you will be able to attend sessions from expert Xojo developers and where you can talk with all the <a href="https://www.xojo.com/company/team.php">Xojo Team</a>!</p>
<h2>8. And you won&#8217;t be left behind</h2>
<p>Did you know that Xojo is still able to open and run projects from earlier releases, even many, many years ago? Sure that in more complex projects you will need to <em>upgrade</em> code, and that&#8217;s because Xojo has evolved, and continues to evolve, to match the own industry changes and evolution.</p>
<p>In fact, the apps created with Xojo are 64-bit compliant (although you can still generate 32-bit code, if you need), with support for HiDPI graphics, Dark Mode support both on macOS and iOS, the latest iOS SDK, native <a href="https://blog.xojo.com/2020/11/24/xojo-now-supports-native-apple-silicon-m1-compilation/">Silicon and M1</a> compilation and meeting other non-visual changes imposed by any of the current operating systems.</p>
<p>You can expect several Xojo version releases every year, adding new features, improving existing ones and fixing bugs. But we also keep a <a href="http://documentation.xojo.com/resources/roadmap.html">bigger picture about the medium to long term</a> evolution of Xojo, so you can always see the big features we are working on that will be coming in future releases of Xojo. That way, all the effort you&#8217;re putting in the apps, products and solutions you create today won&#8217;t be left behind in the future. You&#8217;ll be able to improve and enrich them for your users, keeping them current as operating systems evolve.</p>
<p>Need to request a feature is important for you or did you find a bug you can&#8217;t workaround? We listen to you. Go to our <a href="https://tracker.xojo.com/xojoinc/xojo/-/issues">Issues tracker system</a> to get in touch with us about the things you want to be added or improved.</p>
<h2>9. Add your own features!</h2>
<p>The Xojo Framework is large enough to accomplish most of the usual app requirements you may need; but sometimes you need to go a bit further, even the thousands of already existing external libraries around whose functions you can use directly from your code … and in these cases you&#8217;re covered too!</p>
<p>Xojo Provides <a href="http://documentation.xojo.com/Xojo&lt;/em&gt;Plugin&lt;em&gt;SDK">SDKs</a> (Software Development Kits) both for Desktop and Web applications; so you just need to start digging in the provided documentation and example projects in order to create your own Xojo Plug-Ins. These will be loaded from the IDE and you&#8217;ll be able to use their exposed features with the same simplicity you do when using the rest of the internal Xojo Framework.</p>
<h2>10. Xojo Ecosystem</h2>
<p>Don&#8217;t be afraid if you don&#8217;t have the time, resources or knowledge needed to develop your own plug-ins.</p>
<p>You can resort to the broad offer of excellent <a href="https://www.xojo.com/store/#addons">third-parties plug-ins</a>, add-ons, libraries and classes you can choose from. These range from commercial software to <a href="http://documentation.xojo.com/Resources:Open&lt;/em&gt;Source_Projects">Open-Source projects</a>, or just plain free classes, modules or libraries ready to download and use in your own Xojo projects.</p>
<h1>We are here to help!</h1>
<p>All in all it&#8217;s time to give Xojo a try, isn&#8217;t? It&#8217;s just a click ahead right now, so <a href="http://xojo.com/download/">download</a> Xojo and rediscover the pleasure of coding!</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Drawing User Interface Controls with DrawInto</title>
		<link>https://blog.xojo.com/2019/10/21/drawing-user-interface-controls-with-drawinto/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Mon, 21 Oct 2019 10:00:08 +0000</pubDate>
				<category><![CDATA[General]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Tutorials]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=6090</guid>

					<description><![CDATA[As an Object Oriented Programming language (OOP), Xojo&#8217;s data types, especially the non-primitive ones, use or can use a Class hierarchy. This means that one&#8230;]]></description>
										<content:encoded><![CDATA[<p>As an Object Oriented Programming language (<b>OOP</b>), Xojo&#8217;s data types, especially the non-primitive ones, use or can use a <b>Class hierarchy</b>. This means that one class, either included by default in the Xojo Framework or created from scratch, can act as a base or root class for other classes based upon them.<span id="more-6090"></span></p>
<p>The main advantage of a class hierarchy is that all the derived classes share the same set of methods, properties and events declared in their upper classes (those not set with a Private scope) and, thus, we can make our code more flexible, easier to maintain and get more dynamism from our apps at run time thanks to the <b>Casting</b> of types.</p>
<p style="text-align: center;"><a href="https://drive.google.com/open?id=1FhKmAhYkJYvgagtGuQCK3-67zvdrY78E">Download the Demo Project</a></p>
<p>What is this all about? Very simple. For the subject at hand, every graphic control or User Interface (UI) control included in the Desktop Xojo Framework share the common base class <code>RectControl</code> (this one based, at the same time, on the base class <code>Control</code>); and among the methods available in that class we can find <code>DrawInto</code>.</p>
<p>This means that every UI control has the ability to <em>draw</em> itself in any given <b>Graphic</b> context. However, when drawn in the target graphic context they will lose their usual response to any user interaction. That is, they would be a mere graphic representation of themselves; something that is really useful in many cases. For example, this is the technique used for drawing all the contents of a given page or range of pages in <a href="https://www.aprendexojo.com/shop/axcontrolgrid-2/"><code>AXControlGrid</code></a>.</p>
<p>As you can see in the Xojo documentation, the <code>DrawInto</code> signature is as follows:</p>
<pre>RectControl.<b>DrawInto(g as Graphics,x as Integer, y as Integer)</b></pre>
<ul>
<li>The first thing you can see is that the method is called on the instance (UI control) we want to draw into a given graphic context.</li>
<li>Second, the first argument we provide in the <code>DrawInto</code> method is the <b>graphic context</b> we want to use to draw the control. As you probably know, we can get such graphic context from several kind of classes, for example <b>Picture</b>. In addition, the target graphic context can be of any size we need it to be!</li>
<li>Third, the <code>x</code> and <code>y</code> arguments are the top-left coordinates used to draw the control in the target graphic context and, of course, these coordinates should be in the range of the width and height of the target graphic context passed as the first argument.</li>
</ul>
<p>For most of the cases, you don&#8217;t need to do anything special to use this method in your own classes. That means that the object calling the <code>DrawInto</code> method will draw itself using the same code you put in its <b>Paint</b> event. The unique difference in this case is that the Paint event will use the <b>external</b> graphic context and receive <code>x</code> and <code>y</code> coordinates that may be (or may not be) outside its own width and height range.</p>
<p>But there might be other times you don&#8217;t want to draw the control using the same code as the one written in the Paint event. Maybe because you need a more refined representation of the control or you simply want to leave out some details that are useful when the control is drawn as part of the UI but not when it is printed or used in a PDF document. In addition, it can be the case that inside the Paint event you may need to do some calculations on the <code>x</code> and <code>y</code> coordinates that would not make sense (or would be out of range) when done on an external graphic context.</p>
<p>After all, the key about using&nbsp;<code>DrawInto</code> is this:</p>
<ul>
<li>When a instance calls this method, what really happens is the code in the <code>Paint</code> event will be executed on the new graphic context received as argument. Of course, if you have not implemented the Paint event yourself, then Xojo will execute the default implementation.</li>
</ul>
<h2>Customizing the DrawInto Behavior</h2>
<p>In other cases, especially on Windows, it is possible that we won&#8217;t get the right drawing when using the default implementation of the DrawInto method. If you find yourself in this situation, you can fix it by overwriting the <code>DrawInto</code> method for your own UI classes.</p>
<p>When you do that, evey time you call this method it will execute the code you included in it, and that means that you will be in control of the received graphic context as parameter, its size and origin coordinates, and especially the drawing operations available through the methods from the <code>Graphics</code> class.</p>
<p>The way to implement (overwrite) the <code>DrawInto</code> method in your own UI controls (derived from the <code>RectControl</code> class) is as simple as for any other overwritten method or Event in your own subclasses.</p>
<p>With your class selected in the Xojo IDE Navigator, access the contextual menu to select the <code>Add to "instanceName" &gt; Method</code> option, choosing the <code>DrawInto(graphics as Graphics, Left as Integer, Top as Integer)</code> item in the Name field popup from the Inspector Panel.</p>
<p>Once selected, you will see that the associated Code Editor will contain by default a call to the same method signature on the <b>Super</b> class. This gives the class the control is based on the oportunity to drawn itself.</p>
<p>From a practical point of view, you will probably want to delete that call when you don&#8217;t want to use the same kind of representation for the control on the external graphic context when that is drawn in the UI. In addition you will save some drawing time thus improving the overall speed.</p>
<p>Now you only need to include in the <code>DrawInto</code> method the code you want to use in order to paint your control on the received context and you&#8217;ll be set! From that point on, every time you call:</p>
<pre>aRectControlInstance.DrawInto( tContext, 100, 100 )</pre>
<p>Xojo will execute the code put in your own implementation of the <code>DrawInto</code> method, and that means more flexibility and control about what is drawn and how it is drawn; especially if your UI control is going to be used both in macOS and Windows.</p>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6092 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-Run-300x266.png" alt="" width="300" height="266" srcset="https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-Run-300x266.png 300w, https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-Run-768x682.png 768w, https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-Run.png 964w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<h2>DrawInto in Practice</h2>
<p>In order to see how everything works, let&#8217;s create a simple Xojo Desktop project where we will make use of our own <code>DrawInto</code> implementation on one Canvas based class.</p>
<p>Create a new Xojo Desktop project, drag the <code>Canvas</code> control from the Library panel into the Navigator.</p>
<p>Next, and with the new Canvas class selected, access the Inspector Panel to set the following values:</p>
<ul>
<li><b>Name</b>: MyOwnControl</li>
<li><b>Super</b>: Canvas</li>
</ul>
<p>With our new class still selected in the Navigator, add the <b>Paint</b> Event. For that, you may access the contextual menu and choose the <code>Add to "MyOwnControl" &gt; Event Handler…"</code> option, selecting the Paint entry afterwards in the resulting window.</p>
<p>Then, write the following code in the Code Editor associated with the Paint Event:</p>
<pre>g.DrawingColor = &amp;cff0000
g.FillRectangle(0,0,g.Width, g.Height)</pre>
<p>Nothing especially significant here. As you can see, it sets the foreground color to Red and then fills all the control area using the <code>FillRect</code> method on the control graphic context.</p>
<p>Now it is time to overwrite the <code>DrawInto</code> method. With our class still selected in the Navigator, add the <code>DrawInto</code> method and write the following code in the associated Code Editor:</p>
<pre>// Uncomment the following line of code to see what happens!
// In that Case, the control first executes the code from the Paint Event,
// executing the drawing code from the overriden DrawInto method afterwards.

//super.DrawInto(graphics, left, top)

Var s As String = "From DrawInto"

Var sLen As Double = graphics.TextWidth( s ) / 2

graphics.DrawingColor = &amp;c00FF00

// No matter what the "Left" and "Top" values are, we don't use them
// for our custom drawing.

graphics.DrawRectangle(0,0, graphics.Width, graphics.Height)

graphics.DrawingColor = &amp;c000000
graphics.PenSize = 1
graphics.AntiAlias = True

graphics.DrawText("From DrawInto", (graphics.Width/2) - sLen, (graphics.Height / 2) )</pre>
<p>Basically, what we are doing here is substantially changing the graphical representation of the control between what is seen when it is drawn in the user interface through the Paint Event and what we will get when calling the <code>DrawInto</code> method on the Control instance.</p>
<p>In the second case, it will draw a non-filled green rectangle using the same width and height that the control itself, writting the string &#8220;From DrawInto&#8221; centered in the control area.</p>
<p>You can see that the <code>Super.DrawInto(graphics, Left, Top)</code> code line is commented. After the initial running of the demo app, you can uncoment that line if you want in order to see how it changes the drawing when the <code>Super</code> class is called (remember, that means executing the code on the Paint event for the Class).</p>
<h2>Putting it all Together</h2>
<p>With our class already finished, it is time to start the layout of our minimal user interface. Something really simple. Choose the <code>Window1</code> window in order to access the Layout Editor. Then drag the <code>MyOwnControl</code> item from the Project Broswer into the the Window1 area in the Layout Editor. With that action we will have added a new instance from our class. The resulting name for the instance will be <code>MyOwnControl1</code>.</p>
<p><iframe loading="lazy" title="DrawInto: Dibujado personalizado de controles en un Contexto Gráfico" width="500" height="375" src="https://www.youtube.com/embed/ehyTLCuMIsM?feature=oembed" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe></p>
<p>Then, drag a standard Canvas control from the Library panel into the <code>Window1</code> area in the Layout Editor. This action will result in the creation of a new Canvas instance with the by-default name <code>Canvas1</code>.</p>
<p>Lastly, add a new button from the Library into the <code>Window1</code> area in the Layout Editor and use the Inspector Panel to set its name to <code>pbDrawInto</code> and its caption to &#8220;DrawInto&#8221;. This will be the button in charge to order our <code>MyOwnControl1</code> instance to draw itself in the graphic context provided by <code>Canvas1</code>.</p>
<p>For that, and with the <code>pbDrawInto</code> selected, add an <code>Action</code> Event Handler and write the following code in the associated Code Editor:</p>
<pre>// We create a Picture we can use to give a Graphics context to the
// Canvas1 backdrop (it would be "Nil" by default)

Var p As New Picture( canvas1.Width, Canvas1.Height, 32 )

canvas1.Backdrop = p

// And we instruct our "MyOwnControl" instance to draw itself on the
// "Canvas1" graphics context.

MyOwnControl1.DrawInto(Canvas1.Backdrop.Graphics,0,0)</pre>
<p>If you want, you can layout your user interface like the one displayed in the following screenshot:</p>
<p><img loading="lazy" decoding="async" class="size-medium wp-image-6091 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-IDE-300x267.png" alt="" width="300" height="267" srcset="https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-IDE-300x267.png 300w, https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-IDE-768x684.png 768w, https://blog.xojo.com/wp-content/uploads/2019/10/DrawIntoOverload-IDE.png 892w" sizes="auto, (max-width: 300px) 100vw, 300px" /></p>
<p>Now we have our app ready to test. Press the <code>Run</code> button in the IDE and verify the results you get between what is drawn by the Paint Event and what you get when you click on the button labeled &#8220;DrawInto&#8221;.</p>
<p><em data-rich-text-format-boundary="true">Javier Rodri­guez has been&nbsp;the Xojo Spanish&nbsp;Evangelist since 2008, he’s also a Developer, Consultant and Trainer who&nbsp;has be using&nbsp;Xojo since 1998. He manages&nbsp;<a href="http://www.aprendexojo.com">AprendeXojo.com</a> and is the developer behind the GuancheMOS plug-in for Xojo Developers, GuancheID, AXControlGrid, AXImageCanvas, Markdown Parser for Xojo, and HTMLColorizer for Xojo among others.</em></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Unlock the all in one, low-code, cross-platform solution</title>
		<link>https://blog.xojo.com/2018/03/15/unlock-all-in-one-low-code-cross-platform-solution/</link>
		
		<dc:creator><![CDATA[Geoff Perlman]]></dc:creator>
		<pubDate>Thu, 15 Mar 2018 09:00:32 +0000</pubDate>
				<category><![CDATA[Cross-Platform]]></category>
		<category><![CDATA[Database]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Citizen Developer]]></category>
		<category><![CDATA[Intro to Xojo Programming Textbook]]></category>
		<category><![CDATA[Low-Code]]></category>
		<category><![CDATA[Multi-Platform Development]]></category>
		<category><![CDATA[Native App Development]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[OOP]]></category>
		<category><![CDATA[RAD]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[Xojo Programming Language]]></category>
		<guid isPermaLink="false">https://blog.xojo.com/?p=4006</guid>

					<description><![CDATA[Just as people have varying levels of skill and interest in video games, the same is true of app development.  It's tremendously empowering to be able to build even a simple app that helps you accomplish tasks more quickly and efficiently. A low-code development tool like Xojo is a great place to start.]]></description>
										<content:encoded><![CDATA[<p>Like his father, my teenage son loves video games. The single player games where you take a character through some kind of adventure are the ones I like most. These usually have a fair number of AI-controlled enemies that must be defeated. My son, on the other hand, prefers to play against other human beings. When I asked him why, he said, &#8220;The AIs are <em>so</em> predictable.&#8221; To prove this to me, he took over when I was having trouble defeating a particularly difficult enemy and quickly dispatched him, narrating his strategy as he went and barely being scratched in the process. My son is an elite player compared to me partially because he puts a lot more time into it than I do but also because he loves video games far more than I do.</p>
<p>Just as people have varying levels of skill and interest in video games, the same is true of app development. There are those that are happy to devote enormous amounts of time to learning everything they possibly can. They don&#8217;t care how long it takes. They want to have control over everything and are willing to do whatever is necessary to make that happen. I&#8217;m so glad those people exist because there&#8217;s a lot of great software that might not otherwise have been created without them. I&#8217;m <em>not</em> one of those people. I really want to focus mostly on what makes my application unique, abstracted from the nitty-gritty of app development.</p>
<p>That&#8217;s why I have always been attracted to tools like Xojo. I am a <a href="https://blog.xojo.com/2015/11/19/the-citizen-developer/">citizen developer</a>. Of all the job titles I have had over the years, all of them in tech,  none have <strong>ever</strong> included words like <em>programmer</em> or <em>engineer</em>. I do some software development but it&#8217;s just a part of my job. It&#8217;s something I do to help me in my work or to help my co-workers.</p>
<p><span id="more-4006"></span></p>
<p>When I founded Xojo, Inc., tools like Xojo were called RAD (<a href="https://en.wikipedia.org/wiki/Rapid_application_development">Rapid Application Development</a>) tools. Now the term du jour is <em>Low-Code</em>. Put simply, it means that a development tool provides a lot of <strong>built-in</strong> functionality so you don&#8217;t have to write too much code compared to more traditional languages and tools. That&#8217;s Xojo. You can build your user interface visually via <strong>drag and drop</strong>.</p>
<p><a href="https://blog.xojo.com/wp-content/uploads/2018/03/IDE-Desktop.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-4062 size-full" src="https://blog.xojo.com/wp-content/uploads/2018/03/low-code_desktop-IDE.png" alt="" width="2500" height="2000" /></a></p>
<p><a href="https://blog.xojo.com/wp-content/uploads/2018/03/Xojo-iDE-.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-4063 size-full" src="https://blog.xojo.com/wp-content/uploads/2018/03/low-code_mobile-IDE.png" alt="" width="2500" height="2000" /></a></p>
<p><a href="https://blog.xojo.com/wp-content/uploads/2018/03/IDE-Web.png"><img loading="lazy" decoding="async" class="aligncenter wp-image-4064 size-full" src="https://blog.xojo.com/wp-content/uploads/2018/03/low-code_web-IDE.png" alt="" width="2500" height="2000" /></a>The set of built-in commands (the <em>framework</em>) provides you with everything you&#8217;ll likely need to handle the things that do require some coding. Xojo is a cross-platform tool making it easy to create apps for different platforms such as MacOS, Windows, Linux, the web, iOS and even <a href="https://blog.xojo.com/2018/03/14/have-you-pie-build-with-it-too/">Raspberry Pi</a>, without having to learn all the details of each one. Unlike some cross-platform solutions, Xojo builds complete <strong>native</strong> apps which means your apps have the look, feel and performance of those written in the more complicated tools that require so much more code.</p>
<p><img loading="lazy" decoding="async" class="alignleft size-full wp-image-4049" src="https://blog.xojo.com/wp-content/uploads/2018/03/Xojo-LR.png" alt="" width="2112" height="1510" /></p>
<p>It&#8217;s not all upside. There are sometimes very specific features for which Xojo has no built-in support. An example of this is notifications. The good news is that should you find yourself needing functions like this, there&#8217;s a vibrant Xojo community of users who have likely already created that <a href="http://developer.xojo.com/third-party-products">functionality</a> and you can just add it to your project. And Xojo is updated multiple times per year so new functionality is always appearing.</p>
<p>If you&#8217;re like me and you want to be able to quickly and easily build applications that make life easier for you and perhaps your co-workers, Xojo is something you should seriously consider. Xojo is also <strong>free to use and learn</strong>. You only need buy a license if you decide you want to deploy your application. We provide lots of free resources including a <a href="https://youtube.com/goxojo">video library</a> with over 250 videos, tutorials, and <a href="http://developer.xojo.com/home">documentation</a> as well as a <a href="https://www.xojo.com/resources/learn.php">textbook</a> designed to help you learn app development.</p>
<p>It&#8217;s tremendously empowering to be able to build even a simple app that helps you accomplish tasks more <strong>quickly and efficiently</strong>. A low-code development tool like Xojo is a great place to start.</p>
<p>&nbsp;</p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Design Patterns in Xojo: Observer, Part II</title>
		<link>https://blog.xojo.com/2016/11/15/design-patterns-observer-part-ii/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Tue, 15 Nov 2016 07:24:08 +0000</pubDate>
				<category><![CDATA[Learning]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[Observer]]></category>
		<category><![CDATA[Singleton]]></category>
		<guid isPermaLink="false">http://blog.xojo.com/?p=2070</guid>

					<description><![CDATA[In previous blog entries we saw how easy it is to implement the Design Pattern Singleton and how we can find the Observer Design Pattern&#8230;]]></description>
										<content:encoded><![CDATA[<p>In previous blog entries we saw how easy it is to implement the Design Pattern <a href="http://blog.xojo.com/2016/06/08/design-patterns-in-xojo-singleton/">Singleton</a> and how we can find the <a href="http://blog.xojo.com/2016/06/15/design-patterns-in-xojo-observer-part-1/">Observer</a> Design Pattern already implemented on several Xojo features by default, greatly simplifying our code and interaction between the objects. Now, as promised, it is time to put it all in practice, creating our own Notification Center: a class that will allow us to share the same unique instance for the entire App (Singleton), and that can use any object in order to register itself for receiving notifications by the observed Control, for one or more message (the notifications themselves).<span id="more-2070"></span><br />
In addition, the designed Class will allow you to unsubscribe any of the previously registered objects, either to stop receiving notifications by the observed object at all, or just some of the previously registered notifications.</p>
<p>The <a href="http://blog.xojo.com/2016/06/08/design-patterns-in-xojo-singleton/">Singleton</a> and <a href="http://blog.xojo.com/2016/06/15/design-patterns-in-xojo-observer-part-1/">Observer</a> Design Patterns have been described in previous blog entries and I highly recommend to read them now so you can get the flavor of the fundamentals behind them. I&#8217;ll wait here for you, I promise! Then we will deal with the code that varies to implement our <strong>NotificationCenter</strong> class, and to put it in practice with a Desktop example project.</p>
<p>Of course, before of continuing reading, you can <a href="https://www.dropbox.com/s/ry6ip9oe5jkm4av/Xojo-Observer-II.zip?dl=1">download the example project,</a> run it and review the code to get a first glance of what it does and how it works. Then, you can come back and continue reading if you want to better understand the <strong>NotificationCenter</strong> class inner, or how other objects can use this class.</p>
<h2>The NotificationCenter Class</h2>
<p>Execute the <strong>Xojo</strong> IDE and create a new Desktop project. Add a new class using <strong>Insert &gt; Class</strong>. Go to the Inspector and change the <strong>Name</strong> attribute to &#8220;NotificationCenter&#8221;. This is the name of the new class we are designing (and, thus, a new Data Type).</p>
<p>With the new class still selected in the Navigator (the leftmost column on the Xojo IDE), add a new <strong>Shared Property</strong> (<strong>Insert &gt; Shared Property</strong>). Use the Inspector again to change the <strong>Name</strong> attribute to &#8220;Instance&#8221;, the Type field to &#8220;NotificationCenter&#8221; and the <strong>Scope</strong> to &#8220;Private&#8221;. (You know, a Shared Property or Shared Method are those that you can access from the class itself, without needing to create previously a new instance from the class.)</p>
<p>Add a second Property to the class, this time via <strong>Insert &gt; Property</strong> (this is, an instance property). Use this values on the associated Inspector:</p>
<ul>
<li><strong>Name:</strong> Objects</li>
<li><strong>Type:</strong> Xojo.Core.Dictionary</li>
<li><strong>Scope:</strong> Private</li>
</ul>
<p>Next, add a new Method (<strong>Insert &gt; Method</strong>). Use the Inspector to choose the <strong>Constructor</strong> option from the &#8220;Method Name&#8221; dropdown menu, and set the method Scope to Private.</p>
<p>Write the following code on the associated Code Editor for the method:</p>
<pre>Objects = new xojo.core.Dictionary</pre>
<p>Defining the Constructor method with a Private scope prohibits the creation of several instances from the class. Instead of that, the class consumers will have to use the convenience method defined by us in order to retrieve the same —and unique— instance for all the cases.</p>
<p>So, now we will add a new Shared Method using <strong>Insert &gt; Shared Method</strong>. Use the Inspector to put the following values on the created method:</p>
<ul>
<li><strong>Name:</strong> SharedInstance</li>
<li><strong>Return Type:</strong> NotificationCenter</li>
</ul>
<p>And write the following code in the associated Code Editor for the method:</p>
<pre>if instance = nil then instance = new NotificationCenter
Return instance</pre>
<p>These are the wires to write our Singleton class and to define our Data Model: the &#8220;Objects&#8221; property of data type <a href="http://developer.xojo.com/xojo-core-dictionary"><strong>Xojo.Core.Dictionary</strong></a>. This property will be responsible for storing the registered objects as observers of the desired Control(s), as well as the messages for whom it is interested in receiving notifications for the observed object(s). Probably this is better understood in the following figure:</p>
<p><img loading="lazy" decoding="async" class="size-full wp-image-2072 aligncenter" src="https://blog.xojo.com/wp-content/uploads/2016/11/DataModel.png" alt="Data Model for Notification Center Class" width="485" height="551" />That is, the &#8220;Observers&#8221; Xojo.Core.Dictionary Property uses as <strong>Key</strong> any object of <a href="http://developer.xojo.com/rectcontrol">RectControl</a> data type (the observed object). The associated value for that key is a new Xojo.Core.Dictionary, whose entries will use as Key the Notification (message as Text data type) for what an object wants to register as observer for such Control.</p>
<p>This way, one same object can be registered to several controls and also to several messages (Notifications) on one or several controls.</p>
<p>Finally, the associated value for every <strong>Key</strong> on this second Xojo.Core.Dictionary is an <strong>Array</strong> data type whose items are instances of the <strong>NotificationReceiver</strong> data type.</p>
<p>I know, I know… Stop. Breathe. Execute again the example project. Review the code on the &#8220;Register&#8221; method to get a better grasp… and back to follow!</p>
<h3>Registering Observers</h3>
<p>With the class still selected on the Navigator, add a new method (<strong>Insert &gt; Method</strong>) using the following values. This is the method responsible for registering the new observers on the shared Notification Center instance:</p>
<ul>
<li><strong>Name:</strong> Register</li>
<li><strong>Parameters:</strong> sourceControl as NotificationReceiver, observedObject as RectControl, message as Text</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<p>As you can see in &#8220;Parameters&#8221;, the first parameter is the Observer object (this is the interesed object in receiving the notifications); the second parameter is the observed object (that is from which we want to receive notifications); and the third parameter is the message from which we are interested in receiving the notifications by the observed object.</p>
<p>Write the following code on the Code Editor associated for this method:</p>
<pre>dim observedObjects as xojo.Core.Dictionary = Objects.Lookup( observedObject, new xojo.core.Dictionary )
dim messages() as NotificationReceiver
if observedObjects.HasKey( message ) then messages = observedObjects.Value( message )
messages.Append sourceControl
observedObjects.Value( message) = messages
objects.Value( observedObject ) = observedObjects</pre>
<h3>Sending Notifications</h3>
<p>Now is time to add to the class the method responsible to send the notifications to those objects interested in receiving them from any previously registered object. Insert a new method for the <strong>NotificationCenter</strong> class and use the following values in the associated Inspector:</p>
<ul>
<li><strong>Name:</strong> sendNotification</li>
<li><strong>Parameters:</strong> sourceObject as RectControl, message as text, value as Auto</li>
<li><strong>Scope:</strong> Public</li>
</ul>
<p>And the following code in the Code Editor associated with the method:</p>
<pre>dim observedObjects as xojo.Core.Dictionary = objects.Lookup(sourceObject, nil)
if observedObjects &lt;&gt; nil then
  dim sourceObjects() as NotificationReceiver
  if observedObjects.haskey(message) then sourceObjects = observedObjects.Value( message )
  for n as integer = 0 to sourceObjects.Ubound
    dim target as NotificationReceiver = sourceObjects(n)
    target.valueReceived( value, message )
  next
end if</pre>
<p>As you can see, the first parameter of the method is the control that wants to send a notification (second parameter) to all the possible registered objects, passing the value that such objects can be interested to receive for processing it (third parameter).</p>
<h3>Stop receiving Notifications</h3>
<p>However, it is probable that one object wants to stop receiving notifications from any previously registered control. For that, we need to add a new method to the NotificationCenter class using this values:</p>
<ul>
<li><strong>Name:</strong> RemoveObserver</li>
<li><strong>Parameters:</strong> sourceControl as NotificationReceiver</li>
</ul>
<p>And the following code on the associated Code Editor:</p>
<pre>for each observedObjects as xojo.Core.DictionaryEntry in objects
  dim d as xojo.Core.Dictionary = objects.Value(observedObjects.Key)
  for each messagesForObject as xojo.Core.DictionaryEntry in d
    dim sourceObjects() as NotificationReceiver = d.Value(messagesForObject.Key)
    for n as integer = sourceObjects.Ubound DownTo 0
      if sourceObjects(n) = sourceControl then sourceObjects.Remove(n)
    next
  next
next</pre>
<h3>Stop receiving some Notifications</h3>
<p>It may also be the case that one object wants to unsuscribe from the Notification Center to stop receiving just one particular notification. For that, add a new method and use the following values on the Inspector:</p>
<ul>
<li><strong>Name:</strong> removeObserverForMessage</li>
<li><strong>Parameters:</strong> sourceControl as NotificationReceiver, message as text</li>
</ul>
<p>And write the following code in the associated Code Editor:</p>
<pre>for each observedObjects as xojo.Core.DictionaryEntry in objects
  dim d as xojo.Core.Dictionary = objects.Value(observedObjects.Key)
  for each messagesForObject as xojo.Core.DictionaryEntry in d
    if messagesForObject.Key = message then
      dim sourceObjects() as NotificationReceiver = d.Value(messagesForObject.Key)
      for n as integer = sourceObjects.Ubound DownTo 0
        if sourceObjects(n) = sourceControl then sourceObjects.Remove(n)
      next
    end if
  next
next</pre>
<h2>One Class Interface that runs them all: NotificationReceiver</h2>
<p>Along the implementation of our Notification Center class we have seen several times the reference to the <strong>NotificationReceiver</strong> data type. This is what we are going to get our hands on next.</p>
<p>In fact this is a <strong>Class Interface;</strong> what means that it works as a &#8220;glue&#8221; in order that any object can implement their defined methods. This way the objects can be seen as their native class and also as an instance from <strong>NotificationReceiver</strong>, so they can be registered as observers on the Notification Center independently the native class they are based on.</p>
<p>Use <strong>Insert &gt; Class</strong> Interface to add a new Class Interface to the project. Next, write the following values in the associated Inspector:</p>
<ul>
<li><strong>Name:</strong> NotificationReceiver</li>
</ul>
<p>With the Class Interface still selected in the Navigator, add a new method using the following signature in the Inspector:</p>
<ul>
<li><strong>Method Name:</strong> valueReceived</li>
<li><strong>Parameters:</strong> value as Auto, message as Text</li>
</ul>
<p>Done! Depending on your own needs, you can add more methods for the interface class in combination with the Notification Center class itself.</p>
<h2>Testing the Notification Center</h2>
<p>Now it is time to design the user interface in order to test the Notification Center class. The changes made on a <strong>TextField</strong> control will automatically update the contents of a <strong>Label</strong> control, a <strong>Slider</strong> control, a <strong>ListBox</strong> control and a <strong>Canvas</strong> control. Moreover, the Label instance will subscribe in the Notification Center to receive two types of notifications, changing his behaviour (the text shown) based on the received notification.</p>
<p>We will also add a couple of <strong>CheckBox</strong> controls to test the functionality to unsuscribe the Label control from all or just some notifications.</p>
<p>But before we start with that, and as we have seen in the previous step, we need that all the objects that want to be able to register on the Notification Center be of the <strong>NotificationReceiver</strong> data type. That means that we need to create our own subclases for the Label, Slider, ListBox and Canvas controles. Let&#8217;s start with the Label!</p>
<h3>Label Subclass</h3>
<p>Create a new sublcass for the Label Class. You can do that selecting the Label control from the <strong>Library</strong> and choosing the &#8220;New Subclass&#8221; option from the contextual menu; or you can drag and drop the control from the Library to the Navigator. Anyway, the result will be the same: you will have created a new subclass with the name &#8220;CustomLabel&#8221; (it can vary, depending the Xojo release you use). By the way, you also can use <strong>Insert &gt; Class</strong> in order to create a new subclass.</p>
<p>Regardless of the method used to create the new subclass, choose it in the Navigator and use this values in the associated Inspector:</p>
<ul>
<li><strong>Name:</strong> MyLabel</li>
<li><strong>Super:</strong> Label // This way, our sublcass will inherit all the methods, events and properties from the base class.</li>
<li><strong>Interfaces:</strong> Click on the button and choose &#8220;NotificationReceived&#8221; from the resulting panel/Window. Confirm the selection clicking on the &#8220;OK&#8221; button.</li>
</ul>
<p>As result of the last action, Xojo will automatically added the ValueReceived method to the class. Write the following code in the associated Code Editor:</p>
<pre>RaiseEvent newValueReceived value, message</pre>
<p>Here we raise a new event (not defined yet), so every instance from the class can be in charge of implement the real behavior in base of the parameters received.</p>
<p>So, with the &#8220;MyLabel&#8221; class still selected, use <strong>Insert &gt; Event Definition</strong> to add the event definition we need. Use the following values in the associated Inspector:</p>
<ul>
<li><strong>Event Name:</strong> newValueReceived</li>
<li><strong>Parameters:</strong> value as auto, message as Text</li>
</ul>
<h3>Slider Subclass</h3>
<p>Add a new subclass and use these values in the associated Inspector:</p>
<ul>
<li><strong>Name:</strong> MySlider</li>
<li><strong>Super:</strong> Slider</li>
<li><strong>Interfaces:</strong> Add the NotificationReceiver Class Interface as seen in the previous step.</li>
</ul>
<p>Write the following code for the ValueReceived method:</p>
<pre>RaiseEvent newValueReceived val(value)</pre>
<p>And add the event definition using <strong>Insert &gt; Event Definition</strong>, as we have seen in the previous step. Use this signature in the Inspector:</p>
<ul>
<li><strong>Event Name:</strong> newValueReceived</li>
<li><strong>Parameters:</strong> value as integer</li>
</ul>
<h3>ListBox Subclass</h3>
<p>Let&#8217;s create now the subclass for the ListBox, following basically the same steps already done with the previous subclasses. Use the following values:</p>
<ul>
<li><strong>Name:</strong> MyListBox</li>
<li><strong>Super:</strong> ListBox</li>
<li><strong>Interfaces:</strong> NotificationReceiver</li>
</ul>
<p>Write the following code in the Code Editor associated with the ValueReceived method added by the Class Interface:</p>
<pre>RaiseEvent newValueReceived val(value)</pre>
<p>And add the corresponding Event Definition using this signature:</p>
<ul>
<li><strong>Event Name:</strong> newValueReceived</li>
<li><strong>Parameters:</strong> value as integer</li>
</ul>
<h3>Canvas Subclass</h3>
<p>We have arrived to the last subclass definition for our example project. Add a new subclass to the project and use this values in the associated Inspector:</p>
<ul>
<li><strong>Name:</strong> MyCanvas</li>
<li><strong>Super:</strong> Canvas</li>
<li><strong>Interfaces:</strong> NotificationReceiver</li>
</ul>
<p>Write the following code for the ValueReceived method:</p>
<pre>dim s as string = value
newValue = s.ToText
me.Refresh</pre>
<p>Next, use <strong>Insert &gt; Event Handler</strong> to add the Paint event to the subclass. Write this code in the associated Code Editor:</p>
<pre>dim size as integer = val(newValue)
g.TextSize = size
dim centerx as integer = g.Width/2 - g.StringWidth(newValue)/2
dim centery as integer = g.Height/2+g.StringHeight(newValue,g.Width)/2
g.ForeColor = rgb(size, size, size)
g.FillRect(0,0,g.Width,g.Height)
g.ForeColor = if(size &lt;= 50, rgb(255,255,255), rgb(0,0,0))
g.DrawString(newValue,centerx,centery)</pre>
<p>Lastly, add a new property to the subclass using <strong>Insert &gt; Property</strong>, and using this values:</p>
<ul>
<li><strong>Name:</strong> newValue</li>
<li><strong>Type:</strong> Text</li>
<li><strong>Scope:</strong> Private</li>
</ul>
<h2>Designing the User Interface</h2>
<p>Once we have created the subclasses for the Controls we will use as observers in our example app, it is time to design the user interface. For that, choose the window by default for the project (Window1).</p>
<p>Xojo will show the <strong>Layout Designer</strong> for the selected Window. Drag the subclass controls from the Navigator (or from the Library) so they are arranged as shown in this picture. In addition, drag a couple of CheckBox controls and one TextField too from the Library to the layout.</p>
<p><img loading="lazy" decoding="async" class="alignnone size-full wp-image-2073" src="https://blog.xojo.com/wp-content/uploads/2016/11/Captura-de-pantalla-2016-11-10-a-las-13.23.55.png" alt="captura-de-pantalla-2016-11-10-a-las-13-23-55" width="910" height="534" /></p>
<p>Choose the label instance (with the name &#8220;Label2&#8221; in the example project) and use <strong>Insert &gt; Event Handler</strong> to add the &#8220;newValueReceived&#8221; event handler previously defined in our class. Write the following code in the associated Code Editor:</p>
<pre>dim s as string = value
Select case message
  case "valueChanged"
    me.Text = "Value on source Control: "+ s
  case "charValue"
    me.Text = "ASCII Code for last keystroke: "+ str(asc(s))
End Select</pre>
<p>As you can see, the event uses the received message to decide how to work with the value sent by the observed object. In one case it will show the value as is, and for the other it will show the ASCII code for the value received as Text.</p>
<p>Select now the Slider instance (with the name &#8220;Slider1&#8221; in the example project), and repeat the action to add the Event Handler &#8220;newValueReceived&#8221; to the control. Write the following code in the associated Code Editor:</p>
<pre>me.Value = value</pre>
<p>In this case, the control will simply assign to his &#8220;value&#8221; property the value received.</p>
<p>Select now the ListBox instance (&#8220;ListBox1&#8221; in the example project). Add the Event Handler &#8220;newValueReceived&#8221; and write this line of code:</p>
<pre>me.ListIndex = value</pre>
<p>We will also add the &#8220;Open&#8221; Event Handler, so we can populate some default values to use in the example. Once we&#8217;ve added this event, write the following code in the associated Code Editor:</p>
<pre>for n as integer = 0 to 99
  me.AddRow str(n)
next</pre>
<p>Lastly, select the TextField instance (&#8220;TextField1&#8221; in the example project), and add the &#8220;Keydown&#8221; and &#8220;Lost Focus&#8221; Event Handlers. Once added, select the <strong>KeyDown</strong> event handler and write the following code:</p>
<pre>dim myNotificationCenter as NotificationCenter = NotificationCenter.sharedInstance
myNotificationCenter.sendNotification(me,"charValue",key)</pre>
<p>Next, select the <strong>LostFocus</strong> event and writhe the following code:</p>
<pre>dim myNotificationCenter as NotificationCenter = NotificationCenter.sharedInstance
mynotificationcenter.sendNotification(me,"valueChanged",me.Text)</pre>
<p>For both cases, we retrieve the shared instance from the Notification Center class and publish a new notification, passing along the own control as first argument (acting as originator), the message or published notification as second argument, and the value sent as the third argument. From this point on, the Notification Center will be in charge of propagate the received notification to all the interested objects.</p>
<h3>Subscribing and Unsubscribing to Notifications</h3>
<p>Let&#8217;s get in charge of the user interface controls whose function is to enable and disable the notifications for our MyLabel instance (Label1).</p>
<p>Select the <strong>CheckBox1</strong> control, add the Action event handler and write the following code in the associated Code Editor:</p>
<pre>dim miNotificationCenter as NotificationCenter = NotificationCenter.sharedInstance
select case me.Value
  case true
    miNotificationCenter.register(Label2,TextField1, "valueChanged")
    miNotificationCenter.register(Label2, TextField1, "charValue")
  case False
    miNotificationCenter.removeObserver(Label2)
    CheckBox2.value = false
end select</pre>
<p>Select now the <strong>CheckBox2</strong> control, add the Action event handler and write the following code:</p>
<pre>dim miNotificationCenter as NotificationCenter = NotificationCenter.sharedInstance
select case me.Value
  case true
    miNotificationCenter.register(Label2,TextField1, "valueChanged")
  case False
    miNotificationCenter.removeObserverForMessage(Label2,"valueChanged")
end select</pre>
<p>As you can see, in the first block of code we register the &#8220;Label2&#8221; control so it can receive both notifications when the checkbox value is <strong>True</strong>, and unsubscribe the control from receiving any notification when the checkbox is <strong>False</strong>. For the second block of code, the &#8220;Label2&#8221; control just subscribe or unsubscribe for one of the two notifications, respectively.</p>
<h2>Starting engines!</h2>
<p>What we need to put all to work? Add the <strong>Open</strong> event handler to &#8220;Window1&#8221; and write the following code.</p>
<pre>dim miNotificationCenter as NotificationCenter = NotificationCenter.sharedInstance
miNotificationCenter.register(Label2,TextField1, "valueChanged")
miNotificationCenter.register(Label2, TextField1, "charValue")
miNotificationCenter.register(Listbox1,TextField1, "valueChanged")
miNotificationCenter.register(Slider1,TextField1, "valueChanged")
miNotificationCenter.register(canvas1,TextField1, "valueChanged")</pre>
<p>This code will register the interested controls (observers) to the Notification Center for those Notifications they are interested in. Of course, this can also be done inside the Open event handler for every interested control!</p>
<h2>In brief</h2>
<p>As we have seen, with the combination of the <strong>Observer</strong> and <strong>Singleton</strong> Design Patterns, and the help of one <strong>Class Interface</strong> definition, we have created our own Notification Center from scratch to greatly automatice and simplify the communication between the objects, their processes and easying also the maintenance and extension of the app functionallity.</p>
<p>You can watch <a href="https://youtu.be/bCsGtHKM5GA">the video</a> (in Spanish only) that talks you though this example.</p>
<p><em>Javier Rodri­guez has been the Xojo Spanish Evangelist since 2008, he’s also a Developer, Consultant and Trainer who has used Xojo since 1998. He is in charge of <a href="http://www.aprendexojo.com">AprendeXojo.com</a> and the developer behind the GuancheMOS plug-in for Xojo Developers and the Snippery app, among others.</em></p>
<p>*<a href="http://www.aprendexojo.com/2016/11/patrones-de-diseno-observer-y-ii/">Read this post in Spanish</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Design Patterns in Xojo: Singleton</title>
		<link>https://blog.xojo.com/2016/06/08/design-patterns-in-xojo-singleton/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Wed, 08 Jun 2016 00:00:00 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[Design Patterns]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2016/06/08/design-patterns-in-xojo-singleton/</guid>

					<description><![CDATA[In this post I am going to focus on one of these particular Design Patterns and how to implement it in Xojo: Singleton.]]></description>
										<content:encoded><![CDATA[<p>One of the best things that <strong>Xojo</strong> offers to programming newcomers is that they can simply jump-in and start to write code. In a matter of a few hours they&#8217;ll have a functional app! Nothing new here. (Or for not-so-newcomers, a fast way of creating a functional prototype from a idea).</p>
<p><img loading="lazy" decoding="async" style="display: block; margin-left: auto; margin-right: auto;" src="https://blog.xojo.com/wp-content/uploads/2016/06/CandyMachine.pngt1466486449161ampwidth227ampheight369" sizes="auto, (max-width: 227px) 100vw, 227px" alt="CandyMachine.png" width="227" height="369" />But as these users advance in their Xojo skills, they probably will care about coding better and to embrace the <strong>OOP</strong> way of doing things. After all, Xojo is a modern programming language with <strong>Classes</strong>, <strong>Inheritance</strong>, <strong>Interfaces</strong> and a bunch of the usual OOP paradigms that have much to offer: reusability, better maintainability and a lot of flexibility.<br />
<span id="more-269"></span></p>
<p>When we talk about OOP, Design Patterns arise! Design Patterns are like  recipes, well known solutions or best practices, to a series of problems or situations that emerge again and again in our OOP designs.</p>
<p>These <strong>Design Patterns</strong> are so common that you are probably already using some without knowing it. And if you are curious about what are the most common and the code design problems they solve, then you have to definetly take a look into the BOOK (yes, in uppercase): &#8220;<a href="https://www.amazon.com/Design-Patterns-Elements-Reusable-Object-Oriented/dp/0201633612/" target="_blank">Design Patterns: Elements of Reusable Object-Oriented Software</a>&#8221;</p>
<p>In this post I am going to focus on one of these particular Design Patterns and how to implement it in Xojo: <a href="https://en.wikipedia.org/wiki/Singleton_pattern" target="_blank">Singleton</a>.</p>
<p>OOP is mainly about the instantiation âor object creationâ from a Class definition that acts like a template; so we can have several of these objects around sharing the same behaviour but with a state of their own. Well, the Singleton pattern is the &#8220;opposite&#8221; thing. The answer to having (generally) just one object around from a particular Class.</p>
<p>Why should we want this? The short answer: to limit the access or &#8220;enty point&#8221; to a main functionality of your apps, or when the created object has a high cost or high impact in used resources.</p>
<h2>Implementing the Singleton Pattern</h2>
<p>The key to implement this Design Pattern in your apps is to limit the instantiation of the Class to just one object. So let&#8217;s see how can we achieve this using the Xojo language features. These are the ingredients to the recipe!</p>
<p>A Class Constructor whose scope is set to Private. This is the way we will ensure that the Class consumer will not be able to create several instances using the usual syntax:</p>
<pre>Dim myInstance as MyClass = new MyClass
Dim myInstance as new Myclass</pre>
<p>A <strong>Shared Method</strong> (also known as Static Method or Class Method in other programming languages). This will be the entry point we will use in order to retrieve the unique instance allowed by the Class.</p>
<p>A <strong>Shared Property</strong> whose scope is set to <strong>Private</strong>. This one will be the responsible to hold (point to) the unique instance fromâ¦ the same Class!</p>
<p>Now that we know what the ingredients are, let&#8217;s create our own &#8220;Hello Machine&#8221; as a Singleton Class. Obviously this is not the most useful class in the world, but maintaining the functionality to a minimum will help to focus on the main point about how to implement this Design Pattern in Xojo.</p>
<h2>The &#8220;Hello Machine&#8221; Singleton</h2>
<p>Start the new project creating a new Class using <strong>Insert &gt; Class</strong>. Then, go to the Inspector panel and name the Class as &#8220;HelloMachine&#8221;.</p>
<p>With the new Class item selected in the Project Browser panel (the leftmost), add a new property to it using <strong>Insert &gt; Property</strong>. Name the new property as &#8220;Counter&#8221;, set the Type as Integer and the &#8220;Default Value&#8221; to 1. This is the property that will inform us about how many times has been invoked the class.</p>
<p>Add a new method to the HelloMachine Class (<strong>Insert &gt; Method</strong>). This will be in charge of providing the real functionality to our Singleton class. Use &#8220;Greet&#8221; for the method name and set the Scope to Public. Now, type the following code for the just created method:</p>
<pre>MsgBox "Hello World! Is not funny being the only one instance on Earth?" + endofline + endofline + "You have invoked me " + counter.totext + " times."
counter = counter + 1</pre>
<p>Now it is time to create the class members that will make our HelloMachine behave as a Singleton one.</p>
<p>Start adding the Shared Property that will be in charge to hold the unique class instance used by the App. Use <strong>Insert &gt; Shared Property</strong> for that. Select the just added shared property and using the Inspector panel type &#8220;sharedInstance&#8221; for the &#8220;Name&#8221;, and set the type to &#8220;HelloMachine&#8221;; that is, the same Class type we are just defining (it sounds kind of weird, I know).</p>
<p>Now is time to add our <strong>Class Constructor</strong>. Remember that this one is the special Method whose code is executed every time we want to create a new instance (object) from a particular class.</p>
<p>Use <strong>Insert &gt; Method</strong> and type &#8220;Constructor&#8221; on the &#8220;Method Name&#8221; field of the associated Inspector panel (or choose &#8220;Constructor&#8221; from the dropdown menu). Make sure you set the Scope of the Constructor method as Private. This way we will be sure that nobody will be able to directly instantiate new objects from the class.</p>
<p>Finally we will write the method that will act as the entry point to retrieve the unique instance available from the class; that is, the instance shared among the App.</p>
<p>Use <strong>Insert &gt; Shared Method</strong> and type &#8220;getInstance&#8221; for the &#8220;Method Name&#8221; field. Make sure to set the &#8220;Return Type&#8221; field to &#8220;HelloMachine&#8221;.</p>
<p>Select the &#8220;getInstance&#8221; shared method and type the following code on the associated Code Editor:</p>
<pre>If sharedInstance is Nil then sharedInstance = new HelloMachine
Return sharedInstance</pre>
<p>As you can see, all the &#8220;magic&#8221; consists to verify if has been created already a HelloMachine instance (holded by the sharedInstance Property), returning it if is the case or instantiating and returning it, if otherwise. VoilÃ¡, a Singleton Class!</p>
<h2>Singleton At Work</h2>
<p>Once we have finished our Singleton class definition, let&#8217;s use it in our App. Add the Open event to the default window, for example, and type the following code in the Code Editor:</p>
<pre>Dim myHelloMachine as HelloMachine = HelloMachine.getInstance
myHelloMachine.Greet
Dim myOtherHelloMachine as HelloMachine = HelloMachine.getInstance
myOtherHelloMachine.Greet</pre>
<p>As you can see, we are not instantiating new objects from the Class, just using the Public method to retrieve the unique instance managed by the own Class.</p>
<p>Just for fun, try to instantiate a new object from the class using the regular syntax (I mean, with &#8220;Dim myHellowMachine as new HelloMachine&#8221;) and you will get a Compiler error. That is, no way to have several objects around!</p>
<p>Download an example using the Singleton Design Patter <a href="https://www.dropbox.com/s/znvae5jyvxryz4q/OOP%20Singleton.zip?dl=0" target="_blank">from this link</a>.</p>
<p>You can <a href="https://youtu.be/61KYjND2Vz0" target="_blank">watch the video</a> (in Spanish only) that talks you though this example.</p>
<p><em>Javier RodrÃ­guez has been the Xojo Spanish Evangelist since 2008, he&#8217;s also a Developer, Consultant and Trainer who has used Xojo since 1998. He is in charge of AprendeXojo.com and the developer behind the GuancheMOS plug-in for Xojo Developers and the Snippery app, among others.</em></p>
<p>More Posts From Javier:</p>
<p><!--HubSpot Call-to-Action Code --> <span id="hs-cta-wrapper-2f91fd6d-fb29-4bba-96f2-4a07775b851e" class="hs-cta-wrapper"> <span id="hs-cta-2f91fd6d-fb29-4bba-96f2-4a07775b851e" class="hs-cta-node hs-cta-2f91fd6d-fb29-4bba-96f2-4a07775b851e"><br />
<!-- [if lte IE 8]>


<div id="hs-cta-ie-element"></div>


<![endif]--> <a href="http://blog.xojo.com/2016/05/25/methods-overloading-computed-properties-setters-and-getters/" target="_blank"><img loading="lazy" decoding="async" id="hs-cta-img-2f91fd6d-fb29-4bba-96f2-4a07775b851e" class="hs-cta-img aligncenter" style="border-width: 0px; margin: 0 auto; display: block; margin-top: 20px; margin-bottom: 20px;" src="https://blog.xojo.com/wp-content/uploads/2016/06/2f91fd6d-fb29-4bba-96f2-4a07775b851e.png" alt="Methods Overloading: Computed Properties, Setters and Getters" width="390" height="64" align="middle" /></a> </span><script src="https://js.hscta.net/cta/current.js" charset="utf-8">// <![CDATA[
<script type="text/javascript"><![CDATA[ hbspt.cta.load(608515, '2f91fd6d-fb29-4bba-96f2-4a07775b851e', {});
// ]]&gt;</script></span><br />
<!-- end HubSpot Call-to-Action Code --></p>
<p><a href="http://www.aprendexojo.com/2015/11/patron-singleton-en-xojo/" target="_blank">*Read this post in Spanish</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Methods Overloading: Computed Properties, Setters and Getters</title>
		<link>https://blog.xojo.com/2016/05/25/methods-overloading-computed-properties-setters-and-getters/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Wed, 25 May 2016 00:00:00 +0000</pubDate>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2016/05/25/methods-overloading-computed-properties-setters-and-getters/</guid>

					<description><![CDATA[Learn about the concept of Method Overloading in Object-Oriented Programming (OOP).]]></description>
										<content:encoded><![CDATA[<p>Some years ago, Xojo introduced the ability to use Computed Properties, something that is present in other programming languages too and is based on the use of dedicated methods to assign and retrieve the property value itself. So, in other programming languages, the first of these dedicated methods (or functions), the Setter, is the one invoked every time we want to modify the value of the associated property, while the Getter method is the one used from our code to retrieve the associated value. The <a href="http://developer.xojo.com/userguide/object-oriented-programming" target="_blank">Object-Oriented Programming</a> (OOP) concept found behind this feature is <a href="https://en.wikipedia.org/wiki/Function_overloading" target="_blank">Method Overloading</a>. Nevertheless, let&#8217;s make clear that Xojo Computed Properties are not methods. They aren&#8217;t! But they make our life as developers much easier compared with regular Properties.</p>
<p><span id="more-299"></span><br />
<img decoding="async" style="width: 300px; margin: 0px auto 10px; display: block;" title="Bifurcation.png" src="https://blog.xojo.com/wp-content/uploads/2016/05/Bifurcation.pngt1466486449161ampwidth300" sizes="(max-width: 300px) 100vw, 300px" alt="Bifurcation.png" width="300" data-constrained="true" />As developers, the computed properties definitions don&#8217;t differ a lot from regular ones. For example, every time we create one of these properties via <strong>Insert &gt; Computed Property</strong>, we will define the property name, type and scope as we would do in the case of a regular property; and when we refer to these kind of properties from our code, we will use the usual dot notation and, at the same time, we will assign new values using the habitual equal symbol (&#8220;=&#8221;).</p>
<p><img loading="lazy" decoding="async" style="display: block; margin-left: auto; margin-right: auto;" title="Definicion-de-Propiedad-Calculada-en-Xojo_full.png" src="https://blog.xojo.com/wp-content/uploads/2016/05/Definicion-de-Propiedad-Calculada-en-Xojo_full.pngt1466486449161ampwidth250ampheight117" sizes="auto, (max-width: 250px) 100vw, 250px" alt="Definicion-de-Propiedad-Calculada-en-Xojo_full.png" width="250" height="117" /></p>
<p>As you can see in the screenshot, below the property name we find both methods: <strong>Get</strong> and <strong>Set</strong>. &#8216;Get&#8217; is automatically invoked (and showed by the Debugger) every time we write for instance:</p>
<pre>Dim textVar As String = myProperty</pre>
<p>While &#8216;Set&#8217;  is the one automatically invoked every time we want to assign a new value to the property, using, for instance, a sentence like:</p>
<pre>miPropiedad = MyTextField.text</pre>
<p>But if you try to execute these examples just as they are, you will get errors from the Compiler. The property itself doesn&#8217;t exists yet, just this wireframe or umbrella! When we create a new Computed Property this way, we are creating the wrapper but still have to define the real container (the property itself) in charge to store the values processed by Set and Get. This is something we can fix very easily; just a matter of adding a new property and defining its scope as private. This way we will be sure that no other object can directly access the property. The only way to get and/or set its value would be from the Computed Property methods previously created.</p>
<p>In fact, the way you can more clearly see the relationship between a regular property and the Calculated Property wrapper is by defining the regular property in first place. Add a new property, select it from the Project Browser, access the contextual menu and select the &#8216;<strong>Convert to Computed Property</strong>&#8216; option, as showed in the following screenshot:</p>
<p><img loading="lazy" decoding="async" style="display: block; margin-left: auto; margin-right: auto;" title="Convertir-Propiedad-en-Propiedad-Calculada_thumb.png" src="https://blog.xojo.com/wp-content/uploads/2016/05/Convertir-Propiedad-en-Propiedad-Calculada_thumb.pngt1466486449161ampwidth373ampheight333" sizes="auto, (max-width: 373px) 100vw, 373px" alt="Convertir-Propiedad-en-Propiedad-Calculada_thumb.png" width="373" height="333" /></p>
<p>As result, you&#8217;ll find that Xojo&#8217;s IDE has included the wrapper previously seen, modifying the original property&#8217;s name to include the &#8220;m&#8221; character as prefix. At the same time, the scope will change to Private too.</p>
<h2>The magic behind Set and Get</h2>
<p>Behind of the sugar syntax they provide, the real power found in Computed Properties, when compared with regular ones, resides in the code that we can write on both, and that will be executed just before we retrieve the property value or just before we make a new assignation to it.</p>
<p>Following with our example, if we would be using the property to store a person name, we could use Set on such property to provide a default value if the received one is an empty string:</p>
<pre>Set (Value As String)</pre>
<pre>If Value = "" then mMyProperty = "New User"</pre>
<p>On the other hand, we could use the Get on the property to retrieve the associated value using a predefined format. In our example, this could be getting the name using TitleCase (I know, I knowâ¦ we can do this from the Set too, but just wanted to illustrate the topic exposed).</p>
<pre>Get As String</pre>
<pre>Return mMyProperty.Titlecase</pre>
<h2>Method Overloading</h2>
<p>Did you know Computed Properties always were feasible in Xojo? I mean, what we find behind the Computed Properties on Xojo&#8217;s IDE is a help to us as developers in order to simplify the process (and from an organizational point of view of our code).</p>
<p>The truth is that we always could achieve the same results (and still is possible) using the feature available in every <strong><strong>Object Oriented Programming</strong></strong> language, as is the case of Xojo! I&#8217;m referring to <strong>Method Overloading</strong>. This doesn&#8217;t mean that you have to choose between using Computed Properties or Method Overloadingâ¦ the point here is to introduce what Method Overloading.</p>
<p>Method Overloading is the ability we have to define multiple methods using the same name, as long as their parameters types and/or number varies, and/or the type returned from the method itself. So, it&#8217;s time to see how we can achieve the same results of a Computed Property using Method Overloading.</p>
<p>Start adding a new property via <strong>Insert &gt; Property</strong>. Define its type (String in this example) and its scope as Private. Make sure to add the &#8220;m&#8221; character at the beginning of the property name! (in fact you can use any other character, but we use the &#8220;m&#8221; as convention).</p>
<p>Now it&#8217;s time to create our Setter method. For that, use <strong>Insert &gt; Method</strong> on the same project item where you created the property. Use the same name of the property without the initial &#8220;m&#8221; as the Method name, and write the following code in the Parameters field on the Method&#8217;s Inspector Panel:</p>
<pre>Assigns Value as String</pre>
<p>Leave empty the Return Type field (type returned by the method) and select Public as the Method Scope.</p>
<p>The &#8216;<a href="http://developer.xojo.com/assigns" target="_blank">Assigns</a>&#8216; keyword provides the syntax sugar to use the equal symbol (&#8220;=&#8221;) on the parameter pass to the method. This way, we can invoke our method (myProperty on the example) as follows:</p>
<pre>myProperty = "New Value"</pre>
<p>Does it seems like we are not calling a method but making an assignation to a Property?</p>
<p>Let&#8217;s create the method in charge of the Getter and, for that, we will repeat the same steps involved in the creation of a new method. When done, using the same name, you&#8217;ll see that the Project Browser will group together both methods. In this case, as we want to define the Getter, we don&#8217;t need to define the parameters, just the returned type (String for this example).</p>
<p>This is the way it will look in the Project Browser:</p>
<p><img loading="lazy" decoding="async" style="display: block; margin-left: auto; margin-right: auto;" title="Sobrecarga-de-metodos-en-Xojo._thumb.png" src="https://blog.xojo.com/wp-content/uploads/2016/05/Sobrecarga-de-metodos-en-Xojo._thumb.pngt1466486449161ampwidth250ampheight118" sizes="auto, (max-width: 250px) 100vw, 250px" alt="Sobrecarga-de-metodos-en-Xojo._thumb.png" width="250" height="118" /></p>
<p>As we have previously seen, the method overloading is possible because they differ in the provided parameters and/or returned type, despite they use the same name. That way, the Compiler will know exactly which one has to execute on runtime based on such information.</p>
<p>Done! You&#8217;ve learned what Computed Properties are and how they work from the OOP side of the Xojo&#8217;s language.</p>
<p>Finally, probably you want to know too that:</p>
<p>* Computed Properties appear in the debugger and cannot be overloaded on subclassses<br />
* Getter/Setter method overloading does not appear in the debugger, but can be overloaded on subclasses and specified in interfaces.</p>
<p>You can <a href="https://youtu.be/3cvYYkZbdOE" target="_blank">watch the video</a> (in Spanish only) that talks you though this example.</p>
<p><em>Javier RodrÃ­guez has been the Xojo Spanish Evangelist since 2008, he&#8217;s also a Developer, Consultant and Trainer who has used Xojo since 1998. He is in charge of AprendeXojo.com and the developer behind the GuancheMOS plug-in for Xojo Developers and the Snippery app, among others.</em></p>
<p>More Posts From Javier:<br />
<!--HubSpot Call-to-Action Code --> <span id="hs-cta-wrapper-a66218db-ec5e-4a96-a292-57d093659074" class="hs-cta-wrapper"> <span id="hs-cta-a66218db-ec5e-4a96-a292-57d093659074" class="hs-cta-node hs-cta-a66218db-ec5e-4a96-a292-57d093659074"><br />
<!-- [if lte IE 8]>


<div id="hs-cta-ie-element"></div>


<![endif]--> <a href="http://blog.xojo.com/2016/05/09/let-your-os-x-desktop-app-react-to-custom-uris/" target="_blank"><img loading="lazy" decoding="async" id="hs-cta-img-a66218db-ec5e-4a96-a292-57d093659074" class="hs-cta-img aligncenter" style="border-width: 0px; margin: 0 auto; display: block; margin-top: 20px; margin-bottom: 20px;" src="https://blog.xojo.com/wp-content/uploads/2016/05/a66218db-ec5e-4a96-a292-57d093659074.png" alt="Let Your OS X Desktop App React to Custom URIs" width="455" height="84" align="middle" /></a> </span><script src="https://js.hscta.net/cta/current.js" charset="utf-8">// <![CDATA[
<script type="text/javascript"><![CDATA[ hbspt.cta.load(608515, 'a66218db-ec5e-4a96-a292-57d093659074', {});
// ]]&gt;</script></span><br />
<!-- end HubSpot Call-to-Action Code --></p>
<p><a href="http://www.aprendexojo.com/2016/05/sobrecarga-de-metodos/" target="_blank">*Read this post in Spanish</a></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>WeakRef and Memory Management</title>
		<link>https://blog.xojo.com/2016/04/20/weakref-and-memory-management/</link>
		
		<dc:creator><![CDATA[Javier Menendez]]></dc:creator>
		<pubDate>Wed, 20 Apr 2016 00:00:00 +0000</pubDate>
				<category><![CDATA[Mac]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[AprendeXojo]]></category>
		<category><![CDATA[Memory]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2016/04/20/weakref-and-memory-management/</guid>

					<description><![CDATA[Sometimes apps can simply reach unstable situations by their very nature. Keep memory management under control with the help of the WeakRef class.]]></description>
										<content:encoded><![CDATA[<p>Object Oriented Programming with Xojo, and in this case Event Oriented Programming as well, is simply wonderful. You create objects (Instances) from the defined classes that act as templates and just let them roll. From there, the interactions made by the user are those that determine how objects interact with each other via sending messages to each other (method calls), the access to properties and also the execution of events.</p>
<p>However, sometimes the combination can simply reach unstable situations by the very nature of our applications and here is where failures can arise in memory management. Fortunately, we can keep this under control with the help of the <a href="http://developer.xojo.com/xojo-core-weakref" target="_blank" rel="noopener">WeakRef class</a>.<br />
<span id="more-281"></span><br />
This is, in fact, what happened to me recently while implementing a new feature in <a href="http://www.aprendexojo.com/software/snippery" target="_blank" rel="noopener">Snippery</a> my productivity application where one of those unlikely but possible cases one of the objects left in an unstable state. What does this mean? The referenced Control object stored in a property was not marked as nil once it was out of scope because its containing window was closed, so it was simply unsafe (an dangerous!) to check or access its properties and methods through a simple verification of the type:</p>
<p><span style="font-family: 'courier new', courier;">if miPropiedad &lt;&gt; nil then</span></p>
<p>Despite the object referenced through the property would have been released, this condition will execute the code inside the block resulting in a unexpectedly exit from the app! In fact inspecting the object via Xojo&#8217;s debugger shows that the reference is still there but it inner structure is void.</p>
<p>So executing the previous code will bring a beautiful error message from OS X:</p>
<p><span style="font-family: 'courier new', courier;">EXC_BAD_ACCESS (SIGSEGV)</span></p>
<p>That is an attempt to access a memory vector where we expected to find a data structure that is not there anymore.</p>
<p>I have to say that after further research on the subject I have found that this kind of error does not always occur and that it may depend on the type of object that we maintain the reference to, or even the property we want to access, or the method we try to call when the objects is in this &#8220;unstable&#8221; state. In the best of the cases, simply nothing happens. In the worst case, your application will suffer an unexpected exit you will not be able to trap using the Try &#8230; Catch block or exception handling mechanism offered by the Xojo language.</p>
<p>If you want to see for yourself what I&#8217;m talking about, you can download the <a href="https://www.dropbox.com/s/l1az8r9jq0q2aps/WeakRef%20Example.zip?dl=0">example application</a> that reproduces this kind of problem related with memory management.</p>
<p><strong>WeakRef to the rescue!</strong></p>
<p>How can we solve these kinds of situations? Easy! The WeakRef class allows code to maintain weak references to objects. When you wrap the object you&#8217;re interested in an instance of the class WeakRef, we will ensure that such reference is released (and thus becomes nil) through proper memory management. So, problem solved! From this point on we can perform and trust a conditional test of the reference against &#8216;nil&#8217; before trying to access any of the properties of the object itself.</p>
<p>In the case of our sample application, we can fix the problem with the following changes:</p>
<p>1. We define the property SourceControl Worker class to be of the WeakRef Data Type<br />
2. We make the following changes to Worker class constructor (where the referenced Control instance is now wrapped into a WeakRef instance):</p>
<p><span style="font-family: 'courier new', courier;">sourceControl = new weakref( c )</span></p>
<p>3. We modify the conditional block of code for the Worker method to:</p>
<p><span style="font-family: 'courier new', courier;">if sourceControl.Value &lt;&gt; nil then</span><br />
<span style="font-family: 'courier new', courier;">  textArea(sourceControl).<wbr />SelLength = 0</span><br />
<span style="font-family: 'courier new', courier;">  textArea(sourceControl).Text = &#8220;This is a test&#8221;</span><br />
<span style="font-family: 'courier new', courier;">end if</span></p>
<p>Note that in this case we Cast SourceControl to TextArea, so  we can work with the properties and methods of the control that we know are actually a control of TextArea type.</p>
<p>Make the changes, run the app again and you&#8217;ll notice that this time the app will continue running without errors once all the windows are closed.</p>
<p>You can watch <a href="https://youtu.be/5-8iwlvNSsY" target="_blank" rel="noopener">the video</a> (in Spanish only) that talks you though this example.</p>
<p><em>Javier RodrÃ­guez has been the Xojo Spanish Evangelist since 2008, he&#8217;s also a Developer, Consultant and Trainer who has used Xojo since 1998. He is in charge of AprendeXojo.com and the developer behind the GuancheMOS plug-in for Xojo Developers and the Snippery app among others.</em></p>
<p><span style="text-decoration: underline;"><em><a href="http://www.aprendexojo.com/2016/04/weakref-y-la-gestion-de-memoria/" target="_blank" rel="noopener">*Read this post in Spanish</a>.</em></span></p>
<p><!--HubSpot Call-to-Action Code --> <span id="hs-cta-wrapper-abfc1e1f-d1ee-4de3-bd9e-7bfe6930b212" class="hs-cta-wrapper"> <span id="hs-cta-abfc1e1f-d1ee-4de3-bd9e-7bfe6930b212" class="hs-cta-node hs-cta-abfc1e1f-d1ee-4de3-bd9e-7bfe6930b212"><br />
<!-- [if lte IE 8]>


<div id="hs-cta-ie-element"></div>


<![endif]--> <a href="http://developer.xojo.com/international-resources" target="_blank" rel="noopener"><img loading="lazy" decoding="async" id="hs-cta-img-abfc1e1f-d1ee-4de3-bd9e-7bfe6930b212" class="hs-cta-img aligncenter" style="border-width: 0px; margin: 0 auto; display: block; margin-top: 20px; margin-bottom: 20px;" src="https://blog.xojo.com/wp-content/uploads/2016/04/abfc1e1f-d1ee-4de3-bd9e-7bfe6930b212.png" alt="International Resources Xojo" width="417" height="229" align="middle" /></a> </span><script src="https://js.hscta.net/cta/current.js" charset="utf-8">// <![CDATA[
<script type="text/javascript"><![CDATA[ hbspt.cta.load(608515, 'abfc1e1f-d1ee-4de3-bd9e-7bfe6930b212', {}); // ]]&gt;</script></span><br />
<!-- end HubSpot Call-to-Action Code --></p>
]]></content:encoded>
					
		
		
			</item>
		<item>
		<title>Programming Resources For Students</title>
		<link>https://blog.xojo.com/2015/06/15/learn2code-xojo-for-students-of-all-ages/</link>
		
		<dc:creator><![CDATA[Alyssa Foley]]></dc:creator>
		<pubDate>Mon, 15 Jun 2015 00:00:00 +0000</pubDate>
				<category><![CDATA[Community]]></category>
		<category><![CDATA[Learning]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[Games]]></category>
		<category><![CDATA[Object-Oriented]]></category>
		<category><![CDATA[Rapid Application Development]]></category>
		<category><![CDATA[Women in Tech]]></category>
		<guid isPermaLink="false">http://blogtemp.xojo.com/2015/06/15/learn2code-xojo-for-students-of-all-ages/</guid>

					<description><![CDATA[We offer a lot of resources to help anyone interested in learning to code with Xojo. But we do have some specific resources that will interest and assist students learning the fundamentals of coding and Xojo:]]></description>
										<content:encoded><![CDATA[<p>Can I learn to code in Xojo for free? <a href="http://xojo.com/download/">Yes</a>, Xojo is free for development and testing!</p>
<p>Do you have a free book so I can learn to code? <a href="http://xojo.com/learn/">Yes</a>, <em>Intro to Programming with Xojo</em> is free!</p>
<p>Can I ask my beginner questions? <a href="https://forum.xojo.com">Yes</a>, the Xojo forum is a gateway to the friendly and helpful Xojo community.</p>
<p>The Xojo language is <a href="http://developer.xojo.com/kb/oop">Object-Oriented</a>. Object-Oriented programming is an excellent way to learn the fundamentals of computer programming. Xojo is also cross-platform, which means you can build apps for all kinds of platforms using a single code base. Xojo is a <a href="http://en.wikipedia.org/wiki/Rapid_application_development">Rapid Application Development</a> tool, which means it&#8217;s developed to make building apps simple and quick.</p>
<p><span id="more-219"></span></p>
<p>We offer a lot of resources to help anyone interested in learning to code with Xojo. But we do have some specific resources that will interest and assist students learning the fundamentals of coding and Xojo:</p>
<p><strong>Books</strong></p>
<p><a href="http://www.xojo.com/learn/" target="_blank" rel="noopener">Introduction to Programming With Xojo</a>&#8211; This is a solid resource for learning the fundamentals of programming. While you will use Xojo, the concepts introduced are applicable to any language you want to learn later. In our experience, this book can be helpful to students as young 12 or 13 years old! We also have a Teacher&#8217;s Guide for educators planning on using Xojo in the classroom.</p>
<p><a href="http://xojo.com/learn/" target="_blank" rel="noopener">iOS Booklet</a>&#8211; This booklet shows you how to use Xojo to develop for our latest supported platform, iOS!</p>
<p><a href="http://developer.xojo.com/community-books-magazines-training-and-tutorials">Books, Magazines, Training &amp; Tutorials</a> from the Xojo community.</p>
<p><strong>From the Xojo Blog Archives</strong></p>
<p>First and foremost, <a href="https://blog.xojo.com/2013/12/09/who-should-learn-to-code-everyone/">who should learn to code!? Everyone!</a><br />
Now that you have made your apps with Xojo, read how to <a href="https://blog.xojo.com/2018/07/16/how-to-selling-your-xojo-apps/">Package, Sell &amp; Market your apps</a>.<br />
<a href="https://blog.xojo.com/2014/03/03/flappy-bird-in-xojo/">Xoppy Bird</a> &#8211; Building a Flappy Bird clone in Xojo<br />
Hour of Code Projects for teachers &amp; students: <a href="https://blog.xojo.com/2013/12/11/hour-of-code-spelling-test/">Spelling Test</a>, <a href="https://blog.xojo.com/2013/12/12/hour-of-code-math-facts/">Math Facts</a>, <a href="https://blog.xojo.com/2014/12/19/hour-of-code-2014/">iOS Doodle</a>, <a href="https://blog.xojo.com/2015/12/07/hour-of-code-cat-pictures/">Cat Pictures</a>, <a href="https://blog.xojo.com/2017/12/05/hour-of-code-2017/">Asteroid Run</a><br />
<a href="https://blog.xojo.com/2013/12/12/the-flat-earth-for-young-software-entrepreneurs/">The Flat Earth for Young Software Entrepreneurs</a>&#8211; Today a 12 year old with a good idea and some determination can create an app and sell it with little up-front cost.<br />
<a href="https://blog.xojo.com/2013/10/23/earn-the-boy-scout-programming-merit-badge/">Earn the Boy Scout Programming Merit Badge</a> with Xojo.</p>
<p><strong>On-Demand Webinars &amp; Videos</strong></p>
<p><a href="https://www.youtube.com/watch?v=h_elqXDrues">Retro Gaming</a> &#8211; A fun webinar for beginners! Learn as we create a simple clone of the Atari 2600 game <a href="http://en.wikipedia.org/wiki/Combat_%281977_video_game%29">Combat</a>.<br />
This <a href="https://www.youtube.com/playlist?list=PLPoq910Q9jXiYdPy3sPm_-X9_ol3t9NdM" target="_blank" rel="noopener">Playlist</a> of videos is geared towards Getting Started with Xojo. Recorded webinars and video tutorials can be <a href="https://www.youtube.com/user/goxojo">watched anytime</a>.</p>
<p><strong> Tutorials &amp; Quizzes</strong></p>
<p>Want to see it done? <a href="http://developer.xojo.com/tutorials-overview" target="_blank" rel="noopener">Tutorials</a> take you step-by-step through the code for a Desktop, Web or iOS program. Or get into the details with how to create your own customer controls, build a messenger app, access the serial port, build an iOS app and more.</p>
<p>For a greater challenge see our <a href="http://developer.xojo.com/tutorial/timer">Timer</a> Tutorial &amp; Quizzes, <a href="http://developer.xojo.com/tutorials/sqlite-basics">SQLite Basics</a> Tutorial &amp; Quizzes and the more in-depth <a href="http://developer.xojo.com/sqlitedatabase-and-iossqlitedatabase-for-beginners-tutorial-quizzes">SQLiteDatabase &amp; iOSQLiteDatabase</a> Tutorial &amp; Quizzes. Keep checking in, we add new Tutorials all the time!</p>
<p><strong>Other Resources</strong></p>
<p>Here are step-by-step instructions on how to <a href="http://developer.xojo.com/get-started">get started with Xojo</a>. And of course the <a href="http://blog.xojo.com" target="_blank" rel="noopener">Xojo Blog</a> is always full of tips, announcements, and news about Xojo and cross-platform development. The <a href="http://forum.xojo.com" target="_blank" rel="noopener">Xojo Forum</a> is a good stop when you want to crowdsource your answers or ask a Xojo expert. There are also <a href="http://developer.xojo.com/community-open-source-projects">open-source Xojo projects</a> to review and utilize.</p>
<p>What do you need to start learning to code with Xojo? <a href="https://www.xojo.com/company/contact.php">Email me</a>, I&#8217;m here to help you find the resource you need.<!-- end HubSpot Call-to-Action Code --></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
