• Non ci sono risultati.

301AA - Advanced Programming

N/A
N/A
Protected

Academic year: 2022

Condividi "301AA - Advanced Programming"

Copied!
23
0
0

Testo completo

(1)

301AA - Advanced Programming

Lecturer: Andrea Corradini

[email protected]

h;p://pages.di.unipi.it/corradini/

Course pages:

h;p://pages.di.unipi.it/corradini/Dida@ca/AP-19/

AP-02: Mo%va%ons and Introduc%on

(2)

SoCware is Everywhere

(3)

Programming in the 21 century

•  SoCware as complex as ever

•  Command line interface not enough

•  Data comes from mulKple sources:

structured (DB) and unstructured

•  Single computer not enough

•  SoCware development is a group acKvity

•  Deployment on Web or mobile devices

(4)

Complexity Prompts for InnovaKon

•  Object-Oriented Programming allows ever larger applicaKons to be built

•  But limited support for reuse

•  OS + libraries not enough

•  Reusable components are needed

•  MulK-Ker applicaKons development increases the choices on how to build applicaKons

(5)

Key Ingredients for Complex SoCware

•  Advanced features extending programming languages

•  Component models to ensure reusability

•  Frameworks to support efficient development of (component based) applicaKons

•  Execu9on environments providing runKme support for ever dynamic soCware systems

5

(6)

The SoCware Architect

•  A new role is needed: So;ware Architect

•  to create, define or choose an applica9on framework

•  to create the component design according to a component model

•  to structure a complex applicaKon into pieces

•  to understand the interacKons and dependencies among components

•  to select the execu9on environment / pla>orm based on cost/performance criteria

•  to organize and supervise the development process

(7)

Course ObjecKves

•  Understand programming language technology:

–  ExecuKon Models –  Run-Kme systems

•  Analyze programming metaphors:

–  Objects

–  Components –  Pa;erns

•  Learn advanced programming techniques

•  Present state-of-the-art frameworks incorporaKng these techniques

•  PracKce with all these concepts through small projects

(8)

Course Syllabus

•  Programming Languages and Abstract Machines

•  Run Time Systems and the JVM

•  Component-based Programming

•  SoCware Frameworks and Inversion of Control

•  Polymorphism and Generic Programming

•  FuncKonal programming and Haskell

•  ScripKng Languages and Python

8

(9)

Programming Languages and Abstract Machines

•  Syntax, SemanKcs and PragmaKcs of PLs

•  Programming languages and Abstract Machines

•  InterpretaKon vs. CompilaKon vs. Mixed

•  Examples of Virtual Machines

•  Examples of CompilaKon Schemes

9

(10)

Run-Time Systems and the JVM

•  RTSs provide a Virtual ExecuKon Environment

interfacing a program in execuKon with the OS.

•  They support, among others:

–  Memory Management, Thread Management –  ExcepKon Handling and Security

–  AOT and JIT CompilaKon –  Dynamic Link/Load

–  Debugging Support and ReflecKon –  VerificaKon

•  A concrete example: the Java Virtual Machine

(11)

Component-based Programming

•  Component models and frameworks, an IntroducKon

•  Examples of component-based frameworks:

– JavaBeans and NetBeans – Spring and Spring Beans – COM

– CLR and .NET

– OSGi and Eclipse

– Hadoop Map/Reduce

(12)

SoCware Frameworks and Inversion of Control

•  So;ware Framework: A collecKon of common code providing generic func%onality that can be selec%vely overridden or specialized by user code providing specific func%onality

•  Applica9on Framework: A soCware

framework used to implement the standard structure of an applicaKon for a specific

development environment

(13)

Framework Features

