Introduzione ai puntatori e ai riferimenti in C++. Viene presentato il problema dello swap, come esempio motivante per l'introduzione della semantica di riferimento. Si procede con l'introduzione del concetto di puntatore, a cui segue una spiegazione dei basilare operatori di referenziazione e dereferenziazione. Il problema dello swap viene risolto mediante puntatori. Si procede con l'introduzione dei riferimenti, come alias di variabili esistenti. Il problema dello swap viene in ultimo risolto mediante riferimenti.
Introduzione al concetto di oggetto nel modello della memoria del C++ e ai suoi possibile tempi di vita (temporaneo, automatico, dinamico, ...). Relazione tra il tempo di vita e la visibilità (scope) di un oggetto. Gestione degli oggetti dinamici per tipi primitivi, strutture e array mediante l'utilizzo di puntatori (raw pointers).
There is ongoing confusion, and some contention, over the right way to use the QThread class. Part of the confusion comes from the uniqueness of QThread, which is significantly different from other threading classes. There are two valid patterns of QThread use, and each pattern is best suited for different use cases. Errors will arise when mixing these two patterns, or applying them inappropriately.
This presentation will look at different patterns of threading in general, and examine in detail the two usage patterns for QThread. This talk will also cover how QThread works inside, how to communicate between threads, provide examples, and point out the pitfalls to avoid.
1. Qt uses object-oriented memory management where objects are deleted automatically when their parent object is deleted.
2. Signals and slots provide a mechanism for communication between Qt objects using signals that are emitted by one object and caught by slot functions in other objects.
3. A signal mapper can be used to map multiple signals to a single slot so that different logic can be handled depending on which signal was emitted.
Qt Quick/QML brings designers and developers together to create and collaborate. QML is a collection of technologies that can build modern and fluid interfaces for applications – quickly. Join us as we explore the best of QML for mobile, embedded and desktop.
Part I will cover:
- Building Blocks of QML
- Qt Properties
- Declarative Code
Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It is open source and provides top-tier performance like C/C++ while ensuring memory safety and preventing issues like memory leaks through its ownership and borrowing model that is checked at compile time. Rust also supports features like enums, pattern matching, generics, traits, and has a built-in test system to help ensure correctness.
An introduction to pointers and references in C++ (with elements of C++11 and C++14). The presentation introduces the readers to the concepts of pointers and references through the pragmatic need of writing a swap function between integers. Generic programming notions (e.g., type constructors) are adopted when useful for the explanation.
Video of this presentation can be found here https://engineers.sg/video/security-wednesdays-8-reflections-on-trusting-trust-nus-greyhats--572
The talk I gave at Papers We Love #16 (Singapore) and NUS Greyhats about this Turing award paper "Reflections on Trusting Trust" by Ken Thompson. I also demoed a rudimentary practical implementation of the ideas in the paper.
My talk also touched briefly on 2 extra papers "Fully Countering Trust through Diverse Double Compiling" by David Wheeler and "Critique of DDC" by Paul Jakma.
The code demos used in the presentation can be found here. https://github.com/yeokm1/reflections-on-trusting-trust
Introduzione al concetto di oggetto nel modello della memoria del C++ e ai suoi possibile tempi di vita (temporaneo, automatico, dinamico, ...). Relazione tra il tempo di vita e la visibilità (scope) di un oggetto. Gestione degli oggetti dinamici per tipi primitivi, strutture e array mediante l'utilizzo di puntatori (raw pointers).
There is ongoing confusion, and some contention, over the right way to use the QThread class. Part of the confusion comes from the uniqueness of QThread, which is significantly different from other threading classes. There are two valid patterns of QThread use, and each pattern is best suited for different use cases. Errors will arise when mixing these two patterns, or applying them inappropriately.
This presentation will look at different patterns of threading in general, and examine in detail the two usage patterns for QThread. This talk will also cover how QThread works inside, how to communicate between threads, provide examples, and point out the pitfalls to avoid.
1. Qt uses object-oriented memory management where objects are deleted automatically when their parent object is deleted.
2. Signals and slots provide a mechanism for communication between Qt objects using signals that are emitted by one object and caught by slot functions in other objects.
3. A signal mapper can be used to map multiple signals to a single slot so that different logic can be handled depending on which signal was emitted.
Qt Quick/QML brings designers and developers together to create and collaborate. QML is a collection of technologies that can build modern and fluid interfaces for applications – quickly. Join us as we explore the best of QML for mobile, embedded and desktop.
Part I will cover:
- Building Blocks of QML
- Qt Properties
- Declarative Code
Rust is a systems programming language focused on three goals: safety, speed, and concurrency. It is open source and provides top-tier performance like C/C++ while ensuring memory safety and preventing issues like memory leaks through its ownership and borrowing model that is checked at compile time. Rust also supports features like enums, pattern matching, generics, traits, and has a built-in test system to help ensure correctness.
An introduction to pointers and references in C++ (with elements of C++11 and C++14). The presentation introduces the readers to the concepts of pointers and references through the pragmatic need of writing a swap function between integers. Generic programming notions (e.g., type constructors) are adopted when useful for the explanation.
Video of this presentation can be found here https://engineers.sg/video/security-wednesdays-8-reflections-on-trusting-trust-nus-greyhats--572
The talk I gave at Papers We Love #16 (Singapore) and NUS Greyhats about this Turing award paper "Reflections on Trusting Trust" by Ken Thompson. I also demoed a rudimentary practical implementation of the ideas in the paper.
My talk also touched briefly on 2 extra papers "Fully Countering Trust through Diverse Double Compiling" by David Wheeler and "Critique of DDC" by Paul Jakma.
The code demos used in the presentation can be found here. https://github.com/yeokm1/reflections-on-trusting-trust
Qt5 is a cross-platform application development framework that allows developers to write applications once and deploy them across many operating systems, it provides tools like Qt Creator for building graphical user interfaces and libraries for tasks like networking, multimedia, and data storage, and it uses C++ for application logic with the option of using QML and JavaScript for declarative user interface development.
GStreamer is a multimedia framework for building applications that handle audio and video content. It provides reusable code modules called elements that can be linked together into pipelines to process multimedia. Elements include sources, filters, decoders, encoders and sinks. Pads connect elements and negotiate compatible data formats. Pipelines synchronize playback across elements and the framework supports integration with other projects and bindings to multiple programming languages.
How to write multi threaded applications using Qt:
In the slides you'll learn about 3 alternatives, all of which allow running tasks simultaneously in Qt applications, and understand the use cases leading to choosing each.
This document provides an overview of QML (Qt Meta/Modeling/Mockup Language) and QtQuick. It discusses installing Qt, why to use QML, what QML and QtQuick are, basic QML types, object attributes in QML, custom properties, signals, alias types, grouped properties, attached properties, global QML objects, property binding, inline JavaScript, importing JavaScript files, connections between signals and slots, components, positioning with Row, Column etc, text fields, states, transitions, models and views, and delegates. It also lists Qt Enterprise components and provides a demo and practice example using Flickr API.
Qt Quick/QML brings designers and developers together to create and collaborate. QML is a collection of technologies that can build modern and fluid interfaces for applications – quickly. Join us for this webinar to explore the best of QML for mobile, embedded and desktop.
Part III will cover:
- C++ Backends
- Reusing existing code
- Creating QML Modules
This document discusses best practices in Qt Quick/QML. It covers the building blocks of QML like QObject and QQuickItem which inherit from QObject. It describes properties, signals, slots and introspection capabilities. Anchors provide a declarative way to lay out items by attaching them to parent and sibling items, improving performance over dead reckoning layouts. The document promotes using anchors and bindings over procedural JavaScript for layout where possible.
detailed information about Pointers in c languagegourav kottawar
This document discusses pointers in C programming. It begins with an introduction to pointers and memory organization. It then covers basics of pointers including declaration, initialization, dereferencing, and pointer expressions. The document discusses various pointer applications including pointer arithmetic, pointers to pointers, dynamic memory allocation, pointers and arrays, and character strings. It provides examples to illustrate concepts like pointer expressions and pointer arithmetic with arrays. The document is intended as a reference for understanding pointers in C.
1. The document discusses pointers in C including declaring and initializing pointer variables, pointer operators like & and *, calling functions by reference using pointers, pointer arithmetic, and the relationship between pointers and arrays.
2. Key topics covered include using pointers to simulate call-by-reference, dereferencing pointers with *, taking addresses of variables with &, and implementing a bubble sort using pointers passed as arguments.
3. Pointer arithmetic allows incrementing, decrementing, adding/subtracting integers to pointers, and comparing pointers.
After an overview of Qt and its tools, a Hello World application quickly demonstrates the basic principles.
Qt is mainly famous for its intelligent concepts of signals and slots, which is explained together with examples for how to use widgets (UI controls).
At the end, the foundations of the meta-object system and its implications on memory management are explained.
This module follows up the introduction in the "Software Development with Qt" module, plus the Quickstart slides.
Pointers in C store the address of another variable. They allow dynamic memory allocation at runtime and can refer to variables of any data type. Pointers help save memory space and improve performance. A pointer variable contains the address of another variable. Common pointer types include null pointers, void pointers, and wild pointers. Pointers are useful for accessing memory locations and forming complex data structures like linked lists. However, pointers also present risks like memory corruption if misused.
Smart pointers help solve memory management issues like leaks by automatically freeing memory when an object goes out of scope. They support the RAII idiom where resource acquisition is tied to object lifetime. Common smart pointers include std::shared_ptr, std::unique_ptr, std::weak_ptr, which help avoid leaks from exceptions or cycles in object graphs. make_shared is preferable to separate allocation as it can allocate the object and control block together efficiently in one allocation.
Introduction to the Qt State Machine Framework using Qt 6ICS
The Qt State Machine Framework provides a practical mechanism to implement a GUI application as a state chart. Using Qt 6, this webinar will:
-Provide an intro to the framework
-Explore its features and its API in both C++ and QML
-Illustrate with an example how it can simplify development where the user interface is written in QML
This webinar is for any developer who wants to implement robust user interfaces.
This document discusses why Rust is a useful programming language. It provides an introduction to Rust, highlighting its memory safety features, ownership and borrowing system, and functional programming aspects like iterators and closures. Examples are given to demonstrate how Rust prevents common bugs like dangling pointers and iterator invalidation. The talk also covers Rust's type system, enums, patterns matching, and its Cargo package manager.
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기Chris Ohk
기존에 작성해 놓은 C++ 코드에 모던 C++를 적용하기는 쉽지 않습니다. 막상 개선하려고 마음먹었다고 해도, 어디서부터 바꿔야 할 지 막막하기만 합니다. 이 세션에서는 기존 C++ 코드에서 모던 C++를 적용해 프로그램의 구조와 성능을 개선하는 방법에 대해서 설명합니다. 그리고 기존 C++ 코드에 모던 C++를 적용할 때 주의해야 될 점에 대해서도 살펴봅니다.
The document discusses dynamic memory allocation in C. It explains that dynamic allocation allows programs to obtain more memory while running or release unused memory. The main dynamic memory functions in C are malloc(), calloc(), free(), and realloc(). Malloc allocates memory, calloc allocates and initializes to zero, free deallocates memory, and realloc changes the size of allocated memory. Examples of using each function are provided.
Qt5 is a cross-platform application development framework that allows developers to write applications once and deploy them across many operating systems, it provides tools like Qt Creator for building graphical user interfaces and libraries for tasks like networking, multimedia, and data storage, and it uses C++ for application logic with the option of using QML and JavaScript for declarative user interface development.
GStreamer is a multimedia framework for building applications that handle audio and video content. It provides reusable code modules called elements that can be linked together into pipelines to process multimedia. Elements include sources, filters, decoders, encoders and sinks. Pads connect elements and negotiate compatible data formats. Pipelines synchronize playback across elements and the framework supports integration with other projects and bindings to multiple programming languages.
How to write multi threaded applications using Qt:
In the slides you'll learn about 3 alternatives, all of which allow running tasks simultaneously in Qt applications, and understand the use cases leading to choosing each.
This document provides an overview of QML (Qt Meta/Modeling/Mockup Language) and QtQuick. It discusses installing Qt, why to use QML, what QML and QtQuick are, basic QML types, object attributes in QML, custom properties, signals, alias types, grouped properties, attached properties, global QML objects, property binding, inline JavaScript, importing JavaScript files, connections between signals and slots, components, positioning with Row, Column etc, text fields, states, transitions, models and views, and delegates. It also lists Qt Enterprise components and provides a demo and practice example using Flickr API.
Qt Quick/QML brings designers and developers together to create and collaborate. QML is a collection of technologies that can build modern and fluid interfaces for applications – quickly. Join us for this webinar to explore the best of QML for mobile, embedded and desktop.
Part III will cover:
- C++ Backends
- Reusing existing code
- Creating QML Modules
This document discusses best practices in Qt Quick/QML. It covers the building blocks of QML like QObject and QQuickItem which inherit from QObject. It describes properties, signals, slots and introspection capabilities. Anchors provide a declarative way to lay out items by attaching them to parent and sibling items, improving performance over dead reckoning layouts. The document promotes using anchors and bindings over procedural JavaScript for layout where possible.
detailed information about Pointers in c languagegourav kottawar
This document discusses pointers in C programming. It begins with an introduction to pointers and memory organization. It then covers basics of pointers including declaration, initialization, dereferencing, and pointer expressions. The document discusses various pointer applications including pointer arithmetic, pointers to pointers, dynamic memory allocation, pointers and arrays, and character strings. It provides examples to illustrate concepts like pointer expressions and pointer arithmetic with arrays. The document is intended as a reference for understanding pointers in C.
1. The document discusses pointers in C including declaring and initializing pointer variables, pointer operators like & and *, calling functions by reference using pointers, pointer arithmetic, and the relationship between pointers and arrays.
2. Key topics covered include using pointers to simulate call-by-reference, dereferencing pointers with *, taking addresses of variables with &, and implementing a bubble sort using pointers passed as arguments.
3. Pointer arithmetic allows incrementing, decrementing, adding/subtracting integers to pointers, and comparing pointers.
After an overview of Qt and its tools, a Hello World application quickly demonstrates the basic principles.
Qt is mainly famous for its intelligent concepts of signals and slots, which is explained together with examples for how to use widgets (UI controls).
At the end, the foundations of the meta-object system and its implications on memory management are explained.
This module follows up the introduction in the "Software Development with Qt" module, plus the Quickstart slides.
Pointers in C store the address of another variable. They allow dynamic memory allocation at runtime and can refer to variables of any data type. Pointers help save memory space and improve performance. A pointer variable contains the address of another variable. Common pointer types include null pointers, void pointers, and wild pointers. Pointers are useful for accessing memory locations and forming complex data structures like linked lists. However, pointers also present risks like memory corruption if misused.
Smart pointers help solve memory management issues like leaks by automatically freeing memory when an object goes out of scope. They support the RAII idiom where resource acquisition is tied to object lifetime. Common smart pointers include std::shared_ptr, std::unique_ptr, std::weak_ptr, which help avoid leaks from exceptions or cycles in object graphs. make_shared is preferable to separate allocation as it can allocate the object and control block together efficiently in one allocation.
Introduction to the Qt State Machine Framework using Qt 6ICS
The Qt State Machine Framework provides a practical mechanism to implement a GUI application as a state chart. Using Qt 6, this webinar will:
-Provide an intro to the framework
-Explore its features and its API in both C++ and QML
-Illustrate with an example how it can simplify development where the user interface is written in QML
This webinar is for any developer who wants to implement robust user interfaces.
This document discusses why Rust is a useful programming language. It provides an introduction to Rust, highlighting its memory safety features, ownership and borrowing system, and functional programming aspects like iterators and closures. Examples are given to demonstrate how Rust prevents common bugs like dangling pointers and iterator invalidation. The talk also covers Rust's type system, enums, patterns matching, and its Cargo package manager.
[TechDays Korea 2015] 녹슨 C++ 코드에 모던 C++로 기름칠하기Chris Ohk
기존에 작성해 놓은 C++ 코드에 모던 C++를 적용하기는 쉽지 않습니다. 막상 개선하려고 마음먹었다고 해도, 어디서부터 바꿔야 할 지 막막하기만 합니다. 이 세션에서는 기존 C++ 코드에서 모던 C++를 적용해 프로그램의 구조와 성능을 개선하는 방법에 대해서 설명합니다. 그리고 기존 C++ 코드에 모던 C++를 적용할 때 주의해야 될 점에 대해서도 살펴봅니다.
The document discusses dynamic memory allocation in C. It explains that dynamic allocation allows programs to obtain more memory while running or release unused memory. The main dynamic memory functions in C are malloc(), calloc(), free(), and realloc(). Malloc allocates memory, calloc allocates and initializes to zero, free deallocates memory, and realloc changes the size of allocated memory. Examples of using each function are provided.
The document is an invitation to a graduation ceremony for Darnell Edward Jones, providing the date, time, and address of the event in 3 sentences or less.
A birth announcement was made for Miss Cali Dream Bruno, born on November 19, 2014 at 8 lbs at 8:00 a.m. The announcement noted that she looked just like her mom and that her parents were Amorette Lord and Jeremy Bruno.
The document describes an architectural design for an artist retreat called "An Artist Retreat: Live, Work, Show." The design uses a modular column grid system that can be manipulated to define interior spaces. Operable canvas dividers allow artists flexibility to configure private living and working spaces. Large sliding doors open interior spaces to the exterior and provide views through the building. The goal is to create an integrated space where artists can live, work, and exhibit their art freely within the building envelope.
Este documento presenta una lista de productos de papel de regalo disponibles en diferentes tamaños y estilos. Incluye secciones para productos masculinos, bebé, infantiles, juveniles, románticos, femeninos, casuales y navideños. Proporciona detalles como nombres, códigos, tamaños y acabados de cada producto.
A birth announcement shares that Cali Dream Bruno was born on November 19, 2014 at 8 lbs and 8:00 a.m. to proud parents Amorette Lord and Jeremy Bruno, who are calling their new baby girl "Our Little Miracle!"
Apresentação Institucional - Simplifique Desenvolvimento de Pessoas e NegóciosSIMPLIFIQUE! RH
Já imaginou ter a melhor equipe trabalhando com você?
Conte com a Simplifique para desenvolver projetos personalizados de Recursos Humanos.
Recrutamento & Seleção
Cargos & Salários
Treinamento & Desenvolvimento
Pesquisa de Clima Organizacional
Avaliação de Desempenho
Este documento describe las características principales de las tecnologías de la información y la comunicación (TIC). Las TIC permiten enviar, recibir, almacenar y recuperar información de manera digital y facilitan la comunicación interactiva entre usuarios. Algunas características clave son su alta penetración en sectores como la educación y los negocios, la capacidad de convertir a los espectadores en participantes activos, y permitir el trabajo colaborativo entre personas en diferentes lugares.
Recrutamento & Seleção para Pequenas EmpresasSIMPLIFIQUE! RH
O documento descreve o processo de recrutamento e seleção de funcionários, incluindo definir o perfil da vaga, recrutar candidatos por meio de redes sociais e agências, selecionar os melhores candidatos por meio de entrevistas e testes, e finalizar o processo com a contratação. A empresa Simplifique oferece serviços de recrutamento e seleção para ajudar empresas a encontrarem os melhores candidatos de forma eficiente.
Introduzione agli Array in C++. Argomenti trattati: decadimento a puntatore di un array; conseguenze del meccanismo di decadimento sul passaggio di array a funzioni; array multidimensionali e il concetto di puntatore ad array; come passare array multidimensionali a funzioni; gli iteratori come generalizzazione di un puntatore ad elemento di un array ed una breve scorsa di come usare gli iteratori con gli algoritmi standard (e.g., std::copy) del C++.
Queste slide dal titolo provocatorio cercano di dare l'idea che la stupidità e la pigrizia possono avere un effetto positivo nela programmazione per la ricerca di soluzioni semplici. Nello specifico caso parliamo di funzioni in C
This set of slides introduces the reader to a subset of the C++ Standard Library called the Standard Template Library (STL). The STL provides a collection of parameterized containers and algorithms, and it is the most successful example of an approach to programming called generic programming. In this presentation, we aim at studying the ideals and concepts of the STL by re-implementing small parts of the library. Specifically, we first show how we can discover requirements on types in order to devise generic algorithms. Then, we focus on how to make algorithms independent of containers through the pivotal abstraction of iterators. To this end, we replicate the standard algorithm for finding the minimum in a sequence (min_element), which we subsequently match with a custom forward iterator over intrusive linked lists of integers. Finally, we see how function objects can be used to customize containers and algorithms alike. This allows us to deepen our understanding of ordering relations, and, in particular, to introduce the concept of strict weak orderings.
This set of slides introduces the reader to the concept of regular types, i.e., user-defined types whose semantics closely resembles that of built-in types. The notion of regular types proved crucial for the development of the C++ Standard Template Library, and it is currently employed in next-gen C++ libraries such as Eric Niebler's range-v3. The presentation serves as a gentle introduction to the topic, and discusses which requirements must be satisfied for a type to be regular. In particular, the concept of equality-preserving copy and assignment is presented, as well as how to define ordering relations that satisfy the requirements of strictness, transitivity and comparability (i.e., that adhere to the trichotomy law).
This set of slides introduces the reader to the concept of resource wrappers, i.e., classes that are responsible for the correct handling of resources of some kind (e.g., memory). In particular, the presentation discusses the design and implementation of a simplified version of std::vector for the specific case of integer elements. In this regard, we first discuss the fundamental role of destructors as a deterministic, general-purpose undo mechanism. Second, we notice that providing an explicit destructor entails the need of a consequent explicit implementation for the copy constructor and copy assignment operator. We conclude with the formulation of the so-called "rule of three".
The document discusses memory management concepts in C++ such as storage duration of objects, memory segmentation, dynamic objects, and memory leaks. It explains that objects can have automatic, dynamic, static, or thread-local storage duration. Dynamic objects are created using new and persist until explicitly deleted, while automatic objects are destroyed at the end of the block they are defined in. Memory for a process is divided into code, data, heap, and stack segments. The heap stores dynamic objects created with new. Memory leaks can occur if dynamic objects are not deleted before their pointer variables go out of scope.
This set of slides introduces the reader to the concept of operator overloading for user-defined types in C++ (with elements of C++11 and C++14). The exemplary case of the complex class is introduced. It follows a discussion on how to implement mixed-mode arithmetic, which requires mixing member and non-member operator functions. Moreover, the technical tool of friend functions and access functions is discussed.
This set of slides introduces the reader to the concept of multidimensional arrays in C++ (with elements of C++11 and C++14). The true nature of multidimensional arrays is discussed by means of an intermediate type alias. The pheonomenon of array-to-pointer decay and pointer arithmetic is then generalized to arrays of arrays. The presentation proceeds with a discussion on how to pass multidimensional arrays to functions.
This set of slides introduces the reader to the concept of arrays in C++ (with elements of C++11 and C++14). After presenting the array data type, the concept of array-to-pointer decay is introduced. The presentation proceeds with a discussion on how to pass arrays to functions. To this extent, the reader is guided to the use of bounded ranges as the first step towards the use of the Standard Template Library (STL).
Spring MVC - Wiring the different layersIlio Catallo
The presentation focuses on the problem of wiring the different layers of a Spring MVC Web application. More precisely, the presentation explains how to wire the presentation layer (made of Spring MVC controllers) with the service and persistence objects. To this end, the slides first explain how to create the so called back-end (a.k.a. root) container, which will host the persistence and the service objects. Second, the @Repository and @Service annotations are introduced, which permit the framework to auto-discover the application beans. Finally, it is discussed how to wire such beans, through the usage of either the Spring-specific @Autowired annotation or the JEE @Inject annotation.
This set of slides introduces the basic concepts of Java development. First, the difference between Java as the programming language and Java as a platform is stated. Then, the different Java platforms are presented, with a particular interest in Java Standard Edition and Java Enterprise Edition. With respect to the latter, the roles and differences between the many JEE containers are discussed.
How to process request parameters with the Spring MVC framework. Namely, the presentation tackles the three primary concerns when dealing with request parameters: data binding, data buffering and data validation. To this end, the Bean Validation API (JSR-303) is discussed, and the concept of MessageSource for localized error messages is introduced. Moreover, The Post/Redirect/Get (PRG) pattern is presented along with a possible implementation strategy.
An introduction to the basics of the Spring MVC Web framework. The concepts of front controller, controller (handler), model and view are introduced. The whole processing pipeline is discussed, with an in-depth description of the HandlerMapping and ViewResolver strategy interfaces. The alternative representations of the Model (Map, Model and ModelMap) are presented.
The document discusses the layers of abstraction in web application architecture. It describes how web applications typically have four main layers - the presentation layer, service layer, persistence layer, and domain model layer. The domain model layer contains the core business logic and objects of the application. The service layer acts as a facade to expose use cases to the presentation layer and coordinates access to the domain model layer. The persistence layer isolates the code for interacting with data storage.
An introduction to the Java Persistence API 2.x (JPA). Namely, this set of slides first introduces the problem of impedance mismatch between the object model and the relation model. Then, the EntityManager's public interface is discussed, together with the parallelism between a persistence context and a L1 cache. The issue of encapsulating the different application's use cases (which are exposed by the service objects) is solved by means of the @Transactional annotation, which provides a declarative way of demarcating the application's transactional boundaries. It follows an in-depth explanation on how to integrate a local, container-managed EntityManager within an existing Spring MVC application, so as to correctly support the propagation of the persistence context throughout the different beans involved in the same transaction. We then turn our attention to the problem of mapping relationships, thus introducing the @OneToMany, @ManyToMany and @OneToOne annotations. The additional topics of how to cascade operations and how to support lazy loading are covered as well. The presentation concludes with a discussion on how to use both the Criteria and Query API (and JPQL) to query the underlying database.
The document provides information about the JSP Standard Tag Library (JSTL). It discusses that JSTL is a tag library that offers tags to control flow, format dates/numbers, parse XML, and execute SQL queries. The core JSTL tag library includes commonly used tags for accessing and modifying data, making decisions, looping, and error handling. Specific tags discussed include <c:out> for outputting data, <c:set> for setting variables, <c:if> for simple conditions, and <c:forEach> for looping over collections.
Internationalization in Jakarta Struts 1.3Ilio Catallo
This document discusses internationalization in Struts frameworks. It describes internationalization as designing applications to support multiple languages and locales without code changes. Localization is adapting software for specific regions by adding localized components and translations. To internationalize, an application must distinguish locales, display locale-specific messages, support new locales without recompiling, and format locale-sensitive elements like dates automatically. Struts uses Java Locale objects and resource bundles of localized messages keyed by locale to internationalize. Elements use MessageFormat patterns to specify locale-sensitive formatting.
The document discusses validation in Jakarta Struts 1.3. It describes how Struts uses ActionForms to buffer, validate, and convert HTTP form data on the server-side. It outlines two approaches to validation - manually implementing the validate() method, or using the Jakarta Validator framework. The Validator framework defines validation rules separately in XML files and supports both server-side and client-side validation via JavaScript. It discusses configuring the Validator framework by mapping validators to ActionForm properties and generating validation code.
This document provides an introduction to Jakarta Struts 1.3, an open source MVC framework for building Java web applications. It discusses the limitations of using the traditional MVC pattern for web applications due to HTTP's stateless nature. Struts implements an MVC2 pattern to address this, using the controller to manage state. The core Struts components like ActionForms, Actions, and ActionMappings are explained. It also covers setting up the Struts controller through configuration files, defining forms and actions, and creating views with JSP and custom tag libraries.
The document provides an overview of community detection in networks. It defines what a community and partition are, and describes several algorithms for partitioning networks into communities:
1. Kernighan and Lin's algorithm from 1970 which iteratively swaps nodes between partitions to minimize the cost.
2. Newman and Girvan's algorithm from 2004 which removes the edge with the highest betweenness centrality on each iteration.
3. Bagrow and Bollt's algorithm from 2008 which expands a shell of nodes out from a seed node, looking for a drop in the total emerging degree to identify community boundaries.
The document also discusses different ways to define communities, assess partition quality, and represent partitioning results as a dendrogram
The CUbRIK project is a 36-month, large-scale integrating project partially funded by the European Commission to build an open search platform. The project has four key objectives: 1) advance the architecture of multimedia search through independent and pipelined components for content, query, and feedback processing; 2) place humans in the loop to improve automatic feature extraction; 3) open the search box through an open platform; and 4) start a search business ecosystem. One demonstration aims to integrate human and automatic computation to increase trademark logo detection precision and recall over fully automatic solutions.
4. Il problema dello swap
¤ Supponiamo che in un programma avvenga
frequentemente lo scambio (swap) tra due interi
4
2 inta: 5 intb:
5. Il problema dello swap
¤ IDEA: Scrivere una funzione int_swap e richiamarla
ovunque necessario
int main() {
...
int a = 2, b = 5;
...
int_swap(a, b); // expected result: a = 5, b = 2
}
5
7. Il problema dello swap
¤ Un possibile tentativo potrebbe essere:
¤ La soluzione sembra immediata…ma funziona?
void int_swap(int x, int y) {
int temp = x;
x = y;
y = temp;
}
7
9. Il problema dello swap
¤ All’invocazione di int_swap:
¤ I valori di a e b nella funzione chiamante vengono copiati
nelle variabili locali x e y
¤ i valori di x e y vengono scambiati, ma…
¤ Le variabili a e b nel chiamante rimangono intoccate
...
int a = 2, b = 5;
int_swap(a, b); // x and y are copies of a and b,
// hence a and b remain unchanged
9
10. Il problema dello swap
¤ Non è possibile scrivere la funzione int_swap passando
le variabili per copia
10
#@?$!
12. Organizzazione della memoria
¤ La memoria può essere immaginata come una
successione di celle di memoria
¤ Ogni cella occupa la minima dimensione che il
calcolatore è in grado di gestire (1 byte*)
*1 byte è il quantitativo più comune
12
15. Organizzazione della memoria
¤ In questo modo:
¤ Ogni cella ha un indirizzo univoco
¤ È nota una regola per passare da una cella alle successive
15
16. Nome di una variabile
¤ Il nome della variabile è lo strumento usato per accedere
al contenuto della memoria riservata a tale variabile
int a = 5;
int b = a + 5; // we use the data contained in ‘a’
// without knowing its physical
// location in memory
16
17. Variabili e memoria
¤ In virtù del fatto che ogni variabile ha un nome, non
dobbiamo solitamente preoccuparci di dove i dati
vengano memorizzati
17
1775 17771776 1778 1779 1780
int a
18. Variabili e memoria
¤ Ciononostante, una variabile occupa una o più celle di
memoria
18
1775 17771776 1778 1779 1780
int a
19. Indirizzo di una variabile
¤ Quando vogliamo riferirci all’indirizzo di una variabile,
piuttosto che il suo valore, utilizziamo la sintassi
&nome_variabile
19
1775 17771776 1778 1779 1780
int a&a
20. Indirizzo di una variabile
¤ L’espressione &a può essere letta come “indirizzo di a”
20
1775 17771776 1778 1779 1780
int a&a
21. Indirizzo di una variabile
¤ Data dunque la definizione:
¤ Si ha che:
¤ a si riferisce al contenuto della variabile (5 in questo caso)
¤ &a si riferisce all’indirizzo dove tale contenuto risiede in
memoria
21
int a = 5;
22. Indirizzo di una variabile
¤ Esempio: stampare a video l’indirizzo di una variabile
22
int a = 5;
std::cout << "the address of a is " << &a
<< std::endl;
23. Indirizzo di una variabile
¤ Quando il simbolo & precede un’espressione, questo
assume il ruolo di operatore (address-of operator)
23
int a = 5;
std::cout << "the address of a is " << &a
<< std::endl;
24. Indirizzo di una variabile
¤ Nota: se una variabile occupa più di una cella di
memoria, l’operatore & restituisce l’indirizzo della prima
cella di memoria utilizzata
1775 17771776 1778 1779 1780
int a&a
24
25. Dimensione dei tipi dati in C++
¤ Non esistono dimensioni prefissate dei tipi dati
¤ La dimensione in byte di ogni tipo dato è dipendente
dall’architettura del calcolatore e dal compilatore
¤ Lo standard C++ specifica unicamente il minimo intervallo di
valori memorizzabili
25
26. Dimensione dei tipi dati in C++
¤ Esempio: un int deve permettere di memorizzare numeri
interi tra -32’767 e +32’767
¤ Tipica dimensione su architettura Intel 16-bit: 2 byte
¤ Tipica dimensione su architettura Intel 32-bit: 4 byte
26
27. Memorizzare un indirizzo
¤ La stampa di un indirizzo non è particolarmente utile
¤ Supponiamo invece di voler memorizzare l’indirizzo di a,
in modo da poterlo riutilizzare successivamente
¤ Abbiamo bisogno di una variabile address_of_a il cui
contenuto sia l’indirizzo di a
int a = 5;
std::cout << "the address of a is " << &a
<< std::endl;
27
31. Memorizzare un indirizzo
¤ Il tipo dato di una variabile che contiene l’indirizzo di un
intero è int*
¤ Il tipo dato int* si chiama puntatore a intero
int* address_of_a = &a;
31
32. Puntatori
¤ Variabili che contengono indirizzi sono chiamate
puntatori
¤ Una variable di tipo T* può contenere l’indirizzo di una
variabile di tipo T
¤ È possibile creare puntatori a qualsiasi tipo dato*,
indipendentemente che questo sia predefinito o creato
dall’utente
Per un tipo dato T, T* è il tipo dato puntatore a T
* Purchè il tipo dato non sia più piccolo di 1 byte
32
33. Esempi di puntatori
¤ Regola (del pollice) per interpretare il tipo dato:
¤ Il più a destra degli asterischi * si legge “puntatore a…”
¤ Tutto ciò che segue da destra a sinistra è il tipo puntato
int* a; // pointer to int
char* b; // pointer to char
float* c; // pointer to float
int** d; // pointer to pointer to int
Per un tipo dato T, T* è il tipo dato puntatore a T
33
35. Accedere al contenuto di una
variabile
¤ Supponiamo che qualcuno ci fornisca un puntatore a
intero ptr contenente l’indirizzo di una variabile intera
35
int* ptr = ... // somehow initialized
36. Accedere al contenuto di una
variabile
¤ Possiamo usare l’indirizzo memorizzato in ptr per
accedere al contenuto della variabile puntata?
36
int* ptr = ... // somehow initialized
37. Indirezione
¤ Dato un puntatore, è possibile accedere al contenuto
della variabile puntata attraverso l’operatore *
(indirection operator)
int* ptr = ... // somehow initialized
std::cout << "the value of the variable
pointed to by ptr is " << *ptr << std::endl;
37
38. Indirezione
¤ L’espressione *ptr può essere letta come
“il valore della variabile puntata da ptr”
int* ptr = ... // somehow initialized
std::cout << "the value of the variable
pointed to by ptr is " << *ptr << std::endl;
38
39. Indirezione
¤ L’operatore di indirezione può essere usato sia per
leggere che per modificare il valore della variabile
puntata
int* ptr = ... // somehow initialized
*ptr = 7;
int b = 5 + *ptr; // b contains 12
39
40. Indirezione
¤ In altre parole, l’espressione *ptr può apparire a sinistra
dell’operatore di assegnamento
40
int* ptr = ... // somehow initialized
*ptr = 7;
int b = 5 + *ptr; // b contains 12
43. Metodi d’accesso
¤ È possibile quindi accedere al contenuto di una variabile
in due modi:
¤ Attraverso il suo nome
¤ Attraverso il suo indirizzo (memorizzato in un puntatore)
¤ L’accesso mediante puntatore è indiretto
¤ per accedere al contenuto della variabile puntata è
necessario prima accedere al contenuto del puntatore
43
44. Puntatori nulli
¤ Come per tutte le variabili locali, non è possibile
conoscere il valore di un puntatore non inizializzato
44
int* ptr; // uninitialized pointer
45. Puntatori nulli
¤ Il puntatore potrebbero contenere un qualsiasi valore
45
int* ptr; // uninitialized pointer
46. Puntatori nulli
¤ Tale valore casuale potrebbe essere interpretato come
l’indirizzo di un ipotetica variabile puntata dal puntatore
46
int* ptr; // uninitialized pointer
47. Puntatori nulli
¤ Non esiste alcun modo di capire se il valore contenuto in
un puntatore rappresenti o meno un indirizzo valido
47
int* ptr; // uninitialized pointer
48. Puntatori nulli
¤ È molto facile trovarsi ad utilizzare un puntatore non
inizializzato senza nemmeno rendersene conto
48
int* ptr; // uninitialized pointer
49. Puntatori nulli
¤ Per evitare il rischio di avere puntatori non inizializzati
sarebbe sufficiente inizializzare un puntatore solo dopo
aver definito la variabile da puntare
49
int a = 5;
int* ptr = &a;
50. Puntatori nulli
¤ Purtroppo, ciò non è sempre realizzabile
¤ in alcuni casi non è effettivamente possibile creare la
variabile da puntare prima dell’inizializzazione del puntatore
¤ Anche senza una variabile da puntare, sarebbe
preferibile evitare rischi inizializzando il puntatore.
50
51. Puntatori nulli
¤ È possibile inizializzare un puntatore e al contempo
indicare che non è ancora disponibile la corrispettiva
variabile a cui puntare
¤ Per farlo si inizializza il puntatore al valore:
¤ NULL (fino al C++03) o
¤ nullptr (dal C++11)
51
52. Puntatori nulli
¤ L’espressione può essere letta come
“il puntatore ptr non punta a nulla”
int* ptr = nullptr; // 'ptr’ is not
// pointing to anything
52
53. Il problema dello swap:
soluzione
¤ Come possiamo usare i puntatori per riuscire a scrivere la
funzione int_swap?
53
54. Il problema dello swap:
soluzione
¤ IDEA: invece di passare una copia del contenuto delle
variabili, passare una copia del loro indirizzo
void int_swap(int* x, int* y) {
int temp = *x;
*x = *y;
*y = temp;
}
54
55. Il problema dello swap:
soluzione
¤ All’invocazione di int_swap:
¤ Gli indirizzi di a e b nella funzione chiamante vengono
copiati nelle variabili puntatore locali x e y
¤ Si scambiano i valori delle variabili puntate da x e y
(ovvero a e b)
¤ Al termine della funzione int_swap le variabili locali x e y
vengono distrutte
¤ Come invocare la nuova funzione int_swap?
55
56. Il problema dello swap:
soluzione
¤ Sappiamo che:
¤ La funzione int_swap si aspetta in ingresso gli indirizzi delle
variabili da scambiare
¤ Per ottenere l’indirizzo di una variabile si usa l’operatore &
56
57. Il problema dello swap:
soluzione
¤ Se vogliamo scambiare il contenuto di a e b dobbiamo
quindi fornire l’indirizzo di a (&a) e l’indirizzo di b (&b)
int main() {
...
int a = 2, b = 5;
...
int_swap(&a, &b); // now: a = 5, b = 2
}
57
58. Passaggio per indirizzo
¤ Se una funzione riceve una copia delll’indirizzo di una
variabile piuttosto che un copia del suo valore, si parla di
passaggio per indirizzo
¤ Il passaggio per indirizzo permette di:
¤ Riflettere le modifiche attutate nella funziona chiamata
anche alla funzione chiamante
¤ Accedere rapidamente a dati corposi, dato che nessuna
copia del dato viene creata
¤ Simulare il ritorno di più variabili da una funzione
58
59. Problema risolto?
¤ Siamo soddisfatti della nostra soluzione?
¤ Il metodo funziona, ma…
¤ Il codice è diventato difficile da leggere
¤ dovremmo gestire il caso di particolare in cui viene passato
nullptr come indirizzo
¤ Possiamo fare di meglio?
int_swap(&a, &b);
59
61. Inizializzare una variabile
¤ Al momento dell’inizializzazione di una variabile, il valore
della variabile inizializzatrice viene copiato nella nuova
variabile
¤ Al termine dell’inizializzazione, ognuna delle due variabili
contiene la propria copia dello stesso valore
¤ La nuova variabile vive una vita indipendente, il
cambiamento del suo valore non altera quello della
variabile inizializzatrice
61
62. Dichiarare una variabile
¤ Quando una variabile viene dichiarata, se ne specifica il
tipo e l’identificativo (nome)
¤ Entrambi questi aspetti non sono modificabili in un
secondo momento
¤ Non è possibile tramutare una variabile di tipo T in una
variabile di tipo T’*
¤ Non è possibile mutare l’identificativo (cambiare nome ad
una variabile)
* ricorda che il casting crea una nuova variabile,
non cambia la natura di una variabile esistente
62
63. Alias di una variabile
¤ Il C++ permette però di inizializzare nomi aggiuntivi (alias)
per una variabile:
int a = 5;
int& b = a; // b is a new name (alias) for a
63
64. Alias di una variabile
¤ b non indica una nuova area di memoria, b è solo un
altro nome per a
int a = 5;
int& b = a; // b is a new name (alias) for a
64
65. Alias di una variabile
¤ b è una variabile di tipo int&, ovvero un alias di una
variabile di tipo int
int a = 5;
int& b = a; // b is a new name (alias) for a
65
66. Riferimenti
¤ Gli alias di una variabile sono chiamati riferimenti
(reference*)
¤ L’inizializzazione di un riferimento non comporta la copia
del valore della variabile inizializzatrice, bensì
l’associazione (binding) del nuovo nome alla variabile
* Dal C++11 sono stati rinominati
lvalue reference
Per un tipo dato T, T& è il tipo dato riferimento a T
66
67. Esempi di riferimenti
¤ Regola (del pollice) per interpretare il tipo dato:
¤ L’ampersand & più a destra si legge “riferimento a…”
¤ Tutto ciò che segue da destra a sinistra è il tipo a cui ci si
riferisce
Per un tipo dato T, T& è il tipo dato riferimento a T
int& a = b; // a is a new name for b (where b is of type int)
float& c = d; // c is a new name for d (where d is of type
float)
int& e = b; // e is a new name for b, hence a new name for a
int*& f = g; // f is a new name for g (where g is of type int*)
67
68. Nuovo vs. vecchio nome
¤ Una volta inizializzato, usare il nuovo nome o il vecchio
nome è indifferente*
int a = 5;
int& b = a; // b is a new name (alias) for a
b = 7;
std::cout << a << std::endl; // the output will be '7'
std::cout << &a
<< &b
<< std::endl; //'a' and 'b' are the same thing,
// so the address is the same
* concetto riassumibile nella massima:
“the reference is the referent”
68
69. Limitazione dei riferimenti
¤ I riferimenti devono essere inizializzati
¤ I riferimenti non possono essere ri-assegnati:
¤ Non sono ammessi* riferimenti a riferimenti
int& b; //ERROR: b is a new name of which variable?
int a = 5, c = 10;
int& b = a;
b = c; // this does not mean that b is now a
// new name for c, the expression amounts to
// say “a = c”
* Dal C++11, esiste un unico strappo alla regola al fine
di permettere il perfect forwarding
69
70. Il problema dello swap:
soluzione
¤ I riferimenti ci permettono di scrivere la funzione
int_swap in maniera semplice e sicura
void swap(int& x, int& y) {
int temp = x;
x = y;
y = temp;
}
Il corpo della
funzione è uguale a
quanto scritto nella
prima (errata)
versione
70
71. Il problema dello swap:
soluzione
¤ I riferimenti ci permettono di scrivere la funzione
int_swap in maniera semplice e sicura:
¤ Semplice: non dobbiamo usare l’operatore di indirezione
ovunque
¤ Sicura: non possiamo per errore passare nullptr
71
72. Il problema dello swap:
soluzione
¤ Per scambiare i valori di a e b, invochiamo la funzione
int_swap esattamente come una qualsiasi altra funzione
72
int main() {
...
int a = 2, b = 5;
...
int_swap(a, b); // now: a = 5, b = 2
}
73. Il problema dello swap:
soluzione
¤ In questo modo:
¤ x è un alias per a
¤ y è un alias per b
int main() {
...
int a = 2, b = 5;
...
int_swap(a, b); // now: a = 5, b = 2
}
73
74. Il problema dello swap:
soluzione
¤ Modificare x e y è la stessa cosa che modificare a e b
74
int main() {
...
int a = 2, b = 5;
...
int_swap(a, b); // now: a = 5, b = 2
}
76. Bibliografia
¤ S. B. Lippman, J. Lajoie, B. E. Moo, C++ Primer (5th Ed.)
¤ B. Stroustrup, The C++ Programming Language (4th Ed.)
¤ R. Lafore, Object Oriented Programming in C++ (4th Ed.)
¤ C++FAQ, Section 8
http://www.parashift.com/c++-faq/references.html
76