0% found this document useful (0 votes)
38 views

DEVASC Module 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views

DEVASC Module 3

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 81

Module 3: Software

Development and Design


Rovilyn S. Osalla

DevNet Associate v1.0


Module Objectives
Module Title: Software Development and Design

Module Objective: Use software development and design best practices.

Topic Title Topic Objective

Software Development Compare software development methodologies.

Software Design Patterns Describe the benefits of various software design patterns.

Version Control Systems Implement software version control using GIT.

Coding Basics Explain coding best practices.

Code Review and Testing Use Python Unit Test to evaluate code.

Understanding Data Formats Use Python to parse different messaging and data formats.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 2
3.1 Software Development

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 3
Software Development and Design
Introduction
• The software development process is also known as the software development life cycle
(SDLC).

• SDLC is more than just coding and also includes gathering requirements, creating a proof of
concept, testing, and fixing bugs.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 4
Software Development and Design
Software Development Life Cycle (SDLC)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 5
Software Development and Design
Requirements and Analysis Phase
▪ The requirements and analysis phase involves exploring the stakeholders' current situation, needs and
constraints, present infrastructure, and so on, and determining the problem to be solved by the software.
▪ After gathering the requirements, the team analyzes the results to determine the following:

• Is it possible to develop the software according to these requirements, and can it be done on-budget?
• Are there any risks to the development schedule, and if so, what are they?
• How will the software be tested?
• When and how will the software be delivered?
▪ At the conclusion of this phase, the classic waterfall method suggests creating a Software Requirement
Specification (SRS) document, which states the software requirements and scope, and confirms this
meticulously with stakeholders.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 6
Software Development and Design
Design and Implementation Phases
Design Implementation
• During the Design phase, the software • The implementation phase is also
architects and developers design the called the coding or development
software based on the provided SRS. phase.
• At the end of the phase, the team • As all the components and modules
creates High-Level Design (HLD) and are built during this phase, it is the
Low-Level Design (LLD) documents. longest phase of the life cycle.
• At the end of the phase, the functional
code that implements all customer's
requirements is ready to be tested.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 7
Software Development and Design
Testing, Deployment, and Maintenance Phases
Testing Deployment Maintenance
• In this phase, code is installed • During this phase, the • During the maintenance phase,
in the test environment software is installed into the the team:
• Functional testing, integration production environment. • Provides support to
testing, performance testing • At the end of the phase, the customers
and security testing is product manager releases • Fixes bugs found in
performed. the final piece of software to production
• Testing continues until all the end users. • Works on software
codes are bug free and pass improvements
all the tests. At the end of this • Gathers new requests from
phase, a high quality, bug-free, the customer
working piece of software is • At the end, the team works on
ready for production.
the next iteration and version
of the software.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 8
Software Development and Design
Software Development Methodologies
• A software development methodology is also known as Software Development Life Cycle
model.
• The three most popular methodologies are:
• Waterfall
• Agile
• Lean
• The type of methodology to be used depends on the:
• Type of the project
• Length of the project
• Size of the team.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 9
Software Development and Design
Waterfall Software Development
• The original waterfall model was created by Winston W. Royce.
• His original model consisted of seven phases:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 10
Software Development and Design
Agile Software Development
• Agile method is flexible and customer-focused.
• A group of 17 software developers came up with the Manifesto for Agile Software Development, also known
as the Agile Manifesto, in 2001. According to the Agile Manifesto
• The Agile manifesto lists 12 different principles:

Agile Manifesto Principles


Customer focus Collaboration Working software Simplicity
Embrace change and adapt Motivated teams Work at a sustainable Self-organizing teams
pace
Frequent delivery of working software Face-to-face Agile environment Continuous
conversations Improvement

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 11
Software Development and Design
Agile Methods
• The popular Agile methods are:

• Agile Scrum
• Lean
• Extreme Programming (XP)
• Feature-Driven Development (FDD)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 12
Software Development and Design
Agile Methods (Contd.)
• Sprints
• Backlog
• User stories
• The suggested template for a user story is:
As a <user|role>, I would like to <action>, so that <value|benefit>

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 13
Software Development and Design
Agile Methods (Contd.)
Scrum Teams

