Introduction to Functional Programming and usage of basic constructs in Java 7 using Guava.
Further, the session introduces Reactive Systems architecture and design.
The idea of this talk is presenting the Golang functional features, the pros e cons of apply functional paradigm in Golang. Do you want to improve readability and maintainability of your code using more functional paradigms? So, come on and let's have a fun time together!
Debugging and Profiling C++ Template MetaprogramsPlatonov Sergey
Â
Template metaprogramming is an emerging new direction in C++ programming for executing algorithms in compilation time. Despite all of its already proven benefits and numerous successful applications, it is yet to be accepted in industrial projects. One reason is the lack of professional software tools supporting the development of template metaprograms. A strong analogue exists between traditional runtime programs and compile-time metaprograms. This connection presents the possibility for creating development tools similar to those already used when writing runtime programs. This paper introduces Templight, a debugging framework that reveals the steps executed by the compiler during the compilation of C++ programs with templates. Templightâs features include following the instantiation chain, setting breakpoints, and inspecting metaprogram information. This framework aims to take a step forward to help template metaprogramming become more accepted in the software industry.
User-defined functions are similar to the MATLAB pre-defined functions. A function is a MATLAB program that can accept inputs and produce outputs. A function can be called or executed by another program or function.
Code for a function is done in an Editor window or any text editor same way as script and saved as m-file. The m-file must have the same name as the function.
MATLAB's anonymous functions provide an easy way to specify a function. An anonymous function is a function defined without using a separate function file. It is a MATLAB feature that lets you define a mathematical expression of one or more inputs and either assign that expression to a function. This method is good for relatively simple functions that will not be used that often and that can be written in a single expression.
The inline command lets you create a function of any number of variables by giving a string containing the function followed by a series of strings denoting the order of the input variables. It is similar to an Anonymous Function
Previous post we discussed what is a user defined function in MATLAB. This lecture we will discuss how to define a function and how to call the function in a script.
Components of a function is discussed in the previous lecture. The first statement in a function must be function definition.The basic syntax of a function definition is:
function[a, b, c]= basicmath(x,y)
Basically a function accepts an input vector, perform the operation, and returns a result. The sample function given has two input variables and three output variables. But we can also have functions without input or/and output.
This is the slide stack to the two JavaScript Operators YouTube videos at https://www.youtube.com/watch?v=4sF-9RqDxEA and https://www.youtube.com/watch?v=lRijlc3tsw0
The idea of this talk is presenting the Golang functional features, the pros e cons of apply functional paradigm in Golang. Do you want to improve readability and maintainability of your code using more functional paradigms? So, come on and let's have a fun time together!
Debugging and Profiling C++ Template MetaprogramsPlatonov Sergey
Â
Template metaprogramming is an emerging new direction in C++ programming for executing algorithms in compilation time. Despite all of its already proven benefits and numerous successful applications, it is yet to be accepted in industrial projects. One reason is the lack of professional software tools supporting the development of template metaprograms. A strong analogue exists between traditional runtime programs and compile-time metaprograms. This connection presents the possibility for creating development tools similar to those already used when writing runtime programs. This paper introduces Templight, a debugging framework that reveals the steps executed by the compiler during the compilation of C++ programs with templates. Templightâs features include following the instantiation chain, setting breakpoints, and inspecting metaprogram information. This framework aims to take a step forward to help template metaprogramming become more accepted in the software industry.
User-defined functions are similar to the MATLAB pre-defined functions. A function is a MATLAB program that can accept inputs and produce outputs. A function can be called or executed by another program or function.
Code for a function is done in an Editor window or any text editor same way as script and saved as m-file. The m-file must have the same name as the function.
MATLAB's anonymous functions provide an easy way to specify a function. An anonymous function is a function defined without using a separate function file. It is a MATLAB feature that lets you define a mathematical expression of one or more inputs and either assign that expression to a function. This method is good for relatively simple functions that will not be used that often and that can be written in a single expression.
The inline command lets you create a function of any number of variables by giving a string containing the function followed by a series of strings denoting the order of the input variables. It is similar to an Anonymous Function
Previous post we discussed what is a user defined function in MATLAB. This lecture we will discuss how to define a function and how to call the function in a script.
Components of a function is discussed in the previous lecture. The first statement in a function must be function definition.The basic syntax of a function definition is:
function[a, b, c]= basicmath(x,y)
Basically a function accepts an input vector, perform the operation, and returns a result. The sample function given has two input variables and three output variables. But we can also have functions without input or/and output.
This is the slide stack to the two JavaScript Operators YouTube videos at https://www.youtube.com/watch?v=4sF-9RqDxEA and https://www.youtube.com/watch?v=lRijlc3tsw0
This talk introduces the core concepts of functional programming, why it matters now and how these principles are adopted for programming.
Beyond the usage of the functional principles for programming in the small, their applicability to the design of components and further on to the architecture of software systems is also explored along with relevant examples.
The code samples used in the talk are in Haskell / Java 8 / Scala / Elm and JavaScript, but deep understanding of any of these languages are not a pre-requisite.
Metaprogramming is a key tool of many Java frameworks, such as Spring and Hibernate. In this talk we will cover how metaprogramming can be implemented on JVM. Weâll look at annotations, reflection, bytecode manipulation and cover metaprogramming patterns you can successfully apply in your projects.
A MATLAB function that accepts another function as an input is called a function function. Function handles are used for passing functions to function functions. Syntax for function function is same as simple functions, but one or more input arguments will be function handles.
Multiple functions within one function file is called local function. Name of function file should be name of main function. Main function can be called from the command window or any other function. Local functions are typed in any order after the main function. Local functions are only visible to other functions in the same file.
A private function is a function residing in a sub directory with the name private. Private functions are visible only to functions in the parent directory.
Since these presentations were spare time hobby - I've decided to share them :)
Hopefully someone will find them useful.
This part continues 1. part with more design patterns like Command, State, NullObject.
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
Â
Type Conversion:
JavaScript is loosely typed language and most of the time operators automatically convert a value to the right type but there are also cases when we need to explicitly do type conversions.
While JavaScript provides numerous ways to convert data from one type to another but there are two most common data conversions :
Converting Values to String
Converting Values to Numbers
Regular Expressions:
A regular expression is an object that describes a pattern of characters.
The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on text.
JavaScript Arithmetic Operators
Arithmetic operators are used to perform arithmetic between variables and/or values.
JavaScript Assignment Operators
Assignment operators are used to assign values to JavaScript variables.
JavaScript String Operators
The + operator, and the += operator can also be used to concatenate (add) strings.
Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values.
Conditional (Ternary) Operator
The conditional operator assigns a value to a variable based on a condition.
Logical Operators
Logical operators are used to determine the logic between variables or values.
JavaScript Bitwise Operators
Bit operators work on 32 bits numbers. Any numeric operand in the operation is converted into a 32 bit number. The result is converted back to a JavaScript number.
The delete Operator
The delete operator deletes a property from an object:
Check out these exercises: http://de.slideshare.net/nicolayludwig/3-cpp-procedural-programmingexercises
- Procedural Programming
- Predefined and User defined Functions
- Declaration and Definition of Functions
- Procedural and recursive Function Calling
- Namespaces and separated Function Definitions
- A Glimpse of Separated Compilation and Translation Units
TMPA-2015: A Need To Specify and Verify Standard FunctionsIosif Itkin
Â
A Need To Specify and Verify Standard Functions
Nikolay Shilov, A.P. Ershov Institute of Informatics Systems, Novosibirsk
12 - 14 November 2015
Tools and Methods of Program Analysis in St. Petersburg
What is "functional programming", "pure function", "functional language", "lambda function" and "higher-order function" and how these concepts work in modern programming?
Watch the video lesson from Svetlin Nakov and learn more at:
https://softuni.org/dev-concepts/what-is-functional-programming
A JavaScript function is a block of code designed to perform a particular task.
Why Functions?
You can reuse code: Define the code once, and use it many times. You can use the same code many times with different arguments, to produce different results.
It was presented in #NullHyd on 14th Dec, 2019 with 4 hours hands-on session. All code has been shared in github repo as well: https://github.com/jassics/python-for-cybersecurity
This talk introduces the core concepts of functional programming, why it matters now and how these principles are adopted for programming.
Beyond the usage of the functional principles for programming in the small, their applicability to the design of components and further on to the architecture of software systems is also explored along with relevant examples.
The code samples used in the talk are in Haskell / Java 8 / Scala / Elm and JavaScript, but deep understanding of any of these languages are not a pre-requisite.
Metaprogramming is a key tool of many Java frameworks, such as Spring and Hibernate. In this talk we will cover how metaprogramming can be implemented on JVM. Weâll look at annotations, reflection, bytecode manipulation and cover metaprogramming patterns you can successfully apply in your projects.
A MATLAB function that accepts another function as an input is called a function function. Function handles are used for passing functions to function functions. Syntax for function function is same as simple functions, but one or more input arguments will be function handles.
Multiple functions within one function file is called local function. Name of function file should be name of main function. Main function can be called from the command window or any other function. Local functions are typed in any order after the main function. Local functions are only visible to other functions in the same file.
A private function is a function residing in a sub directory with the name private. Private functions are visible only to functions in the parent directory.
Since these presentations were spare time hobby - I've decided to share them :)
Hopefully someone will find them useful.
This part continues 1. part with more design patterns like Command, State, NullObject.
JavaScript - Chapter 9 - TypeConversion and Regular Expressions WebStackAcademy
Â
Type Conversion:
JavaScript is loosely typed language and most of the time operators automatically convert a value to the right type but there are also cases when we need to explicitly do type conversions.
While JavaScript provides numerous ways to convert data from one type to another but there are two most common data conversions :
Converting Values to String
Converting Values to Numbers
Regular Expressions:
A regular expression is an object that describes a pattern of characters.
The JavaScript RegExp class represents regular expressions, and both String and RegExp define methods that use regular expressions to perform powerful pattern-matching and search-and-replace functions on text.
JavaScript Arithmetic Operators
Arithmetic operators are used to perform arithmetic between variables and/or values.
JavaScript Assignment Operators
Assignment operators are used to assign values to JavaScript variables.
JavaScript String Operators
The + operator, and the += operator can also be used to concatenate (add) strings.
Comparison Operators
Comparison operators are used in logical statements to determine equality or difference between variables or values.
Conditional (Ternary) Operator
The conditional operator assigns a value to a variable based on a condition.
Logical Operators
Logical operators are used to determine the logic between variables or values.
JavaScript Bitwise Operators
Bit operators work on 32 bits numbers. Any numeric operand in the operation is converted into a 32 bit number. The result is converted back to a JavaScript number.
The delete Operator
The delete operator deletes a property from an object:
Check out these exercises: http://de.slideshare.net/nicolayludwig/3-cpp-procedural-programmingexercises
- Procedural Programming
- Predefined and User defined Functions
- Declaration and Definition of Functions
- Procedural and recursive Function Calling
- Namespaces and separated Function Definitions
- A Glimpse of Separated Compilation and Translation Units
TMPA-2015: A Need To Specify and Verify Standard FunctionsIosif Itkin
Â
A Need To Specify and Verify Standard Functions
Nikolay Shilov, A.P. Ershov Institute of Informatics Systems, Novosibirsk
12 - 14 November 2015
Tools and Methods of Program Analysis in St. Petersburg
What is "functional programming", "pure function", "functional language", "lambda function" and "higher-order function" and how these concepts work in modern programming?
Watch the video lesson from Svetlin Nakov and learn more at:
https://softuni.org/dev-concepts/what-is-functional-programming
A JavaScript function is a block of code designed to perform a particular task.
Why Functions?
You can reuse code: Define the code once, and use it many times. You can use the same code many times with different arguments, to produce different results.
It was presented in #NullHyd on 14th Dec, 2019 with 4 hours hands-on session. All code has been shared in github repo as well: https://github.com/jassics/python-for-cybersecurity
Functional Patterns for C++ Multithreading (C++ Dev Meetup Iasi)Ovidiu Farauanu
Â
Discussing Design Patterns and OOP popularity,
Multithreading and OOP,
Functional Design for Multithreaded programming
and how Multithreading does not mean always concurency but multicore paralelism.
Test strategies for data processing pipelines, v2.0Lars Albertsson
Â
This talk will present recommended patterns and corresponding anti-patterns for testing data processing pipelines. We will suggest technology and architecture to improve testability, both for batch and streaming processing pipelines. We will primarily focus on testing for the purpose of development productivity and product iteration speed, but briefly also cover data quality testing.
Robust C++ Task Systems Through Compile-time ChecksStoyan Nikolov
Â
Task-based (aka job systems) engine architectures are becoming the de-facto standard for AAA game engines and software solutions. The talk explains how the task system in the Hummingbird game UI engine was designed to both be convenient and to avoid common programmer pitfalls. Advanced C++ techniques are employed to warn and shield the developer from errors at compile time.
Twins: Object Oriented Programming and Functional ProgrammingRichardWarburton
Â
Object-Oriented Programming has well established design principles, such as SOLID. For many developers architecture and functional programming are at odds with each other: they donât know how their existing tricks of the trade convert into functional design. This problem becomes worse as hybrid languages such as Java 8 or Scala become common. Weâll talk about how functional programming helps you implement the SOLID principles, and how a functional mindset can actually help you achieve cleaner and simpler OO design.
C++ (pronounced "see plus plus") is a computer programming language based on C. It was created for writing programs for many different purposes. In the 1990s, C++ became one of the most used programming languages in the world.
The C++ programming language was developed by Bjarne Stroustrup at Bell Labs in the 1980s, and was originally named "C with classes". The language was planned as an improvement on the C programming language, adding features based on object-oriented programming. Step by step, a lot of advanced features were added to the language, like operator overloading, exception handling and templates.
Zoom is a comprehensive platform designed to connect individuals and teams efficiently. With its user-friendly interface and powerful features, Zoom has become a go-to solution for virtual communication and collaboration. It offers a range of tools, including virtual meetings, team chat, VoIP phone systems, online whiteboards, and AI companions, to streamline workflows and enhance productivity.
Artificia Intellicence and XPath Extension FunctionsOctavian Nadolu
Â
The purpose of this presentation is to provide an overview of how you can use AI from XSLT, XQuery, Schematron, or XML Refactoring operations, the potential benefits of using AI, and some of the challenges we face.
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.
Utilocate offers a comprehensive solution for locate ticket management by automating and streamlining the entire process. By integrating with Geospatial Information Systems (GIS), it provides accurate mapping and visualization of utility locations, enhancing decision-making and reducing the risk of errors. The system's advanced data analytics tools help identify trends, predict potential issues, and optimize resource allocation, making the locate ticket management process smarter and more efficient. Additionally, automated ticket management ensures consistency and reduces human error, while real-time notifications keep all relevant personnel informed and ready to respond promptly.
The system's ability to streamline workflows and automate ticket routing significantly reduces the time taken to process each ticket, making the process faster and more efficient. Mobile access allows field technicians to update ticket information on the go, ensuring that the latest information is always available and accelerating the locate process. Overall, Utilocate not only enhances the efficiency and accuracy of locate ticket management but also improves safety by minimizing the risk of utility damage through precise and timely locates.
Software Engineering, Software Consulting, Tech Lead, Spring Boot, Spring Cloud, Spring Core, Spring JDBC, Spring Transaction, Spring MVC, OpenShift Cloud Platform, Kafka, REST, SOAP, LLD & HLD.
AI Genie Review: Worldâs First Open AI WordPress Website CreatorGoogle
Â
AI Genie Review: Worldâs First Open AI WordPress Website Creator
đđ Click Here To Get More Info đđ
https://sumonreview.com/ai-genie-review
AI Genie Review: Key Features
â Creates Limitless Real-Time Unique Content, auto-publishing Posts, Pages & Images directly from Chat GPT & Open AI on WordPress in any Niche
â First & Only Google Bard Approved Software That Publishes 100% Original, SEO Friendly Content using Open AI
â Publish Automated Posts and Pages using AI Genie directly on Your website
â 50 DFY Websites Included Without Adding Any Images, Content Or Doing Anything Yourself
â Integrated Chat GPT Bot gives Instant Answers on Your Website to Visitors
â Just Enter the title, and your Content for Pages and Posts will be ready on your website
â Automatically insert visually appealing images into posts based on keywords and titles.
â Choose the temperature of the content and control its randomness.
â Control the length of the content to be generated.
â Never Worry About Paying Huge Money Monthly To Top Content Creation Platforms
â 100% Easy-to-Use, Newbie-Friendly Technology
â 30-Days Money-Back Guarantee
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
#AIGenieApp #AIGenieBonus #AIGenieBonuses #AIGenieDemo #AIGenieDownload #AIGenieLegit #AIGenieLiveDemo #AIGenieOTO #AIGeniePreview #AIGenieReview #AIGenieReviewandBonus #AIGenieScamorLegit #AIGenieSoftware #AIGenieUpgrades #AIGenieUpsells #HowDoesAlGenie #HowtoBuyAIGenie #HowtoMakeMoneywithAIGenie #MakeMoneyOnline #MakeMoneywithAIGenie
May Marketo Masterclass, London MUG May 22 2024.pdfAdele Miller
Â
Can't make Adobe Summit in Vegas? No sweat because the EMEA Marketo Engage Champions are coming to London to share their Summit sessions, insights and more!
This is a MUG with a twist you don't want to miss.
E-commerce Application Development Company.pdfHornet Dynamics
Â
Your business can reach new heights with our assistance as we design solutions that are specifically appropriate for your goals and vision. Our eCommerce application solutions can digitally coordinate all retail operations processes to meet the demands of the marketplace while maintaining business continuity.
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
Need for Speed: Removing speed bumps from your Symfony projects âĄïžĆukasz ChruĆciel
Â
No one wants their application to drag like a car stuck in the slow lane! Yet itâs all too common to encounter bumpy, pothole-filled solutions that slow the speed of any application. Symfony apps are not an exception.
In this talk, I will take you for a spin around the performance racetrack. Weâll explore common pitfalls - those hidden potholes on your application that can cause unexpected slowdowns. Learn how to spot these performance bumps early, and more importantly, how to navigate around them to keep your application running at top speed.
We will focus in particular on tuning your engine at the application level, making the right adjustments to ensure that your system responds like a well-oiled, high-performance race car.
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
Quarkus Hidden and Forbidden ExtensionsMax Andersen
Â
Quarkus has a vast extension ecosystem and is known for its subsonic and subatomic feature set. Some of these features are not as well known, and some extensions are less talked about, but that does not make them less interesting - quite the opposite.
Come join this talk to see some tips and tricks for using Quarkus and some of the lesser known features, extensions and development techniques.
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.
Enterprise Resource Planning System includes various modules that reduce any business's workload. Additionally, it organizes the workflows, which drives towards enhancing productivity. Here are a detailed explanation of the ERP modules. Going through the points will help you understand how the software is changing the work dynamics.
To know more details here: https://blogs.nyggs.com/nyggs/enterprise-resource-planning-erp-system-modules/
7. What will you get?
â Get started with basic
Functional Programming
principles
â Reactive System Design
â Adopt in your day to day
work from now!
8. Functional Programming Intro
â Function
â y = f(x)
â Functions as âFirst Classâ Citizens
â Similar to values
â Pass to / return from other functions
â Separate Data from Functions
â Data is passed to functions
â Data may be returned from functions
â State Management outside of Functions
Programming with Functions
9. Functional Programming Facets
â Pure Functions
â No Side Effects
â Referential Transparency
â Immutable Data Structures
â Expressive Power
â Ability to Reason - Equational Reasoning
â Function Composition
â f : b -> c , g : a -> b
â f o g : a -> c
â f o g = f(g(x))
10. Pure Functions
â No side effects , including IO
â For a set of inputs, always produce the same output
â Referential Transparency
â Can âinlineâ the function everywhere with no changes to the
behavior
â Works with substitution model of computation
â Ensures Testability
11. Pure Functions
Is this a pure function?
func increment(int value ) {
return value + 1;
}
12. Pure Functions
How about this?
func increment(int value )
{
if(value < maxVal) {
return value + 1;
} else {
return maxVal;
}
}
func increment(int value, int maxVal )
{
if(value < maxVal) {
return value + 1;
} else {
return maxVal;
}
}
13. Pure Functions
..and this too?
func increment(int value ) {
int newValue = value +1;
localStorage.put(âcurValueâ,
newValue);
return newValue;
}
func increment(int value ) {
return {
âvalâ : value +1,
âtaskâ : {
âtaskâ : localStorage,
âkeyâ : âcurValueâ,
âvalâ : value+1
}
};
}
15. Immutability
Reference to a data structure is *only* for reading from the data structure
Once you have a reference:
â Guarantees that no one will modify its contents
â Pass along to any number of threads without fear of âstepping on each
otherâ
â Enables safe concurrency and parallelism
â Any updates to the data structure returns a new reference
16. Immutability : an Example
Defects (holds list of open defects)
val defectList = List(Defect(id="CSSid1234",age=48,engineer="jayas"),Defect(id="CSCid5678",age=12,engineer="otherone"))
defectList.foreach { defect =>
if (defect.age > 28) {
sendMsg(defect.engineer)
}
}
defectList.dropWhile { defect =>
defect.engineer == "jayas" }
Thread 1 Thread 2
val myDefectList =
18. Why Functional Programming
Expressive Power
â Readability and Maintainability
â Adhering to mathematical laws and
principles
â Programming by whole values
â Lesser Lines of Code , and thus
lesser the possibility of defects
More Info
â View âWhy Functional Programming
Mattersâ
20. OO - in its Original Form
â State Encapsulation in Objects
â Message Passing for Communication
â Objects to process messages sent to it
â Respond by sending messages
â Not intended to use as Data
Containers/Holders
21. OO - as what we do for living
â Primarily a Data Holder
â No Message Passing - arbitrary retrieval and
update of data
â Imperative Programming to the core
â Manipulating State
â Instructing Computer on How to Do
â Hard to do Concurrency
22. Imperative Vs Functional
â Programming By Word Vs Whole Values
â No word at a time processing
â Work with entire value (data structures)
â How to Do Vs What To Do
â Focus on business logic implementation
â E.g: No instructions on how to traverse a list
â Less Code that Does more
â Reduce Lines of Code
â Reduce Possibility of Defects
for(int i=0; i< j; i++)
{
....
}
23. Whole Value Programming
map (A ->B) List<A> -> List<B>
â List of agents -> List of agent UserIds
flatMap (A -> List<B>) List<A> -> List<B>
â List of agents -> List of extension numbers
filter (A->Boolean) List<A> -> List<A>
â Get all supervisors from user list
foldl (acc x -> y) x List<x> -> y
â Total talk time from a list of call data records
Do a map, filter and fold it!
24. map a list of agents to list of strings (using Guava in Java 7)
import com.google.common.base.Function;
import com.google.common.collect.Collections2;
Function<Agent, String> agentTransformer= new Function<Agent,String>() {
@Override
public String apply(Agent agent) {
return agent.getId();
}
};
List<String> agentIds = new ArrayList<String>(Collections2.transform(agents,agentTransformer));
Whole Value Programming
25. filter a list of agents to list of supervisors (using Guava in Java 7)
import com.google.common.base.Function;
import com.google.common.base.Predicate;
import com.google.common.collect.Collections2;
Predicate<Agent> supervisorFilter = new Predicate<Agent>() {
@Override
public boolean apply(Agent agent) {
return agent.role == Role.SUPERVISOR;
}
};
Collection<Agent> supervisors = Collections2.filter(agents, supervisorFilter);
List<String> supervisorIds = new ArrayList<String>(Collections2.transform(supervisors,agentTransformer));
Whole Value Programming
26. Strong Static Typing
â Type System and Compiler as First Line of defense
â Reduces dependency on Unit Tests
â Most of the time, if it compiles, it will run
â Expressive Power By Type
â e.g: Optional for indicating Value being present or not (vs returning null)
27. Strong Static Typing
Get rid of null, Now. (using Guava in Java 7)
import com.google.common.base.Optional;
class Agent {
Optional<String> agentAlias; // alias may not may not be set
public void setAlias(String alias) {
agentAlias = Optional.fromNullable(alias); // alias could be null, Java !!
}
public Optional<String> getAlias() {
return agentAlias; // returns Optional indicating that alias may or may not be there
}
}
28. Strong Static Typing
Indicate Error by Type, Later. ( in Scala)
def fetchDefectsFromDB() : Try[List[Defect]]= {
Try {
readFromDB// Get the list from DB
}
}
val defectList : Try[List[Defect]] = fetchDefectsFromDB()
defectList.map { defects => defects.foreach {defect => if (defect.age > 28) { sendMsg(defect.engineer)} } }
def fetchDefectsWhenDBDown() : Try[List[Defect]]= {
Failure(new Throwable(new IllegalStateException("DB Service is not in Running State)))
}
29.
30. I am not sure.. What Can I do
Adopt these rules
â No nulls to indicate absence. Use Optional
â Use it judiciously.
â Do not use it purely to indicate an un-initialized internal state
â Use it to indicate to other that data may or may not be present
â No loops . Use Collections2 utils
â Simple for expression may be still efficient for simple iterations.
â Use Guava if it avoids code duplication and does not cause performance overhead
â Make all method parameters final
â Unfortunately there are no immutable collections in Java
31. I am not sure.. What Can I do
Adopt these rules
â No Explicit Multi threading / Concurrency
â For state, in case concurrency is a need, ensure all messages to the object are processed in
sequence (yes, sequentially)
â Use a single threaded executor to handle messages received by an object
â Question and Revisit Impure functions / methods
â Strictly adhere to Single Responsibility Principle of OO
â Write pure functions unless itâs unavoidable
â Itâs fine to have a class with all static methods, which are pure!
â Isolate State management and IO to one part of the system
â Let 80 % of the implementation be pure and stateless
32. I am not sure.. What Can I do
Adopt these rules
â As Always, there are exceptions to all the rules , check with Architect.
â Performance , Maintainability and Readability are of most importance
â Do not compromise on these
33. Learn Functional Programming
Haskell: https://github.com/data61/fp-course
Elm: https://www.elm-tutorial.org/en/
Stay Tuned for Elm training and other FP initiatives!
39. Design & Architecture
Asynchronous Communication
â Message Passing across components
â Asynchronous APIs another choice across systems
â Non Blocking IO, Lock Free Operations
â Use Async Servlet (in Servlet 3.0) for web applications (Shindig is a perfect use case)
â Use non blocking version of libraries, say http-client, jersey server and client
â Work on Futures and Future Compositions
â Composition of Futures - not present by default in Java 7
â Use ListenableFuture in Guava / CompletableFuture in Java 8
â Evaluate and Use RxJava
40. Design & Architecture
Resiliency
â Build for failures
â Failures are Inevitable
â Architecture and Design should facilitate failure propagation and recovery
â Communicate Error & Recover from Failures
â Let the user know
â Provide error recovery option
â Retries for inter-component interactions / critical operations
â Location Transparency for distributed/ clustered systems
â Distributed Cache usage does not rely on fetching cache entry from a particular node
41. Design & Architecture
Responsive
â Respond even when subsystems are down
â Let the user know
â Provide degraded /lower set of functionalities than being totally unresponsive
â Have alternate option for dependent critical subsystems / external systems
42. Design & Architecture
Elastic
â Ability to scale up / down / out / in
â Build services that caters to 400 users (CCX) , at the same time that can scale for 18000
users (CCE)
â Utilize all the cores of CPU
â Ability to add more machines to scale out
â distributed data processing, location transparency for processing engines