•  Frameworks, like so(ware libraries, provide reusable abstrac4ons of code wrapped in a well-defined API

•  But: Inversion of control

–  unlike in libraries, the overall program's flow of control is not dictated by the caller, but by the framework

•  Helps solving recurring design problems

•  Drives soluKon

–  Provides a default behavior

–  Dictates how to fill-in-the-blanks

•  Non-modifiable framework code

–  Extensibility: usually by selecKve overriding

(14)

OO SoCware Framework

•  Object-oriented programming frameworks consists of a set of abstract classes

•  An applicaKon can be built simply inheriKng from pre-exisKng classes in the framework

•  InstanKaKon of a framework consists of

composing and subclassing the exisKng classes

(15)

Examples of Frameworks

•  General soCware frameworks

–  .NET – Windows plakorm. Provides language interoperability

–  Android SDK – Supports development of apps in Java (but does not use a JVM!)

–  Spring – Cross-plakorm, for Java applicaKons

–  Cocoa – Apple’s naKve OO API for macOS. Includes C standard library and the ObjecKve-C runKme.

–  Eclipse – Cross-plakorm, easily extensible IDE with plugins

(16)

Examples of Frameworks

•  Frameworks for ApplicaKon with GUI

– MFC - MicrosoC FoundaKon Class Library. C++

object-oriented library for Windows.

– Gnome – Wri;en in C; mainly for Linux

– Qt - Cross-plakorm; wri;en in C++

(17)

Examples of Frameworks

•  Web ApplicaKon Frameworks [based on Model-View-Controller design pa;ern]

– ASP.NET by MicrosoC for web sites, web applicaKons and web services

– GWT - Google Web Toolkit (GWT)

– Rails - Wri;en in Ruby - Provides default

structures for databases, web services and web pages.

(18)

Examples of Frameworks

•  Concurrency

– Hadoop Map/Reduce - soCware framework for applicaKons which process big amounts of data in- parallel on large clusters (thousands of nodes) in a fault-tolerant manner.

•  Map: Takes input data and converts it into a set of tuples (key/value pairs).

•  Reduce: Takes the output from Map and combines the data tuples into a smaller set of tuples.

(19)

Framework Design

•  Intellectual Challenging Task

•  Requires a deep understanding of the problem domain

•  Requires mastering of so;ware (design)

paQerns, OO methods and polymorphism in parKcular

(20)

Polymorphism and Generic Programming

•  A classificaKon of Polymorphism

•  Polymorphism in C++: inclusion polymorphism and templates

•  Java Generics

•  The Standard Template Library: an overview

•  Generics and inheritance: invariance, covariance and contravariance

20

(21)

FuncKonal programming and Haskell

•  IntroducKon to FuncKonal Programming

•  EvaluaKon strategies (lambda-calculus)

•  Haskell: main features

•  Type Classes and overloading

•  Monads

•  FuncKonal programming in Java

– Lambdas and Stream API

21

(22)

ScripKng Languages and Python

•  Overview of scripKng languages

•  Main features of Python

•  ImperaKve, funcKonal and OO programming in Python

•  Higher-order funcKons and Decorators

•  On the implementaKon of Python: the Global Interpreter Lock

22

(23)

Selected Advanced Concepts in Programming Language

•  Overloading and Type Classes in Haskell

•  Closures vs Delegates in CLI

•  Algebraic data types and AcKve pa;erns in F#

•  AssociaKve arrays in scripKng languages

•  Ownership and borrowing in Rust

•  Extensions in SwiC

Riferimenti

Documenti correlati

– Evolution of Miranda, name from Haskell Curry, logician (1900-82), – Haskell 1.0 in 1990, Haskell ‘98, Haskell 2010 (à Haskell 2020). • Several features in common with ML,

• Tail-recursive functions are functions in which no operations follow the recursive call(s) in the function, thus the function returns immediately after the recursive

If an inner object’s interface is exposed to clients of the outer object, then the QueryInterface of that inner object’s interface must still cover the interfaces

– A source, producing (by need) the elements of the stream – Zero or more intermediate operations, producing streams – A terminal operation, producing side-effects or non-..

– B2B Client à one or more applications that make requests to the Business Tier through SOAP / Web Services or Java RMI... Java EE:

(inserting in the middle of a vector takes linear time!) and the fact, that inserting into a vector can make all iterators to elements invalid should make you choose the STL container

“A software component is a unit of composition with contractually specified interfaces and explicit context dependencies only.. A software component

We generalize the behavior of the preorder method in the BinTree hierarchy and replace it by a method traverse that encodes the common features of all Euler tour traversals