• Scrum teams are cross-functional, collaborative, self-managed and self-empowered.


• The scrum teams should not be larger than 10 individuals.
• The scrum master should have a daily stand-up meeting with the team at a fixed time
everyday for not more than 15 minutes.
• The goal is to go over important tasks that have been finished, are in progress, or are about
to be started.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 14
Software Development and Design
Lean Software Development
• Lean software development is based on Lean Manufacturing principles, which are focused
on minimizing waste and maximizing value to the customer.
• The seven principles of lean, given in the book “Lean Software Development: An Agile Toolkit,
” are as follows:
• Eliminate waste
• Amplify learning
• Decide as late as possible
• Deliver as fast as possible
• Empower the team
• Build integrity in
• Optimize the whole

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 15
Software Development and Design
Lean Software Development (Contd.)
Eliminate waste
• It is the most fundamental lean principle.
• There are seven wastes of software development:
• Partially done work
• Extra processes
• Extra features
• Task switching
• Waiting
• Motion
• Defects

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 16
Software Development and Design
Lean Software Development (Contd.)
▪ Amplify Learning with Short Sprints
▪ Decide as Late as Possible
▪ Deliver as Fast as Possible

Deliver As Fast as Possible


Enables customers to provide feedback Doesn't allow customers to change their mind
Enables developers to amplify learning Makes everyone take decisions faster
Provides customers the required features Produces less waste

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 17
Software Development and Design
Lean Software Development (Contd.)
▪ Empower the Team
▪ Build Integrity In
▪ Optimize the Whole

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 18
3.2 Software Design Patterns

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 19
Software Design Patterns
Introduction
• Software design patterns are best practice solutions for solving common problems in software
development.

• Design patterns are language-independent.

• In 1994, Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides (known as the Gang of Four
(GoF)) published a book called Design Patterns - Elements of Reusable Object-Oriented Software.
Patterns identified are:

• Program to an interface, not an implementation.


• Favor object composition over class inheritance.
• Software design patterns have already been proven to be successful, so using them can speed up
development.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 20
Software Design Patterns
The Original Design Patterns
• The Gang of Four divided patterns into three main categories:

• Creational
• Structural
• Behavioral
• They listed 23 design patterns.

• Two of the most commonly used design patterns are:

• The Observer design pattern (a Behavioral design pattern)


• The Model-View-Controller (MVC)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 21
Software Design Patterns
Observer Design Pattern
• The observer design pattern is a subscription
notification design that lets objects receive
events when there are changes to an object
they are observing.
• To implement this subscription mechanism:

• The benefit of the observer design pattern is


that observers can get real time data from the
subject when a change occurs.

• Subscription mechanisms always provide


better performance than other options,
such as polling.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 22
Software Design Patterns
Model-View-Controller (MVC)
• The Model-View-Controller (MVC) design pattern aims to
simplify development of applications that depend on graphic
user interfaces.

• MVC abstracts code and responsibility into three different


components:
• Model
• View
• Controller
• The benefit of MVC is that each component can be built in
parallel.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 23
3.3 Version Control Systems

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 24
Version Control Systems
Types of Version Control Systems
• Version control, also called version control systems, revision control or source control, is a
way to manage changes to a set of files in order to keep a history of those changes.
• Benefits of version control are:
• Enables collaboration
• Accountability and visibility
• Work in isolation
• Safety
• Work anywhere
• There are three types of version control systems:
• Local
• Centralized
• Distributed

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 25
Version Control Systems
Types of Version Control Systems (Contd.)
Local Version Control System (LVCS)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 26
Version Control Systems
Types of Version Control Systems (Contd.)
Centralized Version Control System (CVCS)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 27
Version Control Systems
Types of Version Control Systems (Contd.)
Distributed Version Control System (DVCS)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 28
Version Control Systems
Git

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 29
Version Control Systems
Git (Contd.)
• Git is organized by 3s- three
stages and three states.

• The three stages are:


• Repository (the .git
directory)
• Working directory
• Staging area

• The three states are:


