Objects and Libraries
Goals
You understand the concepts of an object and you know how to access its properties
You know what an external library is and why we use them in our program
When we import the Tinkerforge Device Manager in our HTML file, we automatically get access to a global variable called tf
(short for Tinkerforge). This variable stores a reference to the Tinkerforge Device Manager (TDM) object and all its functionality. The TDM object is part of an external library that we import into our application and that gives us additional functionality for our app. This functionality comes as a set of functions to deal with Tinkerforge devices. If we didn't have the external library, we would have to implement the functionality ourselves, and therefore re-invent the wheel. In programming, we want to avoid re-inventing an existing functionality at all costs.
How do we find external libraries?
There are different ways to find out whether a functionality was already implemented by someone else. The simplest is to use Google and search for terms that describe what we need. Depending on the programming language we use, there are platforms that bundle external libraries so that they are easier to find.
GitHub is a code sharing platform for all types of code projects. GitHub offers a search engine with flexible filtering, for example to see only JavaScript projects.
npm is a platform specific for JavaScript libraries. npm is also the de facto standard for dependency management in JavaScript projects. See for example the native Tinkerforge JavaScript library on npm.
How do we know what an object can do?
Last updated
Was this helpful?