This video is part of a four-part series on thinking ahead. In this video we talk about the need for reusable program components. As software developers we should try to reuse code whenever possible.
Now this might seem counterintuitive at first as we place such a strong emphasis as teachers on copyright and producing original work. Simply put, you won't learn to be a good programmer by simply copying other people's code. However, in software development, code reuse offers many benefits.
It shortens development time, saves systems resources, lowers the overall development cost of a product, and reduces the need for redundant or repeated code. All of this can be achieved by reusing existing sections of code that have been tested, by a previous developer. The point of reusable components is that sections of code can and should be reused during the development of newer programs.
One of the key skills in thinking ahead is to carefully consider which parts of your solution can be reused from previous programs. Reusing existing components during software development saves time, money and resources. One example of code reuse that you should already be familiar with is writing code in a modular way. In other words, creating subroutines such as procedures, functions and methods, blocks of codes that perform a task and can be reused multiple times, simply by calling them and supplying them with the data they need.
Leading on from this idea is the concept of using a software module or library. Here we can see that the random library has been imported into a Python program. All of the pre-written and pre-tested code in the random library is now available for this program to use. It's pointless for a programmer to write their own, potentially flawed, random routines if perfectly effective ones already exist. Using pre-written routines, compiled together into software libraries has many advantages.
As we said they're already compiled so they're tested and error free. Using libraries therefore saves the work for programmers, shortens overall development time and reduce costs. The routines may be used multiple times and they could even have been written in different programming languages.
This therefore allows programmers to take advantage of other programmers expertise. It's a more standardized approach to coding. and it can end up resulting in fewer developers being needed to work on a project. Here's an example of an entire component that can be used across a suite of programs. You'll be familiar with this panel which allows you to change the appearance of text by altering the font, colour and size.
This component belongs to the Office 365 suite of productivity applications. It was designed and tested by Microsoft developers and can now be found across multiple programs in their suite. Another example is external reuse, which means reselling components to a third party. We see this a lot with international tech companies like Facebook.
They've become so popular that they offer integration with other programs and software platforms. You may use certain programs and systems to log into platforms like Google or Facebook. In doing so, developers can reap the benefits of your account being linked to your social media profile.
For example, they may be able to pull in other contacts from your friends list, if you provide them with permission of course. The system being linked to will make certain procedures and functions available to other developers. via what's known as an Application Program Interface or API. APIs are a great example of external code reuse. The developers leveraging the power of other developers software without having to write the code themselves.
Having watched this video you should be able to answer the following key question. What do we mean by reusable program components and how can they save us time? To help get your head around everything to do with computational thinking, we have a freely available downloadable cheat sheet.
It's got two sides to it. There's a basic poster that reminds you at a top level what the five different strands are. And on the back, there's a much more detailed explanation.
This resource is completely free from student.craiganddave.org. Just scroll down and select the section that says A-Level Revision. You'll then see a section called OCR, AS and A-Level, and there's a number of cheat sheets in there. including two versions of the computation one. Just click download to get the zip file.