• Committed
• Modified
• Staged
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 30
Version Control Systems
Local vs. Remote Repositories
• Git has two types of repositories: local and remote.
• A local repository is stored on the file system of a client machine, which is the same one on
which the git commands are being executed.
• A remote repository is stored somewhere other than the client machine, usually a server or
repository hosting service.
• A remote repository with Git continues to be a DVCS because the remote repository will contain
the full repository, which includes the code and the file history.
• When a client machine clones the repository, it gets the full repository without requiring to lock it,
as in a CVCS.
• After the local repository is cloned from the remote repository or the remote repository is created
from the local repository, the two repositories are independent of each other until the content
changes are applied to the other branch through a manual Git command execution.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 31
Version Control Systems
What is Branching?
• Branching enables users to work on code independently without affecting the main code in the repository.
When a repository is created, the code is automatically put on a branch called Master.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 32
Version Control Systems
GitHub and Other Providers
• Git and GitHub are not the same.
• In addition to providing the distributed version control and source code management
functionality of Git, GitHub provides additional features such as:
• code review
• documentation
• project management
• bug tracking
• feature requests

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 33
Version Control Systems
Git Commands
Setting up Git

• To configure Git, use the --global option to set the initial


global settings.
Command: git config --global key value
Create a New Git Repository
• Git provides a git init command to create an empty Git
repository, or make an existing folder a Git repository.
• When a new or existing project becomes a Git
repository, a hidden .git directory is created in
that project folder.
• The .git directory is the repository that holds the
metadata such as the compressed files, the commit
history, and the staging area. In addition, Git also
creates the master branch.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 34
Version Control Systems
Git Commands (Contd.)
Command: git init
• To make a new or existing project a Git repository, use the following command:
$ git init <project directory>

Get an Existing Git Repository

• Command: git clone <repository> [target


directory]

where <repository> is the location of the


repository to clone.

• Git supports four major transport protocols


for accessing the <repository>: Local,
Secure Shell (SSH), Git, and HTTP.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 35
Version Control Systems
Git Commands (Contd.)
View the Modified Files in the Working Directory

• Git provides a git status command to get a list of files that have differences between the
working directory and the parent branch.
• Command: git status

Compare Changes Between Files


• Git provides a git diff command that is essentially a generic file comparison tool.
• Command: git diff
• When using the git diff command, the file does not need to be a Git tracked file.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 36
Version Control Systems
Adding and Removing Files
Adding Files to the Staging Area
• Command: git add
• To add a single file to the staging area:
$ git add <file path>

• To add multiple files to the staging area, where the <file


path> is the absolute or relative path of the file to be
added to the staging area.
$ git add <file path 1> ... <file path n>

• To add all the changed files to the staging area: $ git


add.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 37
Version Control Systems
Adding and Removing Files (Contd.)
Removing Files from the Git Repository
• There are two ways to remove files from the Git
repository.
• Option 1: git rm command is used to remove files
from the Git repository and add to the staging area.
• Command: git rm
• To remove the specified file(s) from the working
directory and add the change to the staging area,
use the following command:
$ git rm <file path 1> ... <file path n>

where <file path> is the absolute or relative path


of the file to be deleted from the Git repository.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 38
Version Control Systems
Adding and Removing Files (Contd.)
• To add the specified file(s) to be removed from the staging area without removing the file(s)
itself from the working directory, use the following command:
$ git rm --cached <file path 1> ... <file path n>

The git rm command will not work if the file is already in the staging area with changes.

• Option 2: This option is a two-step process. First use the regular filesystem command to
remove the file(s) and then add the file to the stage using the Git command.
$ rm <file path 1> ... <file path n>
$ git add <file path 1> ... <file path n>

This two step process is equivalent to using the git rm <file path 1> ... <file path
n> command. Using this option does not allow the file to be preserved in the working
directory.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 39
Version Control Systems
Updating Repositories
Updating the Local Repository with the
Changes in the Staging Area
Command: git commit

• To commit the changes from the staging


area, use the following command:
$ git commit
• To commit the changes from the staging
area with a
message, use the following command:
$ git commit -m "<message>"

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 40
Version Control Systems
Updating Repositories (Contd.)
Updating the Remote Repository

Command: git push

• To update the contents from the local


repository to
a particular branch in the remote repository,
use the following command:
$ git push origin <branch name>

