PCDE Course: Module 10 Content

Knowledge Check 10.1: Command Line Commands

Knowledge Check 10.2: Networks

Discussion 10.1: Pros and Cons of Using Containers

Notes for this exercise are covered in containers and the specific platform of containers, Docker.

Prompt

Once you have read about containers, the pros and cons of using them, and of using Docker specifically, summarize your understanding of Docker. In your own words, discuss at least three benefits of using Docker and at least three disadvantages to using Docker or containerization in general.

Read the statements posted by your peers. Engage with them by responding with thoughtful comments and questions to deepen the discussion. Comment on whether you agree or disagree with their take on Docker and containerization.

Response

Containers in context of software engineering is essentially a standardized unit of software that ensures that the software runs the same way on any machine. It's a lot more than that however. Due to there being isolation between the host machine and the container, deploying software can be orchestrated and made less error prone.

This is similar to virtual machines in that they both provide isolation between the host machine and the software. However, containers are much more lightweight than virtual machines. Where virtual machines are essentially a full operating system running on top of another operating system, containers are just a process running on the host machine. The container effectively uses the same host operating system resources, with a sandboxed environment for the software to run in.

So when is it useful to add the extra complexity of containers?

When not to use Docker?

Knowledge Check 10.3: Docker

Activity 10.1: Creating a Docker Image

In this activity, you will be using Visual Studio (VS) Code to create an image for a web application that displays Hello World - my first Docker Image!. Make sure to install the Docker extension for VS Code.

Prior to beginning this activity, be sure to review the submission instructions below to ensure that you collect the required screenshots as you progress through the activity.

To complete the activity, perform the following steps:

Download the following starter file to your local machine: Assignment 10.1 - Docker Image.zip. The zip file contains the initial code for this activity. Open the folder in Visual Studio Code:

Prior to beginning this activity, be sure to review the submission instructions below to ensure that you collect the required screenshots as you progress through the activity.

Instructions

To complete the activity, perform the following steps:

1. Download the following starter file to your local machine

2. Open the folder in Visual Studio Code

3. Add a file called Dockerfile & copy these contents to the file

FROM node:12.16.3

WORKDIR /code

ENV PORT 80

COPY package.json /code/package.json

RUN npm install

COPY . /code/

CMD [ "node", "src/server.js"]

4. Now you are ready to start creating an image of this web application

5. Run the command from the prompt to create an image

docker build --tag hello-world .

6. View the Docker image

docker images

7. Execute the run command to start the container

docker run -p 8080:80 --name hello -d hello-world

8. Verify the application and container are working

Submission Instructions

The submission for this activity should be a word document that contains the following screenshots, each labeled for the step it represents:

  1. Dockerfile added to the Activity 10.1 - Docker Image folder
  2. Screenshot of running the docker build command
  3. Screenshot of running the docker images command
  4. Screenshot of running the docker run command to run the image in the container
  5. Screenshot of a web browser to show that you have navigated to the URL of http://localhost:8080 and the Hello World - my first Docker Image! message is displayed

Discussion 10.2: Swagger vs. Postman

Introduction

In this module, you have learned about Swagger and Postman, two tools used for API management and communication. As you learned, Swagger is an interface documentation tool that facilitates API communication between machines. Postman is another popular tool that is used for API testing and communicating using HTTP requests.

Consider that you are asked by your manager to recommend a tool to be used by your organization for API management and communication. Evaluate both tools, Swagger and Postman, to determine which tool you would recommend.

Below are some additional resources for you to review to compare Swagger and Postman:

You are encouraged to conduct additional research on your own to delve deeper into these tools and learn more about their uses.

Discussion Prompt

Once you have explored both Postman and Swagger in greater depth, craft an argument to your manager to describe which tool you would recommend for your organization to use. Be sure to describe your reasoning in detail. What are the benefits of using the tool that you have recommended? Why did you choose it over the alternative?

Read the statements posted by your peers and consider their reasoning for choosing the tool that they selected. Engage with them by responding with thoughtful comments and questions to deepen the discussion.

Suggested Time: 60 minutes

Suggested Length: 200-250 words

This is a required activity and will count toward course completion.

Discussion Contribution

I've worked a lot with APIs in my current line of work, which is front end software engineering. It involves a lot of communication between the client (my work) and the servers that supply it with the data it needs to display and make interactive. That means I've used several API testing tools, including Postman and Swagger (to a lesser degree). Personally, I find Postman much more useful for my needs, probably because I'm consuming APIs more than I'm creating them, as Swagger is a lot more focused on Documentation. So here are the reasons I'm recommending Postman.

