advanced programming
Post on 30-Dec-2015
21 Views
Preview:
DESCRIPTION
TRANSCRIPT
Advanced ProgrammingAdvanced Programming
Giuseppe AttardiGiuseppe Attardi
Dipartimento di InformaticaDipartimento di Informatica
Università di PisaUniversità di Pisa
Università di Pisa
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
InstructorInstructor
Giuseppe AttardiOffice: 292Mail: attardi@di.unipi.it
Giuseppe AttardiOffice: 292Mail: attardi@di.unipi.it
IntroductionIntroduction
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 unstructuredstructured (DB) and unstructured Single computer not enoughSingle computer not enough Software development is a group Software development is a group
activityactivity Deployment on Web or mobile devicesDeployment on Web or mobile devices
RequirementsRequirements
Cannot start from scratchCannot start from scratchReusable components are neededReusable components are neededOS + libraries not enoughOS + libraries not enough
Elements of a SolutionElements of a Solution
Software FrameworkSoftware FrameworkComponent ModelComponent ModelExecution EnvironmentExecution Environment
More Complex SoftwareMore Complex Software
Object-Oriented Programming allows Object-Oriented Programming allows ever larger applications to be builtever larger applications to be built
Require increased high-level Require increased high-level application and system oversightapplication and system oversight
Multi-tier applications development Multi-tier applications development increases the choices on how to increases the choices on how to build applicationsbuild applications
A new A new Software Architect Software Architect Role is Role is neededneeded
Software Architect DutiesSoftware Architect Duties
Creating, defining or choosing an Creating, defining or choosing an application frameworkapplication framework
Creating the component designCreating the component design Structure a complex application into Structure a complex application into
piecespieces Understand the interactions and Understand the interactions and
dependencies among componentsdependencies among components Select the platform based on Select the platform based on
cost/performance criteriacost/performance criteria Organize and supervise the Organize and supervise the
““construction siteconstruction site””
Application FrameworkApplication 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 environmentdevelopment environment
Software FrameworkSoftware 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 codespecialized by user code providing providing specific functionalityspecific functionality
Frameworks, like software libraries, Frameworks, like software libraries, provide provide reusable abstractions reusable abstractions of of code wrapped in a well-defined APIcode wrapped in a well-defined API
Framework FeaturesFramework 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 behaviorExtensibility: usually by selective Extensibility: usually by selective
overridingoverridingNon-modifiable framework code Non-modifiable framework code
OO Software FrameworkOO Software Framework
Object-oriented programming Object-oriented programming frameworks consists in a frameworks consists in a set of set of abstract classesabstract 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 frameworkin the framework
Instantiation of a framework consists Instantiation of a framework consists of composing and subclassing the of composing and subclassing the existing classesexisting classes
Examples of FrameworksExamples of Frameworks
GUIGUI– MFC– Gnome– Qt
GeneralGeneral– Android– Spring– Cocoa
WebWeb– ASP.Net– GWT– Rails
ConcurrenceConcurrence– Hadoop Map/Reduce
Class Hierarchy (NextSTEP Class Hierarchy (NextSTEP 1988)1988)
Cocoa (2013)Cocoa (2013)
Benefits of FrameworksBenefits 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
Framework DesignFramework Design
Intellectual Challenging TaskIntellectual Challenging TaskRequires a deep understanding of Requires a deep understanding of
the problem domainthe problem domainRequires mastering of software Requires mastering of software
patterns, OO methods and patterns, OO methods and polymorphism in particularpolymorphism in particular
Design PatternDesign 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 frameworksSmaller architectural elements than 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
ExamplesExamples
VisitorVisitorPublish/SubscribePublish/SubscribeFactoryFactoryDependency InjectionDependency InjectionChain of ResponsibilityChain of ResponsibilityObserverObserver IteratorIteratorDecoratorDecorator
Dependency InjectionDependency Injection
Allows avoiding hard-coded Allows avoiding hard-coded dependencies and changing themdependencies and changing them
Allows selection among multiple Allows selection among multiple implementations of a given implementations of a given dependency interface at run timedependency interface at run time
Examples:Examples:– load plugins dynamically– replace mock objects in test
environments vs. real objects in production environments
Course ObjectivesCourse 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 themovercome them
Course ObjectivesCourse 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 limitationscosts 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 techniquesincorporating these techniques
SyllabusSyllabus
Programming Language Programming Language FoundationsFoundations Syntax, Parsing, Abstract Syntax Tree, Syntax, Parsing, Abstract Syntax Tree,
Parser Generators Parser Generators Names, Scope, Binding Names, Scope, Binding Parameter Passing Parameter Passing Static and Dynamic Allocaltion: Stack, Static and Dynamic Allocaltion: Stack,
Heap Heap Types, Inheritance, Polymorphism, Types, Inheritance, Polymorphism,
Overloading Overloading Delegates, Closures Delegates, Closures Exception Handling Exception Handling
Run-time SystemsRun-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
Advanced TechniquesAdvanced Techniques
Generic ProgrammingGeneric Programming– C++ templates– C# Generics– Java Generics
Generative ProgrammingGenerative Programming– Metaprogramming– Reflection– Template– Aspect Oriented Programming– Generators
InteroperabilityInteroperability
Process level: interprocess Process level: interprocess communication communication
Language level: CORBA/IDL Language level: CORBA/IDL Object level: DCOM Object level: DCOM
Component Based Component Based ProgrammingProgrammingCOM COM JavaBeans JavaBeans .NET (Assembly, Reflection, .NET (Assembly, Reflection,
Interfaces, Attributes) Interfaces, Attributes) OSGi OSGi
Web ProgrammingWeb Programming
Web Services, SOAWeb Services, SOAWeb FrameworksWeb FrameworksWeb 2.0Web 2.0
Web ServicesWeb Services
XML, XML-Schema XML, XML-Schema SOAP, RPC, Rest SOAP, RPC, Rest WSDL WSDL UDDIUDDI
Web Frameworks and Web Frameworks and ApplicationsApplicationsAsp.Net Asp.Net ADO.Net ADO.Net J2EE J2EE Java Server Faces Java Server Faces JQueryJQueryAJAX: XHR, jQuery, YUI, GWT AJAX: XHR, jQuery, YUI, GWT Mashup and Service Oriented Mashup and Service Oriented
ArchitectureArchitecture
Scripting LanguagesScripting Languages
PerlPerlPythonPythonJavaScriptJavaScriptPHP PHP
Text BooksText Books
Programming Language Programming Language Pragmatics, third ed., Michael L. Pragmatics, third ed., Michael L. Scott, Morgan-Kaufmann, 2009.Scott, Morgan-Kaufmann, 2009.
Generative Programming: Generative Programming: Methods, Tools, and Methods, Tools, and Applications, Krzysztof Applications, Krzysztof Czarnecki, Ulrich Eisenecker, Czarnecki, Ulrich Eisenecker, Addison-Wesley, 2000.Addison-Wesley, 2000.
Object Thinking , David West, Object Thinking , David West, Microsoft Press, 2004.Microsoft Press, 2004.
Text BooksText Books
jQuery in Action, B. Bibeault, jQuery in Action, B. Bibeault, Y. Katz, Manning, 2010.Y. Katz, Manning, 2010.
AssessmentAssessment
Mid Term Paper: early November, Mid Term Paper: early November, one week homework one week homework
Term Paper: at the end of the course, Term Paper: at the end of the course, 20 days homework 20 days homework
Final Term PaperFinal Term Paper
Aims at exercising ability to conceive and Aims at exercising ability to conceive and implement full solutions to a nontrivial problemimplement 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
Home WorkHome 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 MemStartMemStart
Discuss the limits of the solutionDiscuss the limits of the solution
top related