• To update the contents from the local


repository to the master branch of the remote
repository, use the command: $ git push origin
master

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 41
Version Control Systems
Updating Repositories (Contd.)
Updating Your Local Copy of the Repository
Command: git pull
• When executing the command, the following steps occur:
• The local repository ( .git directory) is updated with the latest commit, file history, and so
on from the remote Git repository.
• The working directory and branch is updated with the latest content from step 1.
• A single commit is created on the local branch with the changes from step 1.
• The working directory is updated with the latest content.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 42
Version Control Systems
Updating Repositories (Contd.)
• To update the local copy of the Git
repository from the parent branch,
use the following command:
$ git pull
Or
$ git pull origin

• To update the local copy of the Git


repository from a specific branch,
use the following command:
$ git pull origin <branch>

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 43
Version Control Systems
Branching Features
Creating and Deleting a Branch
Option 1: git branch command to list, create, or delete a branch.

$ git branch <parent branch> <branch name>


Option 2: git checkout command to switch branches by updating the working directory with the contents of
the branch.
$ git checkout -b <parent branch> <branch name>
Deleting a Branch
• To delete a branch, use the following command:
$ git branch -d <branch name>
Get a List of all Branches
• To get a list of all the local branches, use the following command:
$ git branch Or $ git branch --list

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 44
Version Control Systems
Branching Features (Contd.)
Merging Branches
• Branches diverge from one
another when they are modified
after they are created.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 45
Version Control Systems
Branching Features (Contd.)
Fast-Forward Merge

Merge Conflicts

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 46
Version Control Systems
Branching Features (Contd.)
Performing the Merge
• Git provides a git merge command to join two or more branches together.
• Command: git merge
• To merge a branch into the client's current branch/repository, use the below command:
$ git merge <branch name>

• To merge a branch into a branch that is not the client's current branch/repository, use the
following command:
$ git checkout <target branch name>
$ git merge <source branch name>

• To merge more than one branch into the client's current branch/repository, use the below
command:
$ git merge <branch name 1>...<branch name n>
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 47
Version Control Systems
.diff Files
What is a .diff file?
• A .diff file is used to show how two different versions of a file have changed.
• By using specific symbols, this file can be read by other systems to interpret how files can be
updated.
• The symbols and meanings in a unified diff file are:
Symbol Meaning
+ Indicates that the line has been added.
- Indicates that the line has been removed.
/dev/null Shows that a file has been added or removed.
or "blank" Gives context lines around changed lines.
@@ A visual indicator that the next block of information is starting. Within the changes for one
file, there may be multiple.
index Displays the commits compared.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 48
3.4 Coding Basics

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 49
Coding Basics
Methods, Functions, Modules, and Classes
• As the project size and complexity grows, and other developers (and stakeholders) get
involved, disciplined methods and best practices are needed to help developers write better
code and collaborate around it more easily.
• What is a clean code?

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 50
Coding Basics
Methods and Functions
• Methods and Functions are blocks of code that perform tasks when executed.
• Standard best-practices for determining whether a piece of code should be encapsulated (in a
method or function):
• Methods and Functions can be written once and executed as many times as required.
• If used correctly, methods and functions will simplify the code, and reduce the potential for bugs.
• Syntax of a Function in Python:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 51
Coding Basics
Methods and Functions (Contd.)
Arguments and Parameters
• Arguments and parameters add flexibility to methods and functions.
• Syntax of a function using arguments and parameters in Python:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 52
Coding Basics
Methods and Functions (Contd.)
Return Statements
• Syntax of a function with a return statement in Python:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 53
Coding Basics
Methods and Functions (Contd.)
Methods vs. Functions

Methods Functions
Methods are code blocks associated with an Functions are standalone code blocks.
object, typically for object-oriented
programming.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 54
Coding Basics
Modules
• Developers typically use modules to divide a large project into smaller parts so that the code can be read
and understood easily.
• Below is a module with a set of functions saved in a script called circleClass.py.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 55
Coding Basics
Classes
• In most Object-Orient Programming (OOP) languages, and in Python, classes are a means of bundling
data and functionality. Each class declaration defines a new object type.
• Classes may have class variables and object variables.

