Jython: Python para la plataforma Java (EL2009)Leonardo Soto
This document discusses using Python on the Java platform. It begins by asking if a Java platform can exist without Java, and explores using Python, Ruby, Scala and Groovy instead. It then highlights features of Python like being dynamic, flexible and readable. Jython is introduced as a way to use Python on the Java platform. The document demonstrates using Swing GUIs from Jython and shows a Django web application example. It also discusses testing Python code including doctests and integration tests using HtmlUnit. Finally, it mentions some companies that use Jython and provides resources for learning more.
Jython: Python para la plataforma Java (JRSL 09)Leonardo Soto
This document discusses using Python on the Java platform with Jython. It begins with an introduction to Jython, noting that it allows Python code to run on the Java Virtual Machine while maintaining compatibility with CPython. The document then provides examples of using Swing GUI libraries from Python with Jython. It also demonstrates using Django to build a simple wiki application in Jython. Finally, it discusses doctests for testing Python code and mentions some organizations that use Jython, such as Lockheed Martin and EADS.
Actors are one of the most popular concurrency models in nowadays software systems. In this talk, we will present zio-actors – a small strongly typed actor library backed by ZIO. He will explain library design, demonstrate its usage, and point out the differences and similarities with Akka.
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
The document discusses various techniques for optimizing Django ORM queries to improve performance, including:
1. Using bulk_create, update, and transaction.atomic to perform bulk operations in a single query instead of multiple queries.
2. Prefetching related objects and selecting related fields to avoid N+1 queries when accessing related data.
3. Filtering and ordering prefetched querysets to further optimize related data retrieval.
4. Encapsulating optimizations like select_related in custom model managers to apply them automatically.
The key is to minimize the number of database hits by performing operations in bulk where possible instead of one-by-one. Selecting related fields, prefetching, and
The Ring programming language version 1.2 book - Part 32 of 84Mahmoud Samir Fayed
The document discusses user registration and login functionality in Ring. It describes classes for users (Model, View & Controller), form views for registration and login, and code to handle registration, login, and checking authentication. It also summarizes classes for database access (Database), model objects (ModelBase), and controllers (ControllerBase).
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]MongoDB
MongoDB 2.2 이후 집계 파이프라인을 통한 데이터 분석을 강화하고 있습니다.
버전 4.2 에서는 더 많은 기능을 추가 했으며, 더 강력한 쿼리 및 업데이트 그리고 MView 기능까지 사용 할 수
있습니다. 집계파이프 라인을 포함한 해당 기능을 이용하여 단일뷰(SignleView), ETL, 데이터 롤업 및 MView 수행하는 방법을 설명합니다.
Jython: Python para la plataforma Java (EL2009)Leonardo Soto
This document discusses using Python on the Java platform. It begins by asking if a Java platform can exist without Java, and explores using Python, Ruby, Scala and Groovy instead. It then highlights features of Python like being dynamic, flexible and readable. Jython is introduced as a way to use Python on the Java platform. The document demonstrates using Swing GUIs from Jython and shows a Django web application example. It also discusses testing Python code including doctests and integration tests using HtmlUnit. Finally, it mentions some companies that use Jython and provides resources for learning more.
Jython: Python para la plataforma Java (JRSL 09)Leonardo Soto
This document discusses using Python on the Java platform with Jython. It begins with an introduction to Jython, noting that it allows Python code to run on the Java Virtual Machine while maintaining compatibility with CPython. The document then provides examples of using Swing GUI libraries from Python with Jython. It also demonstrates using Django to build a simple wiki application in Jython. Finally, it discusses doctests for testing Python code and mentions some organizations that use Jython, such as Lockheed Martin and EADS.
Actors are one of the most popular concurrency models in nowadays software systems. In this talk, we will present zio-actors – a small strongly typed actor library backed by ZIO. He will explain library design, demonstrate its usage, and point out the differences and similarities with Akka.
From java to kotlin beyond alt+shift+cmd+k - Droidcon italyFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
From Java to Kotlin beyond alt+shift+cmd+k - Kotlin Community Conf MilanFabio Collini
Kotlin is a first-class language for Android development since Google I/O 2017. And it’s here to stay!
Thanks to Android Studio it’s really easy to introduce Kotlin in an existing project, the configuration is trivial and then we can convert Java classes to Kotlin using a Alt+Shift+Cmd+K. But the new syntax is the just beginning, using Kotlin we can improve our code making it more readable and simpler to write.
In this talk we’ll see how to use some Kotlin features (for example data classes, collections, coroutines and delegates) to simplify Android development comparing the code with the equivalent “modern” Java code. It’s not fair to compare Kotlin code with plain Java 6 code so the Java examples will use lambdas and some external libraries like RxJava and AutoValue.
The document discusses various techniques for optimizing Django ORM queries to improve performance, including:
1. Using bulk_create, update, and transaction.atomic to perform bulk operations in a single query instead of multiple queries.
2. Prefetching related objects and selecting related fields to avoid N+1 queries when accessing related data.
3. Filtering and ordering prefetched querysets to further optimize related data retrieval.
4. Encapsulating optimizations like select_related in custom model managers to apply them automatically.
The key is to minimize the number of database hits by performing operations in bulk where possible instead of one-by-one. Selecting related fields, prefetching, and
The Ring programming language version 1.2 book - Part 32 of 84Mahmoud Samir Fayed
The document discusses user registration and login functionality in Ring. It describes classes for users (Model, View & Controller), form views for registration and login, and code to handle registration, login, and checking authentication. It also summarizes classes for database access (Database), model objects (ModelBase), and controllers (ControllerBase).
Aggregation Pipeline Power++: MongoDB 4.2 파이프 라인 쿼리, 업데이트 및 구체화된 뷰 소개 [MongoDB]MongoDB
MongoDB 2.2 이후 집계 파이프라인을 통한 데이터 분석을 강화하고 있습니다.
버전 4.2 에서는 더 많은 기능을 추가 했으며, 더 강력한 쿼리 및 업데이트 그리고 MView 기능까지 사용 할 수
있습니다. 집계파이프 라인을 포함한 해당 기능을 이용하여 단일뷰(SignleView), ETL, 데이터 롤업 및 MView 수행하는 방법을 설명합니다.
The Ring programming language version 1.5.2 book - Part 43 of 181Mahmoud Samir Fayed
This document discusses Ring code for implementing CRUD (create, read, update, delete) functionality using an MVC (model-view-controller) pattern. It includes code for classes that represent a Salary model, controller, and view. It also includes code for classes that handle user registration and login functionality, including models, views, controllers, and language files. The document provides code examples for connecting to a database, implementing base model and controller classes, and performing common database operations like searching, counting, inserting, updating, and finding records.
The document discusses Java and the benefits of Groovy compared to Java. It covers boilerplate code and ceremony in Java that can be reduced using Groovy. Examples are provided demonstrating Groovy's syntax for primitives, collections like lists and maps, closures, IO operations, XML processing, and a DSL. The document recommends Groovy for its duck typing, operators, and safe navigation operator to avoid null pointer exceptions.
This document contains code for a sales system application in Visual Basic. It includes code for forms to manage clients, products, invoices and users. It allows adding, editing, deleting and searching records in databases. It also includes code to launch other applications like Word, Excel and Calculator from the main form.
The Ring programming language version 1.10 book - Part 54 of 212Mahmoud Samir Fayed
This document describes code related to user registration and login functionality in Ring. It includes code for a registration form, login form, user registration logic, login validation, and checking if a user is logged in. Database and model classes are also shown that handle connecting to the database, querying for users, and managing user data.
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinFabio Collini
It’s never easy to write async code but luckily there are many libraries to manage asynchronicity without adding too much complexity. In the last years RxJava and the other ReactiveX libraries have been very popular but lately there is a new way to manage async code in Kotlin: the coroutines. In this talk we’ll pros and cons of there two approaches and how to leverage them to simplify asynchronous code on Android.
Do they solve the same problem? Can we use them together? Which one can be used to write functional code? How can we use them effectively in Android development?
Spoiler alert: They are both great!
In this talk we’ll see how to solve common problems using RxJava or Coroutines, starting from basic concepts (for example the Retrofit support and how to cancel a task) to some more advanced (like threading, error management and how to combine multiple tasks).
All example of the talk are available on this repository:
https://github.com/fabioCollini/RxJavaVsCoroutines
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
This document summarizes code from the Ring documentation related to user registration, login, and database classes. It describes classes for users, models, views, controllers, and languages that allow for user registration, login, form views, and routing. It also summarizes the Database, ModelBase, and ControllerBase classes that provide functionality for connecting to databases, executing queries, and managing model data.
Functional programming avoids changing-state and mutable data. Referential transparency means expressions can be replaced without affecting observable behavior. Pure functions only depend on argument values and have no other effects. Case classes provide functionality like equals, hashCode and pattern matching out of the box. Futures allow running blocking operations asynchronously and chaining results with map, flatMap and for comprehensions. Implicits allow type conversions and providing parameters implicitly. Sealed classes allow exhaustive pattern matching of a type hierarchy.
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
This document provides code examples for classes used in a web application framework in Ring. It includes the Database, ModelBase, and ControllerBase classes which handle database connectivity and operations. It also includes an overview of the WebLib API which provides functions and classes for generating HTML pages and elements. Some key classes described are Page, Form, Table, and classes to generate specific HTML elements like Div, Link, Image etc.
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
This document discusses mobile application development using MOBL, a domain-specific language for building mobile web applications. It provides examples of building user interfaces, adding scripting capabilities, modeling and querying data, and integrating with native device APIs like geolocation using higher-order controls. Future directions are mentioned like adaptive UIs, offline support, and hybrid web/native applications. Code samples demonstrate creating a tip calculator, scripting functions, modeling task data, and accessing local storage on a device.
The document describes MOBL, a programming language for building mobile web applications. MOBL aims to provide a small core language with large and extensible libraries. It includes built-in types, controls, and abstraction mechanisms like screens and functions. The language exposes low-level primitives while providing a native interface to external APIs. MOBL code can be deployed by concatenating, eliminating dead code, and minifying for client-side execution on mobile browsers. The language has been publicly released since January 2011 and sees over 1,000 visitors per day, with ongoing development focused on error handling, data evolution, documentation and libraries.
The Ring programming language version 1.3 book - Part 34 of 88Mahmoud Samir Fayed
This document contains code from the datalib.ring library that defines classes for database connectivity and model-view-controller implementation in Ring.
The Database class handles database connections and queries. The ModelBase class extends Database and adds methods for CRUD operations on a model object. It determines the table name from the class name.
The ControllerBase class is the base class for controllers. It dynamically creates the view and model objects based on the controller class name. It also contains routing logic and pagination methods. These classes provide a framework for building MVC applications with Ring and connecting to a database.
The document provides information about various Corona display, audio, physics, and storyboard APIs:
1) It summarizes the display.newText, display.newImage, display.newRect, display.newCircle, and display.newGroup functions for creating and manipulating display objects.
2) It covers the basics of touch handling using object:addEventListener and provides an example listener function.
3) It describes timer functions like timer.performWithDelay, timer.pause, and timer.resume for delayed execution of functions.
4) It gives an overview of the audio API and provides an example of loading and playing sounds.
5) It introduces the Corona physics module and
The document discusses RxSwift, which is a library for reactive programming with Swift. It combines ReactiveX with Swift by providing Observables and Observers. Observables allow data streams to be observed and manipulated through operators like map, filter, etc. The document provides examples of using RxSwift to validate a password field by observing text changes and mapping valid/invalid states to display feedback. It also shows an example of observing a nickname field to call an API on valid input. Overall, the document introduces the key concepts of RxSwift like Observables, Observers, operators, and provides examples of validating user input fields reactively.
Fabric.js is a JavaScript canvas library that simplifies canvas rendering and provides an interactive object model for canvas elements. It allows creating and manipulating canvas elements and objects in a more simplified way compared to using the native canvas API. The library provides features like animation, events, SVG parsing, text rendering, and supports multiple browsers. Future plans include reducing the library size, improving documentation, and adding touch support.
The Ring programming language version 1.5.2 book - Part 29 of 181Mahmoud Samir Fayed
The document discusses object-oriented programming in Ring. It shows how to define classes and create objects. Classes contain attributes and methods, and objects are instances of classes that can access attributes and call methods using braces or dot notation. Default values can be set for class attributes. Printing, inheritance, private members, and other OOP concepts are also covered.
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...Matthew Tovbin
Spark + AI Summit, 2019 - Mastering complex software stacks, such as Spark or Hadoop, is a challenging process. Incompatible dependencies, new programming paradigms, runtime errors, outdated documentation, scaling, tuning - this is just a short list of skills we must acquire. How do we make sure that we are not wasting time and making progress learning? How do we share our knowledge efficiently? This talk walks you through a journey of scaling Salesforce Einstein AI platform to serve 6B+ predictions per day and provides you with a scale to measure learning progress.
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...Databricks
Mastering complex software stacks, such as Spark or Hadoop, is a challenging process. Incompatible dependencies, new programming paradigms, runtime errors, outdated documentation, scaling, tuning - this is just a short list of skills we must acquire. How do we make sure that we are not wasting time and making progress learning? How do we share our knowledge efficiently? This talk walks you through a journey of scaling Salesforce Einstein AI platform to serve 3B+ predictions per day and provides you with a scale to measure learning progress.
Speaker: Matthew Tovbin
famo.us is a JavaScript framework for building user interfaces using a reactive programming model. It provides building blocks like surfaces, contexts and engines to construct animatable UI elements in a render tree. Key concepts include moveable surfaces that can be transformed, laid out and animated. Custom layouts and views can be created by extending base classes and composing surfaces together in a render tree managed by the engine.
The Ring programming language version 1.9 book - Part 52 of 210Mahmoud Samir Fayed
This document describes how to implement user registration, login, and CRUD functionality in Ring using MVC patterns and database integration. It defines model, view, and controller classes for users that interact with a database table. Code examples are provided for registration and login forms, form validation, hashing passwords, and setting login sessions. The CRUD functionality is demonstrated using model, view, and controller classes defined in a datalib library.
Data in Motion: Streaming Static Data EfficientlyMartin Zapletal
Distributed streaming performance, consistency, reliable delivery, durability, optimisations, event time processing and other concepts discussed and explained on Akka Persistence and other examples.
The Ring programming language version 1.5.2 book - Part 43 of 181Mahmoud Samir Fayed
This document discusses Ring code for implementing CRUD (create, read, update, delete) functionality using an MVC (model-view-controller) pattern. It includes code for classes that represent a Salary model, controller, and view. It also includes code for classes that handle user registration and login functionality, including models, views, controllers, and language files. The document provides code examples for connecting to a database, implementing base model and controller classes, and performing common database operations like searching, counting, inserting, updating, and finding records.
The document discusses Java and the benefits of Groovy compared to Java. It covers boilerplate code and ceremony in Java that can be reduced using Groovy. Examples are provided demonstrating Groovy's syntax for primitives, collections like lists and maps, closures, IO operations, XML processing, and a DSL. The document recommends Groovy for its duck typing, operators, and safe navigation operator to avoid null pointer exceptions.
This document contains code for a sales system application in Visual Basic. It includes code for forms to manage clients, products, invoices and users. It allows adding, editing, deleting and searching records in databases. It also includes code to launch other applications like Word, Excel and Calculator from the main form.
The Ring programming language version 1.10 book - Part 54 of 212Mahmoud Samir Fayed
This document describes code related to user registration and login functionality in Ring. It includes code for a registration form, login form, user registration logic, login validation, and checking if a user is logged in. Database and model classes are also shown that handle connecting to the database, querying for users, and managing user data.
Async code on kotlin: rx java or/and coroutines - Kotlin Night TurinFabio Collini
It’s never easy to write async code but luckily there are many libraries to manage asynchronicity without adding too much complexity. In the last years RxJava and the other ReactiveX libraries have been very popular but lately there is a new way to manage async code in Kotlin: the coroutines. In this talk we’ll pros and cons of there two approaches and how to leverage them to simplify asynchronous code on Android.
Do they solve the same problem? Can we use them together? Which one can be used to write functional code? How can we use them effectively in Android development?
Spoiler alert: They are both great!
In this talk we’ll see how to solve common problems using RxJava or Coroutines, starting from basic concepts (for example the Retrofit support and how to cancel a task) to some more advanced (like threading, error management and how to combine multiple tasks).
All example of the talk are available on this repository:
https://github.com/fabioCollini/RxJavaVsCoroutines
The Ring programming language version 1.6 book - Part 46 of 189Mahmoud Samir Fayed
This document summarizes code from the Ring documentation related to user registration, login, and database classes. It describes classes for users, models, views, controllers, and languages that allow for user registration, login, form views, and routing. It also summarizes the Database, ModelBase, and ControllerBase classes that provide functionality for connecting to databases, executing queries, and managing model data.
Functional programming avoids changing-state and mutable data. Referential transparency means expressions can be replaced without affecting observable behavior. Pure functions only depend on argument values and have no other effects. Case classes provide functionality like equals, hashCode and pattern matching out of the box. Futures allow running blocking operations asynchronously and chaining results with map, flatMap and for comprehensions. Implicits allow type conversions and providing parameters implicitly. Sealed classes allow exhaustive pattern matching of a type hierarchy.
The Ring programming language version 1.5.3 book - Part 44 of 184Mahmoud Samir Fayed
This document provides code examples for classes used in a web application framework in Ring. It includes the Database, ModelBase, and ControllerBase classes which handle database connectivity and operations. It also includes an overview of the WebLib API which provides functions and classes for generating HTML pages and elements. Some key classes described are Page, Form, Table, and classes to generate specific HTML elements like Div, Link, Image etc.
mobl: Een DSL voor mobiele applicatieontwikkelingDevnology
This document discusses mobile application development using MOBL, a domain-specific language for building mobile web applications. It provides examples of building user interfaces, adding scripting capabilities, modeling and querying data, and integrating with native device APIs like geolocation using higher-order controls. Future directions are mentioned like adaptive UIs, offline support, and hybrid web/native applications. Code samples demonstrate creating a tip calculator, scripting functions, modeling task data, and accessing local storage on a device.
The document describes MOBL, a programming language for building mobile web applications. MOBL aims to provide a small core language with large and extensible libraries. It includes built-in types, controls, and abstraction mechanisms like screens and functions. The language exposes low-level primitives while providing a native interface to external APIs. MOBL code can be deployed by concatenating, eliminating dead code, and minifying for client-side execution on mobile browsers. The language has been publicly released since January 2011 and sees over 1,000 visitors per day, with ongoing development focused on error handling, data evolution, documentation and libraries.
The Ring programming language version 1.3 book - Part 34 of 88Mahmoud Samir Fayed
This document contains code from the datalib.ring library that defines classes for database connectivity and model-view-controller implementation in Ring.
The Database class handles database connections and queries. The ModelBase class extends Database and adds methods for CRUD operations on a model object. It determines the table name from the class name.
The ControllerBase class is the base class for controllers. It dynamically creates the view and model objects based on the controller class name. It also contains routing logic and pagination methods. These classes provide a framework for building MVC applications with Ring and connecting to a database.
The document provides information about various Corona display, audio, physics, and storyboard APIs:
1) It summarizes the display.newText, display.newImage, display.newRect, display.newCircle, and display.newGroup functions for creating and manipulating display objects.
2) It covers the basics of touch handling using object:addEventListener and provides an example listener function.
3) It describes timer functions like timer.performWithDelay, timer.pause, and timer.resume for delayed execution of functions.
4) It gives an overview of the audio API and provides an example of loading and playing sounds.
5) It introduces the Corona physics module and
The document discusses RxSwift, which is a library for reactive programming with Swift. It combines ReactiveX with Swift by providing Observables and Observers. Observables allow data streams to be observed and manipulated through operators like map, filter, etc. The document provides examples of using RxSwift to validate a password field by observing text changes and mapping valid/invalid states to display feedback. It also shows an example of observing a nickname field to call an API on valid input. Overall, the document introduces the key concepts of RxSwift like Observables, Observers, operators, and provides examples of validating user input fields reactively.
Fabric.js is a JavaScript canvas library that simplifies canvas rendering and provides an interactive object model for canvas elements. It allows creating and manipulating canvas elements and objects in a more simplified way compared to using the native canvas API. The library provides features like animation, events, SVG parsing, text rendering, and supports multiple browsers. Future plans include reducing the library size, improving documentation, and adding touch support.
The Ring programming language version 1.5.2 book - Part 29 of 181Mahmoud Samir Fayed
The document discusses object-oriented programming in Ring. It shows how to define classes and create objects. Classes contain attributes and methods, and objects are instances of classes that can access attributes and call methods using braces or dot notation. Default values can be set for class attributes. Printing, inheritance, private members, and other OOP concepts are also covered.
The Rule of 10,000 Spark Jobs - Learning from Exceptions and Serializing Your...Matthew Tovbin
Spark + AI Summit, 2019 - Mastering complex software stacks, such as Spark or Hadoop, is a challenging process. Incompatible dependencies, new programming paradigms, runtime errors, outdated documentation, scaling, tuning - this is just a short list of skills we must acquire. How do we make sure that we are not wasting time and making progress learning? How do we share our knowledge efficiently? This talk walks you through a journey of scaling Salesforce Einstein AI platform to serve 6B+ predictions per day and provides you with a scale to measure learning progress.
The Rule of 10,000 Spark Jobs: Learning From Exceptions and Serializing Your ...Databricks
Mastering complex software stacks, such as Spark or Hadoop, is a challenging process. Incompatible dependencies, new programming paradigms, runtime errors, outdated documentation, scaling, tuning - this is just a short list of skills we must acquire. How do we make sure that we are not wasting time and making progress learning? How do we share our knowledge efficiently? This talk walks you through a journey of scaling Salesforce Einstein AI platform to serve 3B+ predictions per day and provides you with a scale to measure learning progress.
Speaker: Matthew Tovbin
famo.us is a JavaScript framework for building user interfaces using a reactive programming model. It provides building blocks like surfaces, contexts and engines to construct animatable UI elements in a render tree. Key concepts include moveable surfaces that can be transformed, laid out and animated. Custom layouts and views can be created by extending base classes and composing surfaces together in a render tree managed by the engine.
The Ring programming language version 1.9 book - Part 52 of 210Mahmoud Samir Fayed
This document describes how to implement user registration, login, and CRUD functionality in Ring using MVC patterns and database integration. It defines model, view, and controller classes for users that interact with a database table. Code examples are provided for registration and login forms, form validation, hashing passwords, and setting login sessions. The CRUD functionality is demonstrated using model, view, and controller classes defined in a datalib library.
Data in Motion: Streaming Static Data EfficientlyMartin Zapletal
Distributed streaming performance, consistency, reliable delivery, durability, optimisations, event time processing and other concepts discussed and explained on Akka Persistence and other examples.
Flink Forward San Francisco 2018: Seth Wiesman - "Testing Stateful Streaming ...Flink Forward
As more workloads migrate from batch to stream processing there is ever increasing demand on streaming applications to operate based on more complex business rules. Apache Flink provides many high and low level api’s for writing a wide breadth of stateful streaming applications. However, as applications get more complex they can become harder to understand and debug. This talk will discuss best practices for writing well tested streaming applications with an eye towards working with stateful operators and validating against failure. We will do this by walking through the world’s most thoroughly tested implementation of word count.
This document describes a reactive platform architecture designed for scalability. It advocates for a shift in priorities from consistency to availability to enable responsiveness under load. The architecture uses microservices and serverless functions to improve scalability but notes serverless is not yet good for managing state. It also discusses challenges around infrastructure complexity and operational costs that increase with microservices compared to monolithic architectures.
The Ring programming language version 1.7 book - Part 16 of 196Mahmoud Samir Fayed
This document summarizes the new features and changes in Ring 1.2, including new functions like PtrCmp() and PrevFileName(), improved functions like find() supporting C pointers, an improved Ring Notepad that saves line numbers, better RingQt classes with event handling, a new Objects library for RingQt, an enhanced RingLibCurl library, improved call command support, using NULL instead of NULLPointer(), a new display warnings option, and general quality improvements.
The Ring programming language version 1.6 book - Part 15 of 189Mahmoud Samir Fayed
The document summarizes the new features and changes in Ring 1.2, including:
1. New functions like PtrCmp(), PrevFileName(), and functions to retrieve lists of functions, classes, packages, etc.
2. Improved existing functions like find() and type() to support C pointers.
3. Enhancements to Ring Notepad and RingQt like line number restoration and event handling.
4. The introduction of an Objects library for RingQt and better support for the MVC pattern.
5. The RingLibCurl library providing an API for the libcurl functions.
6. Updates to call handling and allowing NULL instead of NULLPointer().
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
The document discusses Scala and functional programming concepts. It provides examples of building a chat application in 30 lines of code using Lift, defining messages as case classes, and implementing a chat server and comet component. It then summarizes that Scala is a pragmatically-oriented, statically typed language that runs on the JVM and provides a unique blend of object-oriented and functional programming. Traits allow for code reuse and multiple class inheritances. Functional programming concepts like immutable data structures, higher-order functions, and for-comprehensions are discussed.
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
The document discusses Scala and functional programming concepts. It provides examples of building a chat application in 30 lines of code using Lift, defining case classes and actors for messages. It summarizes that Scala is a pragmatically oriented, statically typed language that runs on the JVM and has a unique blend of object-oriented and functional programming. Functional programming concepts like immutable data structures, functions as first-class values, and for-comprehensions are demonstrated with examples in Scala.
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
This document discusses Scala and its features. It provides an example of building a chat application in 30 lines of code using Lift framework. It also demonstrates pattern matching, functional data structures like lists and tuples, for comprehensions, and common Scala tools and frameworks. The document promotes Scala as a pragmatic and scalable language that blends object-oriented and functional programming. It encourages learning more about Scala.
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
The document discusses Scala and functional programming concepts. It provides examples of building a chat application in 30 lines of code using Lift, defining messages as case classes, and implementing a chat server and comet component. It then summarizes that Scala is a pragmatically-oriented, statically typed language that runs on the JVM and provides a unique blend of object-oriented and functional programming. Traits allow for static and dynamic mixin-based composition. Functional programming concepts like immutable data structures, higher-order functions, and for-comprehensions are discussed.
Programiści aplikacji Mobilnych na Androida, uwięzieni w czasach Java 1.7 od pewnego czasu eksperymentowali z innymi językami programowania. Żaden nie zdobył do tej pory takiej popularności jak Kotlin. Ale czy faktycznie jest to coś rewolucyjnego? Przecież getery, settery i konstruktory wygenerujemy za pomocą Lomboka. Używając Retrolamby zyskamy wsparcie dla dopełnień. A dodatkowo od niedawna Android ma wsparcie dla Javy 8.
Zatem co decyduje o sile Kotlina, które konstrukcje i właściwości języka powodują, że warto zastosować go w swoim projekcie? Jaki wpływ będzie to miało na architekturę aplikacji i wydajność? Kotlin jest tylko ciekawostką czy spowoduje, że będziesz kodował efektywniej? Z tej prezentacji wyniesiesz pełen zestaw informacji pozwalający odpowiedzieć na wszystkie te pytania.
The document discusses React hooks and how they can be used to manage state and other features in function components without writing classes. It provides examples of how common lifecycle methods and state management in classes can be re-written using hooks like useState, useEffect, and useContext. Specifically, it walks through converting a chat component that subscribes to new messages and manages local state from a class to a function component using these React hooks.
This document discusses the key concepts in KnockoutJS including observables, bindings, utilities, data features, and plugins. It provides code examples for creating observables and computed values, using built-in and custom bindings, and leveraging utilities and the mapping plugin. Resources for learning more about KnockoutJS are also listed.
Kotlin is something more than just tool that help you remove boilerplate from you code. It brings much more than just lamdas and handy syntax to your Java or Android project
The document describes an implementation of the Model-View-Intent (MVI) architecture pattern for Android applications. It explains the key components of MVI - the Intent, Model, and View. The Intent interprets user interactions and outputs actions. The Model manages application state from actions and outputs state changes. The View renders state. It then provides code examples of an Android drawing app implemented using MVI, including classes for the Intent, Model, View, and drawing state data.
This document contains code snippets and explanations related to WPF concepts like graphics, binding, animation, positioning, templates and data binding. It discusses using panels like Canvas to position shapes, binding data to controls, creating item templates for ListView, and provides a complete example of an app using binding, templates and XML to display Twitter data in a ListBox.
The Ring programming language version 1.5.3 book - Part 70 of 184Mahmoud Samir Fayed
The document describes a GraphicsAppBase class that provides functionality for creating graphics applications using the Allegro graphics library. The class initializes Allegro, creates a display, event queue, timer and handles events in a loop. It also defines constants for screen dimensions, keys and mouse handling. Methods are provided for setup, drawing, resource loading/unloading and cleanup.
Scala Swing is a thin wrapper around Java's Swing GUI framework that aims to simplify it. It uses Scala features like case classes for events, partial functions for event handling, and integrates with Scala collections. This allows building GUI components like panels, buttons, and list views with less verbose code compared to plain Java Swing. Custom painting and mixing in traits also allows flexibility in building component appearances.
Goal Based Data Production with Sim SimeonovDatabricks
Since the invention of SQL and relational databases, data production has been about specifying how data should be transformed through queries. While Apache Spark can certainly be used as a general distributed SQL-like query engine, the power and granularity of Spark’s APIs allows for a fundamentally different, and far more productive, approach. This session will introduce the principles of goal-based data production with examples ranging from ETL, to exploratory data analysis, to feature engineering for machine learning.
Goal-based data production concerns itself with specifying WHAT the desired result is, leaving the details of HOW the result is achieved to the smart data warehouse running on top of Spark. That not only substantially increases productivity, but also significantly expands the audience that can work directly with Spark: from developers and data scientists to technical business users. With specific data and architecture patterns and live demos, this session will demonstrate how easy it is for any company to create its own smart data warehouse with Spark 2.x and gain the benefits of goal-based data production.
Similar to Functional programming techniques in real-world microservices (20)
SOCRadar's Aviation Industry Q1 Incident Report is out now!
The aviation industry has always been a prime target for cybercriminals due to its critical infrastructure and high stakes. In the first quarter of 2024, the sector faced an alarming surge in cybersecurity threats, revealing its vulnerabilities and the relentless sophistication of cyber attackers.
SOCRadar’s Aviation Industry, Quarterly Incident Report, provides an in-depth analysis of these threats, detected and examined through our extensive monitoring of hacker forums, Telegram channels, and dark web platforms.
Launch Your Streaming Platforms in MinutesRoshan Dwivedi
The claim of launching a streaming platform in minutes might be a bit of an exaggeration, but there are services that can significantly streamline the process. Here's a breakdown:
Pros of Speedy Streaming Platform Launch Services:
No coding required: These services often use drag-and-drop interfaces or pre-built templates, eliminating the need for programming knowledge.
Faster setup: Compared to building from scratch, these platforms can get you up and running much quicker.
All-in-one solutions: Many services offer features like content management systems (CMS), video players, and monetization tools, reducing the need for multiple integrations.
Things to Consider:
Limited customization: These platforms may offer less flexibility in design and functionality compared to custom-built solutions.
Scalability: As your audience grows, you might need to upgrade to a more robust platform or encounter limitations with the "quick launch" option.
Features: Carefully evaluate which features are included and if they meet your specific needs (e.g., live streaming, subscription options).
Examples of Services for Launching Streaming Platforms:
Muvi [muvi com]
Uscreen [usencreen tv]
Alternatives to Consider:
Existing Streaming platforms: Platforms like YouTube or Twitch might be suitable for basic streaming needs, though monetization options might be limited.
Custom Development: While more time-consuming, custom development offers the most control and flexibility for your platform.
Overall, launching a streaming platform in minutes might not be entirely realistic, but these services can significantly speed up the process compared to building from scratch. Carefully consider your needs and budget when choosing the best option for you.
Code reviews are vital for ensuring good code quality. They serve as one of our last lines of defense against bugs and subpar code reaching production.
Yet, they often turn into annoying tasks riddled with frustration, hostility, unclear feedback and lack of standards. How can we improve this crucial process?
In this session we will cover:
- The Art of Effective Code Reviews
- Streamlining the Review Process
- Elevating Reviews with Automated Tools
By the end of this presentation, you'll have the knowledge on how to organize and improve your code review proces
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j
Dr. Jesús Barrasa, Head of Solutions Architecture for EMEA, Neo4j
Découvrez les dernières innovations de Neo4j, et notamment les dernières intégrations cloud et les améliorations produits qui font de Neo4j un choix essentiel pour les développeurs qui créent des applications avec des données interconnectées et de l’IA générative.
Hand Rolled Applicative User ValidationCode KataPhilip Schwarz
Could you use a simple piece of Scala validation code (granted, a very simplistic one too!) that you can rewrite, now and again, to refresh your basic understanding of Applicative operators <*>, <*, *>?
The goal is not to write perfect code showcasing validation, but rather, to provide a small, rough-and ready exercise to reinforce your muscle-memory.
Despite its grandiose-sounding title, this deck consists of just three slides showing the Scala 3 code to be rewritten whenever the details of the operators begin to fade away.
The code is my rough and ready translation of a Haskell user-validation program found in a book called Finding Success (and Failure) in Haskell - Fall in love with applicative functors.
AI Pilot Review: The World’s First Virtual Assistant Marketing SuiteGoogle
AI Pilot Review: The World’s First Virtual Assistant Marketing Suite
👉👉 Click Here To Get More Info 👇👇
https://sumonreview.com/ai-pilot-review/
AI Pilot Review: Key Features
✅Deploy AI expert bots in Any Niche With Just A Click
✅With one keyword, generate complete funnels, websites, landing pages, and more.
✅More than 85 AI features are included in the AI pilot.
✅No setup or configuration; use your voice (like Siri) to do whatever you want.
✅You Can Use AI Pilot To Create your version of AI Pilot And Charge People For It…
✅ZERO Manual Work With AI Pilot. Never write, Design, Or Code Again.
✅ZERO Limits On Features Or Usages
✅Use Our AI-powered Traffic To Get Hundreds Of Customers
✅No Complicated Setup: Get Up And Running In 2 Minutes
✅99.99% Up-Time Guaranteed
✅30 Days Money-Back Guarantee
✅ZERO Upfront Cost
See My Other Reviews Article:
(1) TubeTrivia AI Review: https://sumonreview.com/tubetrivia-ai-review
(2) SocioWave Review: https://sumonreview.com/sociowave-review
(3) AI Partner & Profit Review: https://sumonreview.com/ai-partner-profit-review
(4) AI Ebook Suite Review: https://sumonreview.com/ai-ebook-suite-review
Mobile App Development Company In Noida | Drona InfotechDrona Infotech
Looking for a reliable mobile app development company in Noida? Look no further than Drona Infotech. We specialize in creating customized apps for your business needs.
Visit Us For : https://www.dronainfotech.com/mobile-application-development/
Neo4j - Product Vision and Knowledge Graphs - GraphSummit ParisNeo4j
Dr. Jesús Barrasa, Head of Solutions Architecture for EMEA, Neo4j
Découvrez les dernières innovations de Neo4j, et notamment les dernières intégrations cloud et les améliorations produits qui font de Neo4j un choix essentiel pour les développeurs qui créent des applications avec des données interconnectées et de l’IA générative.
WhatsApp offers simple, reliable, and private messaging and calling services for free worldwide. With end-to-end encryption, your personal messages and calls are secure, ensuring only you and the recipient can access them. Enjoy voice and video calls to stay connected with loved ones or colleagues. Express yourself using stickers, GIFs, or by sharing moments on Status. WhatsApp Business enables global customer outreach, facilitating sales growth and relationship building through showcasing products and services. Stay connected effortlessly with group chats for planning outings with friends or staying updated on family conversations.
What is Augmented Reality Image Trackingpavan998932
Augmented Reality (AR) Image Tracking is a technology that enables AR applications to recognize and track images in the real world, overlaying digital content onto them. This enhances the user's interaction with their environment by providing additional information and interactive elements directly tied to physical images.
Introducing Crescat - Event Management Software for Venues, Festivals and Eve...Crescat
Crescat is industry-trusted event management software, built by event professionals for event professionals. Founded in 2017, we have three key products tailored for the live event industry.
Crescat Event for concert promoters and event agencies. Crescat Venue for music venues, conference centers, wedding venues, concert halls and more. And Crescat Festival for festivals, conferences and complex events.
With a wide range of popular features such as event scheduling, shift management, volunteer and crew coordination, artist booking and much more, Crescat is designed for customisation and ease-of-use.
Over 125,000 events have been planned in Crescat and with hundreds of customers of all shapes and sizes, from boutique event agencies through to international concert promoters, Crescat is rigged for success. What's more, we highly value feedback from our users and we are constantly improving our software with updates, new features and improvements.
If you plan events, run a venue or produce festivals and you're looking for ways to make your life easier, then we have a solution for you. Try our software for free or schedule a no-obligation demo with one of our product specialists today at crescat.io
GraphSummit Paris - The art of the possible with Graph TechnologyNeo4j
Sudhir Hasbe, Chief Product Officer, Neo4j
Join us as we explore breakthrough innovations enabled by interconnected data and AI. Discover firsthand how organizations use relationships in data to uncover contextual insights and solve our most pressing challenges – from optimizing supply chains, detecting fraud, and improving customer experiences to accelerating drug discoveries.
Takashi Kobayashi and Hironori Washizaki, "SWEBOK Guide and Future of SE Education," First International Symposium on the Future of Software Engineering (FUSE), June 3-6, 2024, Okinawa, Japan
Do you want Software for your Business? Visit Deuglo
Deuglo has top Software Developers in India. They are experts in software development and help design and create custom Software solutions.
Deuglo follows seven steps methods for delivering their services to their customers. They called it the Software development life cycle process (SDLC).
Requirement — Collecting the Requirements is the first Phase in the SSLC process.
Feasibility Study — after completing the requirement process they move to the design phase.
Design — in this phase, they start designing the software.
Coding — when designing is completed, the developers start coding for the software.
Testing — in this phase when the coding of the software is done the testing team will start testing.
Installation — after completion of testing, the application opens to the live server and launches!
Maintenance — after completing the software development, customers start using the software.
Graspan: A Big Data System for Big Code AnalysisAftab Hussain
We built a disk-based parallel graph system, Graspan, that uses a novel edge-pair centric computation model to compute dynamic transitive closures on very large program graphs.
We implement context-sensitive pointer/alias and dataflow analyses on Graspan. An evaluation of these analyses on large codebases such as Linux shows that their Graspan implementations scale to millions of lines of code and are much simpler than their original implementations.
These analyses were used to augment the existing checkers; these augmented checkers found 132 new NULL pointer bugs and 1308 unnecessary NULL tests in Linux 4.4.0-rc5, PostgreSQL 8.3.9, and Apache httpd 2.2.18.
- Accepted in ASPLOS ‘17, Xi’an, China.
- Featured in the tutorial, Systemized Program Analyses: A Big Data Perspective on Static Analysis Scalability, ASPLOS ‘17.
- Invited for presentation at SoCal PLS ‘16.
- Invited for poster presentation at PLDI SRC ‘16.
15. Immutable domain entities
Always creating a copy:
val campaignWithName = campaign.copy(
name = "Abandoned Shopping Cart Campaign”
)
16. Copyception
… and we have only updated ONE campaign
contactProfile.copy(
lastEvents = contactProfile.lastEvents.copy(
send = contactProfile.lastEvents.send.copy(
campaign = replaceCampaignWithName(campaignNames)
(contactProfile.lastEvents.send.campaign)
)
)
)
17. Lens
Type of the object to update is O
Type of the field to update is V
case class Lens[O, V] (
get: O => V,
set: (O, V) => O
)
18. Example lens instance
val campaignNameLens = Lens[Campaign, String](
get = _.name,
set = (campaign, name) => campaign.copy(name = name)
)
val campaign = Campaign(id = 1, name = "old name")
campaignNameLens.set(campaign, "new name")
// Campaign(1, "new name")
24. val clickCampaignLens =
lens[ContactProfile]
>> 'lastEvents
>> 'click
>> ‘campaign
val lastPurchaseLens =
lens[ContactProfile]
>> 'purchases
>> ‘last
Solving the problem
Define lenses using shapeless
25. def modifyBy(lens: Lens[ContactProfile, Campaign]) =
(contactProfile: ContactProfile) =>
lens.modify(contactProfile)
(replaceCampaignWithName(campaignNames))
val contactProfileWithCampaignNames =
(
modifyBy(clickCampaignLens) andThen
modifyBy(lastPurchaseLens)
)(contactProfile)
Solving the problem
26.
27. How can I convert between a third
party library’s representation and
my case classes in a generic way?
Question 2
28.
29. def executeQuery(query: Query): Future[List[TableRow]] =
{
queryResult(query).map { result =>
if (result.getTotalRows.equals(BigInteger.ZERO)) {
List.empty[TableRow]
} else {
result.getRows.asScala.toList
}
}
}
Google BigQuery API
Running a query job in BigQuery results
in a list of TableRow objects
30. case class ClickEvent(campaignId: Int, eventTime: DateTime,
deviceName: String, customerId: Int, messageId: Int)
def loadClicks(contact: Contact): Future[List[ClickEvent]] = {
executeQuery(createQuery).map(_.map(
tableRow => {
val cells = tableRow.getF
ClickEvent(
campaignId = cells.get(0).getV.toString.toInt
eventTime = new DateTime(cells.get(1).getV.toString.toLong),
deviceName = cells.get(1).getV.toString
)
}
))
}
TableRow - model
We would like to work with our models
34. trait BigQueryFormat[T] {
def fromTableRow(tableRow: TableRow): T
}
implicit val clickEventFormat = new BigQueryFormat[ClickEvent] {
def fromTableRow(tableRow: TableRow) = {
val cells = tableRow.getF
ClickEvent(
campaignId = cells.get(0).getV.toString.toInt,
eventTime = new DateTime(cells.get(1).getV.toString.toLong),
deviceName = cells.get(2).getV.toString
)
}
}
BigQueryFormat type class
BigQueryFormat trait and one simplified
concrete instance for ClickEvent
35. object syntax {
implicit class RichTableRow(val row: TableRow)
extends AnyVal {
def as[T]
(implicit format: BigQueryFormat[T]): T =
format.fromTableRow(row)
}
}
Syntax
Add ‘as’ function to TableRow
36. "create ClickEvent case class from TableRow" in {
val tableRow = new TableRow()
val now = DateTime.now
tableRow.setF(List[TableCell](
new TableCell().setV(1),
new TableCell().setV(now.getMillis),
new TableCell().setV("iPhone")
).asJava)
tableRow.as[ClickEvent] shouldEqual
ClickEvent(1, now, "iPhone")
}
Test it!
Convert a test TableRow to a case class
with our syntax: ’as’
43. implicit object hNilBigQueryFormat
extends BigQueryFormat[HNil] {
def fromTableRow(m: TableRow) = HNil
}
BigQueryFormat for HList
Convert to the members of the HList
recursively, ultimately to HNil
44. implicit def hListBigQueryFormat[Head, Tail <: HList](
implicit valueFormatter: BigQueryValue[Head],
tailFormatter: BigQueryFormat[Tail]
): BigQueryFormat[Head :: Tail] = {
new BigQueryFormat[Head :: Tail] {
def fromTableRow(tableRow: TableRow) = {
val tableCells = tableRow.getF.toList
val cellValue = tableCells.head.getV
val resolvedValue = valueFormatter.fromValue(cellValue)
tableRow.setF(tableCells.tail.asJava)
val tail = tailFormatter.fromTableRow(tableRow)
resolvedValue :: tail
}
}
}
BigQueryFormat for HList
But what about HList?
45. implicit def hListBigQueryFormat[Head, Tail <: HList](
implicit valueFormatter: BigQueryValue[Head],
tailFormatter: BigQueryFormat[Tail]
): BigQueryFormat[Head :: Tail] = {
new BigQueryFormat[Head :: Tail] {
def fromTableRow(tableRow: TableRow) = {
val tableCells = tableRow.getF.toList
val cellValue = tableCells.head.getV
val resolvedValue = valueFormatter.fromValue(cellValue)
tableRow.setF(tableCells.tail.asJava)
val tail = tailFormatter.fromTableRow(tableRow)
resolvedValue :: tail
}
}
}
BigQueryFormat for HList
46. implicit def hListBigQueryFormat[Head, Tail <: HList](
implicit valueFormatter: BigQueryValue[Head],
tailFormatter: BigQueryFormat[Tail]
): BigQueryFormat[Head :: Tail] = {
new BigQueryFormat[Head :: Tail] {
def fromTableRow(tableRow: TableRow) = {
val tableCells = tableRow.getF.toList
val cellValue = tableCells.head.getV
val resolvedValue = valueFormatter.fromValue(cellValue)
tableRow.setF(tableCells.tail.asJava)
val tail = tailFormatter.fromTableRow(tableRow)
resolvedValue :: tail
}
}
}
BigQueryFormat for HList
What is happening?
47. Generic BigQueryFormat
Generic type class instance
BigQueryFormat for generic
representation
Create HList representation
Convert to expected type
48. Generic BigQueryFormat
implicit def genericBigQueryFormat[T, Repr](
implicit gen: Generic.Aux[T, Repr],
reprFormatter: BigQueryFormat[Repr]
): BigQueryFormat[T] = {
new BigQueryFormat[T] {
def fromTableRow(tableRow: TableRow) = {
val repr = reprFormatter.fromTableRow(tableRow)
gen.from(repr)
}
}
}
What is Aux?
49. Nice job!
We can remove all the concrete type
class instances for our model classes!
51. Our library is open source!
https://github.com/emartech/
googlecloud-shapeless
Contribution is welcome!
52.
53. How can I write pure functions
if I have to do a bunch of IO
operations?
Question 3
54.
55. Overview
Microservices do a lot of API calls
There is a data store involved in most
cases
An IO operation depends on the result
of another IO operation
59. Issues with this approach
Hard to unit test
Dependency management
complications
Business logic & the environment
Future on the interface
Future in function body
63. Instance for Future
object ClientInstance {
implicit val suiteClientInstance = new RestIO[Future]
{
val contactApiClient = ContactFieldApi()
def listFields(customerId: Int)
: Future[List[FieldItem]] =
contactApiClient.list(customerId).map(_.data)
def createField(payload: CreateFieldRequest)
: Future[CreateFieldResponse] =
contactApiClient.createField(customerId, payload)
}
}
64. Changes in client code
[error] value map is not a member of type parameter F[List[FieldItem]]
import RestIO.syntax._
def create[F[_]: RestIO](
customerId: Int,
fieldsToUse: List[ContactField]
): F[List[FieldItem]] = {
for {
existingFields <- listFields(customerId)
fieldRequests = FieldPayload.create(existingFields, fieldsToUse)
newFields <- createNewFields(fieldRequests)
} yield newFields
}
The interface is generic for the type class
Client class dependency is removed
65. Does it work?
[error] value map is not a member of type parameter F[List[FieldItem]]
import RestIO.syntax._
def create[F[_]: RestIO](
customerId: Int,
fieldsToUse: List[ContactField]
): F[List[FieldItem]] = {
for {
existingFields <- listFields(customerId)
fieldRequests = FieldPayload.create(existingFields, fieldsToUse)
newFields <- createNewFields(fieldRequests)
} yield newFields
}
66. Monad to the rescue!
[error] value map is not a member of type parameter F[List[FieldItem]]
import cats._
import RestIO.syntax._
def create[F[_]: RestIO: Monad](
customerId: Int,
fieldsToUse: List[ContactField]
): F[List[FieldItem]] = {
for {
existingFields <- listFields(customerId)
fieldRequests =
FieldPayload.create(existingFields, fieldsToUse)
newFields <- createNewFields(fieldRequests)
} yield newFields
}
Let’s use cats!
67. Changes in client code
[error] value map is not a member of type parameter F[List[FieldItem]]
private def createNewFields[F[_]: RestIO: Monad](
customerId: Int,
fieldRequests: List[CreateFieldRequest]
): F[List[FieldItem]] = {
fieldRequests.map(request => {
createField(request)
.map(createFieldItem(request))
}).sequence
}
Got rid of Future.sequence