• Non ci sono risultati.

Advanced Programming Advanced Programming

N/A
N/A
Protected

Academic year: 2021

Condividi "Advanced Programming Advanced Programming"

Copied!
52
0
0

Testo completo

(1)

Advanced Programming Advanced Programming

Giuseppe Attardi Giuseppe Attardi

Dipartimento di Informatica Dipartimento di Informatica

Università di Pisa Università di Pisa

Università di Pisa

(2)

Language is an instrument of human reason, not merely a medium for the expression of thought.

G. Boole, An Investigation of the Laws of Thought, 1854

(3)

Instructor and Assistant Instructor and Assistant

Giuseppe Attardi Office: 292

Mail: attardi@di.unipi.it Giuseppe Attardi

Office: 292

Mail: attardi@di.unipi.it

TBDTBD

(4)

Recurring questions Recurring questions

To teach or not to teach To teach or not to teach programming?

programming?

How to teach programming?How to teach programming?

Programming is not just Programming is not just programming languages programming languages

(5)

Software Everywhere Software Everywhere

Software can be the key to delivering Software can be the key to delivering new product offerings and driving

new product offerings and driving continuous product innovation

continuous product innovation

Software role:Software role:

– Product innovation – Process flexibility

– Process enforcement for quality assurance and matching demands

(6)

Software Innovation

Software Innovation

(7)

Software as Competitive Software as Competitive

Advantage Advantage

Most Admired Companies Making IT A Competitive Advantage (Forbes)

Accenture

Amazon

Apple

Cleveland Clinic

General Electric

Goldman Sachs

Google

Hospital Corporation of America

IBM

Intermountain Healthcare

JP Morgan Chase

Kaiser Permanente

Mayo Clinic

Microsoft

Nestle

Procter & Gamble

Progressive Insurance

Schlumberger

Target

Toyota

Wells Fargo

(8)

Introduction Introduction

Programming in the 21 centuryProgramming in the 21 century

Software as complex as everSoftware as complex as ever

Command line interface not enoughCommand line interface not enough

Data comes from multiple sources: Data comes from multiple sources:

structured (DB) and unstructured structured (DB) and unstructured

Single computer not enoughSingle computer not enough

Software development is a group Software development is a group activity

activity

Deployment on Web or mobile devicesDeployment on Web or mobile devices

(9)

Requirements Requirements

Cannot start from scratchCannot start from scratch

Reusable components are neededReusable components are needed

OS + libraries not enoughOS + libraries not enough

(10)

Elements of a Solution Elements of a Solution

Software FrameworkSoftware Framework

Component ModelComponent Model

Execution EnvironmentExecution Environment

(11)

More Complex Software More Complex Software

Object-Oriented Programming allows Object-Oriented Programming allows ever larger applications to be built

ever larger applications to be built

Require increased high-level Require increased high-level

application and system oversight application and system oversight

Multi-tier applications development Multi-tier applications development increases the choices on how to

increases the choices on how to build applications

build applications

A new A new Software Architect Software Architect Role is Role is needed

needed

(12)

Software Architect Duties Software Architect Duties

Creating, defining or choosing an Creating, defining or choosing an application framework

application framework

Creating the component designCreating the component design

Structure a complex application into Structure a complex application into pieces

pieces

Understand the interactions and Understand the interactions and dependencies among components dependencies among components

Select the platform based on Select the platform based on cost/performance criteria

cost/performance criteria

Organize and supervise the Organize and supervise the

construction siteconstruction site

(13)

Application Framework Application Framework

A software framework used to A software framework used to implement the

implement the standardstandard structure of structure of an application for a

an application for a specificspecific development environment development environment

(14)

Software Framework Software Framework

A collection of A collection of common codecommon code providing

providing generic functionalitygeneric functionality that that can be selectively overridden or

can be selectively overridden or specialized by user code

specialized by user code providing providing specific functionality

specific functionality

Frameworks, like software libraries, Frameworks, like software libraries, provide

provide reusable abstractions reusable abstractions of of code wrapped in a well-defined API code wrapped in a well-defined API

(15)

Framework Features Framework Features

Inversion of controlInversion of control

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

caller, but by the framework – Hollywood Principle:

Don’t call us, we’ll call you

Default behaviorDefault behavior

Extensibility: usually by selective Extensibility: usually by selective overriding

overriding

Non-modifiable framework code Non-modifiable framework code

(16)

OO Software Framework OO Software Framework

Object-oriented programming Object-oriented programming frameworks consists in a

frameworks consists in a set of set of abstract classes

abstract classes

An application can be built simply An application can be built simply inheriting from pre-existing classes inheriting from pre-existing classes

in the framework in the framework

Instantiation of a framework consists Instantiation of a framework consists of composing and subclassing the

of composing and subclassing the existing classes

existing classes

(17)

Examples of Frameworks Examples of Frameworks

GUIGUI