Note: Unlike other OOP languages, in Python, there is no means of creating 'private' class variables or
internal methods. However, by convention, methods and variables with a single preceding underscore ( _ )
are considered private and not to be used or referenced outside the class.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 56
3.5 Code Review and Testing

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 57
Code Review and Testing
What is a Code Review and Why Should You Do This?
• A code review is when developers look over the codebase, a subset of code, or specific code changes and
provide feedback. These developers are often called reviewers.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 58
Code Review and Testing
Types of Code Reviews
The most common types of code review processes
include:
• Formal code review
• Change-based code review
• Over-the-shoulder code review

• Email pass-around

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 59
Code Review and Testing
Testing
• Software testing is classically subdivided into two general categories:
• Functional testing
• Non-functional testing
• Developers capture design requirements as tests and then write software to pass those
tests. This is called Test-Driven Development (TDD).

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 60
Code Review and Testing
Unit Testing
• Detailed functional testing of small pieces of code (lines, blocks, functions, classes, and other components in
isolation) is called Unit Testing.
• These test frameworks are software that allows you to make assertions about testable conditions and
determine if these assertions are valid at a point in execution.
• Examples of test frameworks for Python:

PyTest unittest

• PyTest is handy. It automatically executes any • The unittest framework demands a different
scripts that start with test_ or end with _test.py syntax than PyTest.
and within those scripts, automatically executes • For unittest, you need to subclass the built-in
any functions beginning with 'test_' or 'tests_'. TestCase class and test by overriding its built-in
• We can unit test a piece of code by copying it into a methods or adding new methods whose names
file, importing pytest, adding appropriately-named begin with 'test_'.
testing functions, saving the file under a filename
that also begins with 'tests_,' and running it with
PyTest.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 61
Code Review and Testing
Integration Testing
• Integration testing ensures
that all the individual units fit
together properly to make a
complete application.

Note: You can run this script


on your VM using pytest.
However, understanding the
output and fixing any errors
is beyond the scope of this
course.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 62
Code Review and Testing
Test-Driven Development (TDD)
• The basic pattern of TDD is a five-step, repeating process:
• Create a new test.
• Run tests to see if any fail for unexpected reasons.
• Write application code to pass the new test.
• Run tests to see if any fail.
• Refactor and improve application code.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 63
3.6 Understanding Data Formats

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 64
Understanding Data Formats
Data Formats
• Rest APIs let you exchange information with remote services and equipment.
• The three most popular standard formats for exchanging information with remote APIs are
XML, JSON, and YAML.
• Parsing XML, JSON, or YAML is a frequent requirement of interacting with APIs. An oft-
encountered pattern in REST API implementations is as follows:
• Authenticate, usually by POSTing a user/password combination and retrieving an
expiring token for use in authenticating subsequent requests.
• Execute a GET request to a given endpoint (authenticating as required) to retrieve the
state of a resource, requesting XML, JSON, or YAML as the output format.
• Modify the returned XML, JSON, or YAML.
• Execute a POST (or PUT) to the same endpoint (again, authenticating as required) to
change the state of the resource, again requesting XML, JSON, or YAML as the output
format and interpreting it as needed to determine if the operation was successful.
© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 65
Understanding Data Formats
XML
• Extensible Markup Language (XML) is a generic methodology for wrapping textual data in
symmetrical tags to indicate semantics.
• It is a derivative of Structured, Generalized Markup Language (SGML), and also the parent of
HyperText Markup Language (HTML). XML filenames typically end in ".xml".
An Example XML Document

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 66
Understanding Data Formats
XML (Contd.)
• XML Document Body
• User-Defined Tag Names
• Special Character Encoding
• XML Prologue
• Comments in XML
• XML Attributes

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 67
Understanding Data Formats
XML (Contd.)
• XML Namespaces:

