Please stay healthy and well!

Integrated Sciences Complex

Remote Lectures

All Meetings

Schedule here:

Revised Project Proposals

Daniel's Feedback

Loraine's Feedback

Schedule here:

Please schedule a group meeting!

Fritz Lekschas

JavaScript Web Application Frameworks - What? When? Which? How?

Wednesday 4/8 11:00a

Host System

Container

VM

VM

Container kernel needs to match host system.

WSL 2 uses the latest and greatest in virtualization technology to run its Linux kernel inside of a lightweight utility virtual machine (VM).

Native Docker Desktop should be better than using WSL.

So why is Docker cool?

much more lightweight than VirtualMachines

runs on cloud services

it can scale!

Docker Swarm

Kubernetes

FROM ubuntu:18.04

MAINTAINER Daniel Haehn version: 0.1


ADD converter.cc converter.cc

RUN apt-get update
RUN apt-get install -y g++
RUN g++ -o converter converter.cc

ENTRYPOINT ["./converter"]

Dockerfile

$ docker pull haehn/cs410converter
$ docker run -it haehn/cs410converter
$ pip install trako
$ python setup.py sdist
$ twine upload dist/trako-0.3.1*

Testing

System Tests

Automatic Testing!

from selenium import webdriver

def test_google():
  
  driver = webdriver.Chrome()
  driver.maximize_window()
  driver.get("https://google.com")

  searchtext = driver.find_element_by_id("searchtext")
  searchtext.send_keys("CS410")
  
  submitbutton = driver.find_element_by_id("submit")
  submitbutton.click()
  
  driver.save_screenshot("/tmp/shot.png")
  

UI Testing

Control a web-browser

const browser = await puppeteer.launch();

const page = await browser.newPage();

await page.setViewport({
    width: 1440,
    height: 900
});
  
await page.goto('https://nsa.gov');

await page.waitFor('input[name=desktopSearch]');
await page.click('input[name=desktopSearch]');

await page.keyboard.type('Area 51');
await page.keyboard.press('Enter');

await page.waitFor(1000);
await page.screenshot({path: 'screenshot.png'});
await browser.close();

Functions, Classes

Arrays, Vectors

Templates

GIBBS Cluster

Cython

Run our C++ code in Python using Cython

and compare timing against NumPy

Analyze a bunch of numbers and calculate min, max, mean, stddev.

Templates

Generic Programming

Type-Independent

"Blueprint"

Advanced!

int get_min(std::vector<int> v) {
    
    int minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}
void test_get_min() {

  std::vector<int> somevalues;

  somevalues.push_back(1);
  somevalues.push_back(2);
  somevalues.push_back(3);
  somevalues.push_back(-241);
  
  assert(get_min(somevalues)==-241);
  std::cout << "Test OK!" << std::endl;
    
}
float get_min_float(std::vector<float> v) {
    
    float minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}
void test_get_min_float() {

  std::vector<float> somevalues;

  somevalues.push_back(1.1);
  somevalues.push_back(2.31);
  somevalues.push_back(3.4);
  somevalues.push_back(-241.44);
  
  assert(get_min_float(somevalues)==-241.44);
  std::cout << "Test OK!" << std::endl;
    
}

get_min for integers

get_min for floats

void test_get_min_float() {

  std::vector<float> somevalues;

  somevalues.push_back(1.1);
  somevalues.push_back(2.31);
  somevalues.push_back(3.4);
  somevalues.push_back(-241.44);
  
  assert(get_min_float(somevalues)==-241.44);
  std::cout << "Test OK!" << std::endl;
    
}

Never got executed!

void test_get_min_float() {

  std::vector<float> somevalues;

  somevalues.push_back(1.1);
  somevalues.push_back(2.31);
  somevalues.push_back(3.4);
  somevalues.push_back(-241.44);
  
  float diff = std::abs( -241.44 ) - std::abs( get_min_float(somevalues) );
  
  assert(diff < 0.0005);
  std::cout << "Test OK!" << std::endl;
    
}