– MFC – Gnome – Qt

GeneralGeneral

– Android – Spring – Cocoa

WebWeb

– ASP.Net – GWT

– Rails

ConcurrenceConcurrence

– Hadoop Map/Reduce

(18)

Class Hierarchy (NextSTEP Class Hierarchy (NextSTEP

1988)

1988)

(19)

Cocoa (2013)

Cocoa (2013)

(20)

Benefits of Frameworks Benefits of Frameworks

Drives solutionDrives solution

– Dictates how to fill-in-the-blanks

Helps solving recurring problemsHelps solving recurring problems

– Designed for reuse

– High value, since reduces cost of development

(21)

Framework Design Framework Design

Intellectual Challenging TaskIntellectual Challenging Task

Requires a deep understanding of Requires a deep understanding of the problem domain

the problem domain

Requires mastering of software Requires mastering of software patterns, OO methods and

patterns, OO methods and polymorphism

polymorphism in particular in particular

(22)

Design Pattern Design Pattern

More abstract than frameworksMore abstract than frameworks

– Frameworks can be embodied in code, but

only examples of patterns can be embodied in code

– Design patterns explain the intent, trade-offs, and consequences of a design

Smaller architectural elements than Smaller architectural elements than frameworks

frameworks

– A typical framework contains several design patterns but the reverse is never true.

Less specialized than frameworksLess specialized than frameworks

– Frameworks always have a particular application domain

– Design patterns can be used in nearly any kind of application

(23)

Examples Examples

VisitorVisitor

Publish/SubscribePublish/Subscribe

FactoryFactory

Dependency InjectionDependency Injection

Chain of ResponsibilityChain of Responsibility

ObserverObserver

IteratorIterator

DecoratorDecorator

(24)

Dependency Injection Dependency Injection

Allows avoiding hard-coded Allows avoiding hard-coded

dependencies and changing them dependencies and changing them

Allows selection among multiple Allows selection among multiple implementations of a given

implementations of a given

dependency interface at run time dependency interface at run time

Examples:Examples:

– load plugins dynamically

– replace mock objects in test

environments vs. real objects in production environments

(25)

Dependency Injection Dependency Injection

public class Client {

// Internal reference to the service used by this client private Service service;

Client() {

// Fixed implementation

service = new ServiceExample();

}

Client(Service service) {

// injection of a specific service this.service = service;

}

// Method within this client that uses the service public String greet() {

return "Hello " + service.getName();

} }

(26)

Course Objectives Course Objectives

Understand programming language Understand programming language technology:

technology:

– Execution Models – Run-time

Analyze programming metaphors:Analyze programming metaphors:

– Objects

– Components – Patterns

Learn advanced programming techniquesLearn advanced programming techniques

Understand their limits ad how to Understand their limits ad how to overcome them

overcome them

(27)

Course Objectives Course Objectives

Explain how high level programming Explain how high level programming concepts and metaphors map into concepts and metaphors map into

executable systems and which are their executable systems and which are their

costs and limitations costs and limitations

Acquaint with modern principles, Acquaint with modern principles,

techniques, and best practices of advanced techniques, and best practices of advanced

software construction software construction

Introduce techniques of programming at Introduce techniques of programming at higher abstraction levels, in particular higher abstraction levels, in particular

generative programming, component generative programming, component

programming and web computing programming and web computing

Present state-of-the-art frameworks Present state-of-the-art frameworks incorporating these techniques

incorporating these techniques

(28)

Syllabus

Syllabus

(29)

Programming Language Programming Language

Foundations Foundations

Syntax, Parsing, Abstract Syntax Syntax, Parsing, Abstract Syntax Tree, Parser Generators

Tree, Parser Generators

Names, Scope, Binding Names, Scope, Binding

Parameter Passing Parameter Passing

Static and Dynamic Allocaltion: Static and Dynamic Allocaltion:

Stack, Heap Stack, Heap

Types, Inheritance, Polymorphism, Types, Inheritance, Polymorphism, Overloading

Overloading

Delegates, Closures Delegates, Closures

Exception Handling Exception Handling

(30)

Run-time Systems Run-time Systems

Virtual Execution Environment Virtual Execution Environment

– Memory Management – Thread Management – Exception Handling – Security

– Debugging Support

– AOT and JIT Compilation – Dynamic Link/Load

– Reflection – Verification

Language InteroperabilityLanguage Interoperability

(31)

Advanced Techniques Advanced Techniques

Generic ProgrammingGeneric Programming

– C++ templates – C# Generics – Java Generics

Generative ProgrammingGenerative Programming

– Metaprogramming – Reflection

– Template

– Aspect Oriented Programming – Generators

(32)

Interoperability Interoperability

Process level: interprocess Process level: interprocess communication

communication

Language level: CORBA/IDL Language level: CORBA/IDL

Object level: DCOM Object level: DCOM

(33)

Component Based Component Based