• Namespaces are defined by the IETF and other internet authorities, organizations, and
other entities, and their schemas are typically hosted as public documents on the web.
• Namespaces are identified by Uniform Resource Names (URIs) to make persistent
documents reachable without the seeker needing to be concerned about their location.
• The code example below shows the use of a namespace, defined as the value of an
xmlns attribute, to assert that the content of an XML remote procedure call should be
interpreted according to the legacy NETCONF 1.0 standard.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 68
Understanding Data Formats
XML (Contd.)
• Interpreting XML
• In the XML Namespaces example, the structure is represented as a list or one-dimensional
array (called 'instances') of objects (each identified as an 'instance' by bracketing tags).
Each instance object contains two key-value pairs denoting a unique instance ID and VM
server type.

• A semantically-equivalent Python data structure might be declared as shown below:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 69
Understanding Data Formats
JSON
• Below is a sample JSON file, containing two values that are text strings, one is a boolean
value, and two are arrays:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 70
Understanding Data Formats
JSON (Contd.)
• JSON Basic Data Types
• JSON Objects
• JSON Maps and Lists
• No Comments in JSON
• Whitespace Insignificant.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 71
Understanding Data Formats
YAML
• YAML Ain't Markup Language (YAML) is a superset of JSON designed for even easier human
readability.
• As a superset of JSON, YAML parsers can generally parse JSON documents (but not vice-
versa).
• Hence, YAML is better than JSON at certain tasks, including the ability to embed JSON
directly (including quotes) in YAML files.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 72
Understanding Data Formats
YAML (Contd.)
• YAML File Structure
• YAML Data Types
• Basic Objects
• YAML Indentation and File Structure
• Maps and Lists
• Maps are generally expressed over multiple lines, beginning with a label key and a colon,
followed by members, indented on subsequent lines:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 73
Understanding Data Formats
YAML (Contd.)
• Lists (arrays) are represented with optionally-indented members preceded by a single
dash and space:

• Maps and lists can also be represented in a so-called "flow syntax," which looks very
much like JavaScript or Python:

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 74
Understanding Data Formats
YAML (Contd.)
• Long Strings: They are represented using a 'folding' syntax, where linebreaks are presumed
to be replaced by spaces when the file is parsed/consumed, or in a non-folding syntax.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 75
Understanding Data Formats
YAML (Contd.)
• Comments: Comments in YAML can be inserted anywhere except in a long string literal, and
are preceded by the hash sign and a space.

• More YAML Features

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 76
Understanding Data Formats
Parsing and Serializing
• Parsing means analyzing a message, breaking it into its component parts, and
understanding their purposes in context.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 77
3.7 Software Development and
Design Summary

© 2016 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 78
Software Development and Design Summary
What Did I Learn in this Module?
• Six phases of SDLC: Requirements & Analysis, Design, Implementation, Testing, Deployment and
Maintenance.
• Three popular software development models are Waterfall, Agile, and Lean.
• The MVC design pattern simplifies development of applications that depend on graphic user interfaces.
• Version control maintains history of changes to a file. Types of version control systems: Local, Centralized,
and Distributed.
• Git is an open source implementation of a distributed version control system and has two types of
repositories: local and remote.
• Clean code is the result of developers trying to make their code easy to read and understand for other
developers.
• Code review involves reviewing a codebase, a subset of code, or specific code change to provide feedback.
• Three most popular standard formats for exchanging information with remote APIs: XML, JSON and YAML.
• Parsing requires analyzing a message, breaking it into its component parts, and understanding their
purposes in context. Serializing is roughly the opposite.

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 79
Software Development and Design
New Terms and Commands
• Software Development Life • Centralized Version Control • Test-Driven Development (TDD)
Cycle (SDLC) Systems (CVCS) • Unit Testing
• User experience (UX) • Distributed Version Control • Software Development Kits
• Software Requirement System (DVCS) (SDKs)
Specification (SRS) • Git • XML
• Agile Scrum • Branching • JSON
• Lean • GitHub • YAML
• Extreme Programming (XP) • Arguments • Application Programming
• Feature-Driven Development • Parameters Interfaces (APIs)
(FDD) • Object-Orient Programming • REpresentational State
• Sprints (OOP) Transfer (REST)
• Backlog • Formal Code Review • Long Strings
• User stories • Change-Based Code Review • Parsing
• Scrum Teams • Over-the-Shoulder Code Review • Serializing
• Model-View-Controller (MVC)

© 2020 Cisco and/or its affiliates. All rights reserved. Cisco Confidential 80

You might also like