Check if we have a very small difference between two floats..

We can not just compare floats..

float onevalue = 0.33333333333333;

float secondvalue = 1/3;

if (onevalue == secondvalue) {

	// cancel life-support
	// ...
}

Developer is in charge of precision..

int get_min(std::vector<int> v) {
    
    int minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}
void test_get_min() {

  std::vector<int> somevalues;

  somevalues.push_back(1);
  somevalues.push_back(2);
  somevalues.push_back(3);
  somevalues.push_back(-241);
  
  assert(get_min(somevalues)==-241);
  std::cout << "Test OK!" << std::endl;
    
}
float get_min_float(std::vector<float> v) {
    
    float minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}
void test_get_min_float() {

  std::vector<float> somevalues;

  somevalues.push_back(1.1);
  somevalues.push_back(2.31);
  somevalues.push_back(3.4);
  somevalues.push_back(-241.44);
  
  float diff = std::abs( -241.44 ) - std::abs( get_min_float(somevalues) );
  
  assert(diff < 0.0005);
  std::cout << "Test OK!" << std::endl;
    
}

get_min for integers

get_min for floats

template <typename T>

T get_min(std::vector<T> v) {
    
    T minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}
void test_get_min() {

  std::vector<int> somevalues;

  somevalues.push_back(1);
  somevalues.push_back(2);
  somevalues.push_back(3);
  somevalues.push_back(-241);
  
  assert(get_min(somevalues)==-241);
  std::cout << "Test OK!" << std::endl;
    
}
void test_get_min_float() {

  std::vector<float> somevalues;

  somevalues.push_back(1.1);
  somevalues.push_back(2.31);
  somevalues.push_back(3.4);
  somevalues.push_back(-241.44);
  
  float diff = std::abs( -241.44 ) - std::abs( get_min(somevalues) );
  
  assert(diff < 0.0005);
  std::cout << "Test OK!" << std::endl;
    
}

get_min for ints, floats...

int get_min(std::vector<int> v) {
    
    int minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}
template <typename T>
class Stats {
    
    public:
        static T get_min(std::vector<T> v);
        static T get_max(std::vector<T> v);
        static float get_mean(std::vector<T> v);
        
};

template <typename T>
T Stats<T>::get_min(std::vector<T> v) {
    
    T minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::min(minvalue, v[i]);
        
    }
    
    return minvalue;
}

template <typename T>
T Stats<T>::get_max(std::vector<T> v) {
    
    T minvalue = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        minvalue = std::max(minvalue, v[i]);
        
    }
    
    return minvalue;
}
template <typename T>
float Stats<T>::get_mean(std::vector<T> v) {
    
    float sum = v[0];
    
    for(int i=1; i<v.size(); i++) {
        
        sum += v[i];
        
    }
    
    sum /= v.size();
    
    return sum;
}

Templated Classes!

More Friday....

Software Development Models

Predictive

Adaptive

Project has been done before

Clear process is in place

Not much room for change

Project is a new idea

No clear process in place

Likely change over time

Software Engineering 101

Requirements

Design

Implementation

Verification

Maintenance

Testing and Deployment

This model can be used for all Engineering problems!

What?

How?

Build

More Testing / Evaluate

Bugs / New Features

The Waterfall Model

Requires extreme planning

Takes long to get product

Not adaptive to new technology

Predictive!

V-Model

Verify / Validate on the go

Every software design process is unique is some ways or another!

As rigid as possible as flexible as needed

Requirements

Design

Implementation

Verification

Maintenance

Time

Start different phases at the same time

Sashimi Model

Error can require restart

Incremental Model

Iterative Model

Both are Adaptive!

Spiral Model

Let's code!

CS410 Lecture 24

By Daniel Haehn

CS410 Lecture 24

Slides for CS410 Software Engineering at UMass Boston. See https://cs410.net!

  • 225

More from Daniel Haehn