Postman is more intuitive

I find Postman to be much more intuitive than Swagger. All the information I need is right there in the UI, making discoverability of its features easier. I will say though, you often don't need a lot of the features Postman provides, so it can feel a bit bloated at times navigating its UI. But for large teams that might be necessary.

Collaboration

As previously hinted, although Postman can have a very complex UI, it does contain most features you and a large team might need. You can store, save, document, and modify API calls, very easily between team members.

Testing

Postman is perhaps best when used to test an API. The UI offers many tools to test an API, including the ability to create automated tests for the API, and defining variables to alter the parameters of a request.

Documentation

Although Swagger is a better documentation tool, Postman does have some documentation features. You can export your API calls to various formats that can then be used to document your API. You can even have code snippets generated to make the API calls you need.

Knowledge Check 10.4: Localhost

Try-It Activity 10.1: Writing Requests in Postman

How can you use Postman to test your APIs?

Postman allows for creating and modifying REST HTTP requests to be run against any endpoint on the internet, or local network. With easy UI elements for modifying things like headers, request line parameters, and payload body, this becomes a lot easier. Then its many ways to view the response in an easy to read format, it's easy to evaluate the response and make changes to the request. And accumulating various kinds of requests in their storage system, you can also come back later and verify that the API works as expected.

What are the advantages/disadvantages of using Postman for testing?

It's a fairly comprehensive UI tool. That means there's less reading of documentation to make it do what you need it to. Doing this by the terminal or some scratch software you wrote is not as easy. And the way the UI is designed adding parameters, headers, tokens, etc. is a lot faster and easier than most other methods to test a REST API.

Where Postman can get frustrating is just how complex the UI is. Sometimes you just need to make a simple request and get a simple response. All the steps involved in making a request in Postman can be a bit much.

What are some utilities in Postman that can help you in building and managing APIs?

Postman allows creation of mock API servers to test functionality without an actually implemented API server. This can be great if you have some ideas for API endpoints but want to see in isolation how that behaves before spending a ton of time implementing it. Postman scripts also enables automation of API testing.

Discussion 10.3: Postman and Strapi

Introduction

In this module, you have learned about some basic software engineering tools. Two of these important tools are Postman and Strapi. As you have learned, Postman is an application commonly used for API testing, creating HTTP requests, and debugging. Strapi is an efficient CMS that provides the framework for developers to build websites and integrate various tools for creative web development.

Below are some additional resources for you to review to learn more about Postman:

Below are some additional resources for you to review to learn more about Strapi:

You are encouraged to conduct additional research on your own to delve deeper into these tools and learn more about their uses.

Discussion Prompt

Once you have explored both Postman and Strapi in greater depth, for each tool:

Read the statements posted by your peers. Engage with them by responding with thoughtful comments and questions to deepen the discussion.

Suggested Time: 60 minutes

Suggested Length: 200-250 words

This is a required activity and will count toward course completion.

Discussion Entry

Summarizing Postman & Strapi Practical Application

Postman is a tool that allows you to create and send HTTP requests to any URL. It is used for API testing, debugging, documentation and collaboration workflows. Strapi is a headless CMS that allows you to create and manage content. The CMS can also generate data model entities and properties with corresponding API endpoints quickly and easily.

Using Strapi you can quickly create a data-centric API for your project. Then using Postman you can test the API to make sure it works as expected. Putting the two together you can achieve a pretty pleasant data engineering workflow.

Examples of Postman & Strapi on the Job

As mentioned, Strapi provides a mature web framework to quickly build data-based APIs. Then using Postman you can quickly test and iterate the API to make sure it works as expected.

Pros of Using Postman & Strapi

Speed of Iteration

As we've seen in our previous projects. Data engineering is all about iterating processes, designs and models. These tools allow for quick and lower cognitive load for iteration of the API.

Ease of Use

Both tools are easy to use and have a low learning curve. Meaning onboarding goes quickly, and mental stress on portions of development that don't require a lot of thought get reduced.

Cons of Using Postman & Strapi

Complexity

Both tools are fairly complex. Although Postman's UI can be easy to use, using it to the fullest can take some time to get used to. Strapi is also fairly complex, getting a standard deployment of it up and running can require some effort.

Fixed Workflows

Strapi has some opinionated design choices. This is a double edged sword. While it means that you can get a lot done quickly, it also means that you can't do everything the way you might want to do it. Same goes for Postman, it has fairly specific workflows to work with HTTP requests.

Knowledge Check 10.5: Requests

References

Web Links

Note Links