Programming Programming

COM COM

JavaBeans JavaBeans

.NET (Assembly, Reflection, .NET (Assembly, Reflection, Interfaces, Attributes)

Interfaces, Attributes)

OSGi OSGi

(34)

Web Programming Web Programming

Web Services, SOAWeb Services, SOA

Web FrameworksWeb Frameworks

Web 2.0Web 2.0

(35)

Web Services Web Services

XML, XML-Schema XML, XML-Schema

SOAP, RPC, Rest SOAP, RPC, Rest

WSDL WSDL

UDDIUDDI

(36)

Web Frameworks and Web Frameworks and

Applications Applications

Asp.Net Asp.Net

J2EE J2EE

JQueryJQuery

AJAX: XHR, jQuery, YUI, GWTAJAX: XHR, jQuery, YUI, GWT

Node.jsNode.js

ReactReact

(37)

Service Components Service Components

Service Oriented ArchitectureService Oriented Architecture

MicroservicesMicroservices

Flow Based ProgrammingFlow Based Programming

(38)

Scaling Scaling

Map/ReduceMap/Reduce

CUDA ProgrammingCUDA Programming

(39)

Web Application Web Application

Frameworks Frameworks

ArchitecturesArchitectures

Principles:Principles:

– Inversion of control

FeaturesFeatures

– Templates

– Database access and mapping – Scaffolding

– Ajax

– Web Services

Examples:Examples:

– Symfony – Laravel

(40)

Scripting Languages Scripting Languages

PerlPerl

PythonPython

JavaScriptJavaScript

PHPPHP

RubyRuby

(41)

IEEE Spectrum Ranking 2015-2014

IEEE Spectrum Ranking 2015-2014

(42)

IEEE Spectrum Ranking 2016-2015

IEEE Spectrum Ranking 2016-2015

(43)

CodEval Chart

CodEval Chart

(44)
(45)
(46)

Top 10 Frameworks

Top 10 Frameworks

(47)

Top 10 Web Application Top 10 Web Application

Frameworks Frameworks

1.1. Ruby on RailsRuby on Rails

2.2. AngularJSAngularJS

3.3. Ember.jsEmber.js

4.4. CakePHPCakePHP

5.5. PhalconPhalcon

6.6. ZendZend

7.7. ASP.netASP.net

8.8. SymfonySymfony

9.9. ExpressExpress

10.10.CodeigniterCodeigniter

(48)

Text Books Text Books

Programming Language Programming Language

Pragmatics, third ed.. Michael L.

Pragmatics, third ed.. Michael L.

Scott, Morgan-Kaufmann, 2009.

Scott, Morgan-Kaufmann, 2009.

Software Components: Beyond Software Components: Beyond

Object-Oriented Programming. C.

Object-Oriented Programming. C.

Szyperski, D. Gruntz, S. Murer, Szyperski, D. Gruntz, S. Murer,

Addison-Wesley, 2002.

Addison-Wesley, 2002.

(49)

Additional Reading Additional Reading

Generative Programming: Methods, Generative Programming: Methods,

Tools, and Applications. K.

Tools, and Applications. K.

Czarnecki, U. Eisenecker, Czarnecki, U. Eisenecker,

Addison-Wesley, 2000.

Addison-Wesley, 2000.

Object Thinking. D. West, Microsoft Object Thinking. D. West, Microsoft

Press, 2004.

Press, 2004.

jQuery in Action. B. Bibeault, Y.

jQuery in Action. B. Bibeault, Y.

Katz, Manning, 2010.

Katz, Manning, 2010.

(50)

Assessment Assessment

Mid Term Paper: half way, one week Mid Term Paper: half way, one week homework

homework

Term Paper: at the end of the course, Term Paper: at the end of the course, 20 days homework

20 days homework

(51)

Final Term Paper Final Term Paper

Aims at exercising ability to conceive and Aims at exercising ability to conceive and

implement full solutions to a nontrivial problem implement full solutions to a nontrivial problem

Examples:Examples:

– ASP Code generator with regular expression matcher – Implement a DSL for handling persistent object

containers

– SOAP protocol and SOAP server

– Code generator for searching an object DB – Xpath and XSLT Intrepreter

– Language for generating network protocols – AJAX Framework

– Unit Testing Framework – State Charts

(52)

Home Work Home Work

Develop a simple implementation of Develop a simple implementation of primitives:

primitives:

– void* malloc(size_t size) – void free(void*)

Assume to have available a block of Assume to have available a block of memory of size MemSize starting at memory of size MemSize starting at

MemStart MemStart

Discuss the limits of the solutionDiscuss the limits of the solution

Riferimenti

Documenti correlati

father :: Person -> Maybe Person -- partial function mother :: Person -> Maybe Person -- (lookup in a DB) maternalGrandfather :: Person -> Maybe Person..

– 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:

•  Advanced features extending programming languages.. •  Component models to

(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