Mt. San Jacinto College Computer Information Systems
Minimize header.

CSIS 111B: Fundamentals of Computer Programming: Lessons

Lesson 13

APIs,
Libraries &
Frameworks

Application Programming Interfaces (APIs)

An API can be defined as "a set of clearly defined methods of communication between various software components." The best way to think of an API is as a building block that can be used to add functionality to your program. Any professionally written API that you use will have a well defined interface with some kind documentation on how to use it. APIs come in all shapes and formats and depending on the type of programming you are building you might even use an API written in a different programming language than the program you are writing in, however you won't care because all you need to know is how to interact with the API using its provided interface.

Images representig the Google, Twitter, and Facebook APIs, Web pages, and mobile apps.
Table of Contents
Amazon Web Services
screenshot of the AWS homepage.
Table of Contents
Facebook for Developers
Image of the facebook for developers toolbar.
Image showing a sample facebook developer's dashboard screen.
Table of Contents
Google Developers

Website

Google Developers
screen capture from google developer's home page.
Table of Contents

Libraries

Libraries come in many different configurations, but generally they are a collection of functions, APIs, Classes, or pre-compiled objects that can be used to provide added functionality to an application without you having to write the code required to accomplish the same task. Libraries are also contained within Frameworks, as you can see in the Frameworks section on this page.

JavaScript Libraries

There are currently numerous JavaScript libraries available for use in enhancing your Web site or application. jQuery is one of the more popular and well known JavaScript libraries.

Table of Contents

Frameworks

The best way to think of a software framework is as a comprehensive system for developing applications by utilizing an existing code base provided by an included coding library. Depending on the framework, it may or may not be open-source, it could have supporting tools like a compiler, or a code editor enhanced for the programming language used. The biggest drawback to using a particular framework could be that you can only code for certain platforms, or a change to the existing code library may change and break your program.

Here is a recent article written about software frameworks; the author lists seven reasons why frameworks are the new programming languages.

The .Net Framework

The .NET (pronounced dot net) framework is a software framework developed by Microsoft that, until recently, ran primarily on computers running the Microsoft Windows operating system. However, Microsoft has made most of its coding libraries available as "open-source" allowing a larger community of developers to contribute to its content, but also with the advent of .NET Core, has now made it so that programs written using the .NET framework can now run on any device running either the Android, OS X, iOS, or Linux operating systems in addition to Windows.

The .NET framework includes a large class library named the Framework Class Library (FCL) and provides language interoperability (each language can use code written in other languages) across several programming languages. Programs written for .NET framework execute in a software environment (in contrast to a hardware environment) named Common Language Runtime (CLR), an application virtual machine that provides services such as security, memory management, and exception handling. (As such, computer code written using .NET framework is called "managed code".) FCL and CLR together constitute the .NET Framework.

The layered architecture of the .NET framework.
Table of Contents
Finding Documentation

In order to learn about the classes that are available in the .NET library, including their properties, methods, and events, check out the Microsoft Developer's Network (MSDN) Website by navigating your Web browser to https://msdn.microsoft.com/en-us/library/gg145045(v=vs.110).aspx, this is where we'll find the home page for the Microsoft .NET Framework's Class library.

The .NET Framework Class Libray page showing a listing of namespaces.

On this page we see a list of namespaces. The System namespace contains numerous classes related to basic system operations including the Console class which can be used to display output to the screen or accept user input from the keyboard. To view the list of classes which make up the System name space, click on the blue text that reads "System". Now, we see a list of classes that are in the System namespace, scroll down until you find Console and then click on the "Console" blue text. You should see a page similar to the image below.

The Console class description.

Now, you are looking at the details of the Console class. In object-oriented programming, a class  is a set of data and methods, which is another way of saying properties and functions. Like variables, Properties store data, and functions do things like output text to the screen — like the WriteLine method of the Console class. Scroll down to the Methods section of the Console class, this section contains all the actions in the Console class we can use display (write) data to the console screen or take user input from the keyboard (read). Scroll towards the bottom of the list of methods until you see the first instance of the Write method, it should read "Write(Boolean) as shown in the figure.

Write(Boolean) method description.

If you read the description to the right you can see that this method "Writes" the text (boolean converted to a string data type) to the standard output stream, which in the case of a console app is the screen on the user's device. Look through all of the instances of the Write method and notice that except for the char data type all other data types are converted to text (a.k.a. the string data type). This is important to note for later when you want to combine data types into your output; it's good to know that all data types will be converted to string data types.

WriteLine() method description.

Interesting, there are a lot of methods (functions) that the Console class can perform, and some of those methods have the word "Read" in them. Does it make sense that if WriteLine generates output to the screen that ReadLine will take input from the screen? Well, guess what, it does, even if it's description does not convey that very clearly to beginning programmers.

Console.ReadLine method description.

These classes are referred to as helper classes in that we don't have to create an instance of them in order to use them in our code (more on instances later). Another common thing that programmers need to do is convert data from one data type to another. The good news is that in object-oriented languages they also provide helper classes for all of the primitive data types and more. For instance it is very common to convert a string data type to an int data type. To do this you can use the Int32 helper class.

 The Int32 Parse method description from MSDN.

As you can see the Int32's Parse method accepts a string data type as input and then converts it to a signed 32 bit integer data type - once the input is converted to the correct data type we can safely assign it to our int variable quantity without throwing an error.

Table of Contents

How To Become and What It's Like To Be A Programmer

The following is a series of videos by a gentleman of the name of John Sonmez. I am not endorsing him nor his products here, I just found these videos interesting, provocative, and entertaining and thought you might enjoy viewing them as well.

What Was Your First Programming Job Like?
Table of Contents
What Do You Need To Know For Your First Developer Job?
Table of Contents
Programming Job With No Experience
Table of Contents
How To Become A Software Developer Without A Degree
Table of Contents

Software Architecture

Uncle Bob martin talks about software architecture and when to make key decisions about design elements.

Table of Contents