As businesses grow, so does the complexity of their software. New features, new models, and new background processes all continue to be added. . .and developers struggle to make sense of it all. Yet the end user demands a swift and functional experience when interacting with your application. It is paramount to be open to alternative patterns that help tame complex, high-demand services. Two such patterns are command-query responsibility segregation (CQRS) and event sourcing (ES).
Command-query responsibility segregation is an architectural pattern for user-facing applications that extends from the now standard Model-View-Controller (MVC) pattern and is an alternative to the CRUD pattern. At its core, CQRS is about changing how we think of and work with our data by introducing two types of models: all user actions become commands, and a read-only query model powers our views. Commands and queries are logistically separated, providing additional decoupling of our application. CQRS also calls for changes in how we store and structure our data.
Enter event sourcing. Instead of persisting the current state of our domain objects or entities, we record historical events about our data. The key advantage is that we can examine our application data at any point in time, rather than just the current state. This pattern changes how we persist and process our data but is surprisingly efficient.
While each of the two patterns can be used exclusively, they complement each other beautifully and facilitate the construction of decoupled, scalable applications or individual services. Stephen Pember explores the fundamentals of each pattern and offers several examples and demonstration code to show how one might actually go about implementing CQRS and ES. Steve discusses task-based UIs and domain-driven design as he outlines some of the advantages—and challenges—that ThirdChannel has seen when developing systems using CQRS and ES over the past year.
Myths and Mathemagical Superpowers of Data ScientistsDavid Pittman
Some people think data scientists are mythical beings, like unicorns, or they are some sort of nouveau fad that will quickly fade. Not true, says IBM big data evangelist James Kobielus. In this engaging presentation, with artwork created by Angela Tuminello, Kobielus debunks 10 myths about data scientists and their role in analytics and big data. You might also want to read the full blog by Kobielus that spawned this presentation: "Data Scientists: Myths and Mathemagical Superpowers" - http://ibm.co/PqF7Jn
For more information, visit http://www.ibmbigdatahub.com
YouTube Link: https://youtu.be/WvhQhj4n6b8
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'What is Python?' will help you understand and learn python programming language with its features. It is one of the most widely adopted programming language in the industry currently. Below are the topics covered in this Python Programming tutorial
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This Edureka Python tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) gives an introduction to Machine Learning and how to implement machine learning algorithms in Python. Below are the topics covered in this tutorial:
1. Why Machine Learning?
2. What is Machine Learning?
3. Types of Machine Learning
4. Supervised Learning
5. KNN algorithm
6. Unsupervised Learning
7. K-means Clustering Algorithm
In this presentation, I have talked about Big Data and its importance in brief. I have included the very basics of Data Science and its importance in the present day, through a case study. You can also get an idea about who a data scientist is and what all tasks he performs. A few applications of data science have been illustrated in the end.
When building an Event Sourcing system, can we change the past? Can we also forecast “events” in the future?
If we want to provide various projections/visions of things that hapenned over the time, what are the consequences and trade-offs on our code?
All these questions will be answered during this talk. But moreover, I'll tell you our learning story about Bi-temporal Event Sourcing. Yet another illustration of the power of modeling, sketches and concrete examples when we need to understand each others.
As businesses grow, so does the complexity of their software. New features, new models, and new background processes all continue to be added. . .and developers struggle to make sense of it all. Yet the end user demands a swift and functional experience when interacting with your application. It is paramount to be open to alternative patterns that help tame complex, high-demand services. Two such patterns are command-query responsibility segregation (CQRS) and event sourcing (ES).
Command-query responsibility segregation is an architectural pattern for user-facing applications that extends from the now standard Model-View-Controller (MVC) pattern and is an alternative to the CRUD pattern. At its core, CQRS is about changing how we think of and work with our data by introducing two types of models: all user actions become commands, and a read-only query model powers our views. Commands and queries are logistically separated, providing additional decoupling of our application. CQRS also calls for changes in how we store and structure our data.
Enter event sourcing. Instead of persisting the current state of our domain objects or entities, we record historical events about our data. The key advantage is that we can examine our application data at any point in time, rather than just the current state. This pattern changes how we persist and process our data but is surprisingly efficient.
While each of the two patterns can be used exclusively, they complement each other beautifully and facilitate the construction of decoupled, scalable applications or individual services. Stephen Pember explores the fundamentals of each pattern and offers several examples and demonstration code to show how one might actually go about implementing CQRS and ES. Steve discusses task-based UIs and domain-driven design as he outlines some of the advantages—and challenges—that ThirdChannel has seen when developing systems using CQRS and ES over the past year.
Myths and Mathemagical Superpowers of Data ScientistsDavid Pittman
Some people think data scientists are mythical beings, like unicorns, or they are some sort of nouveau fad that will quickly fade. Not true, says IBM big data evangelist James Kobielus. In this engaging presentation, with artwork created by Angela Tuminello, Kobielus debunks 10 myths about data scientists and their role in analytics and big data. You might also want to read the full blog by Kobielus that spawned this presentation: "Data Scientists: Myths and Mathemagical Superpowers" - http://ibm.co/PqF7Jn
For more information, visit http://www.ibmbigdatahub.com
YouTube Link: https://youtu.be/WvhQhj4n6b8
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'What is Python?' will help you understand and learn python programming language with its features. It is one of the most widely adopted programming language in the industry currently. Below are the topics covered in this Python Programming tutorial
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This Edureka Python tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) gives an introduction to Machine Learning and how to implement machine learning algorithms in Python. Below are the topics covered in this tutorial:
1. Why Machine Learning?
2. What is Machine Learning?
3. Types of Machine Learning
4. Supervised Learning
5. KNN algorithm
6. Unsupervised Learning
7. K-means Clustering Algorithm
In this presentation, I have talked about Big Data and its importance in brief. I have included the very basics of Data Science and its importance in the present day, through a case study. You can also get an idea about who a data scientist is and what all tasks he performs. A few applications of data science have been illustrated in the end.
When building an Event Sourcing system, can we change the past? Can we also forecast “events” in the future?
If we want to provide various projections/visions of things that hapenned over the time, what are the consequences and trade-offs on our code?
All these questions will be answered during this talk. But moreover, I'll tell you our learning story about Bi-temporal Event Sourcing. Yet another illustration of the power of modeling, sketches and concrete examples when we need to understand each others.
Overview of tools available in python for performing data visualization (statistical, geographical, reporting, etc). Prepared for Minsk DataViz Day (October 4, 2017)
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...Edureka!
This Edureka Python Pandas tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you learn the basics of Pandas. It also includes a use-case, where we will analyse the data containing the percentage of unemployed youth for every country between 2010-2014. Below are the topics covered in this tutorial:
1. What is Data Analysis?
2. What is Pandas?
3. Pandas Operations
4. Use-case
A presentation on "Rest api with Python" presented at Python Developers Nepal Meetup #6 by Santosh Ghimire. It focuses more on Django Rest Framework library.
End-to-End Deep Learning with Horovod on Apache SparkDatabricks
Data processing and deep learning are often split into two pipelines, one for ETL processing, the second for model training. Enabling deep learning frameworks to integrate seamlessly with ETL jobs allows for more streamlined production jobs, with faster iteration between feature engineering and model training.
Introduction to various data science. From the very beginning of data science idea, to latest designs, changing trends, technologies what make then to the application that are already in real world use as we of now.
Data Science For Beginners | Who Is A Data Scientist? | Data Science Tutorial...Edureka!
** Data Science Certification using R: https://www.edureka.co/data-science **
This Edureka "Data Science for Beginners" PPT talks about the basic concepts of Data Science, which includes machine learning algorithms as well as the roles & responsibilities of a Data Scientist. It also includes a demo using R Studio, that attempts to make sense of all the Data generated in the real world. This PPT talks about the most crucial aspects of data science and covers the following topics:
Why Data Science?
What is Data Science?
Who is a Data Scientist?
What does a Data Scientist do?
How to solve a problem in Data Science?
Data Science Tools
Demo
Check out our Data Science Tutorial blog series: http://bit.ly/data-science-blogs
Check out our complete YouTube playlist here: http://bit.ly/data-science-playlist
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
The 'macro view' on Big Query:
We started with an overview, some typical uses and moved to project hierarchy, access control and security.
In the end we touch about tools and demos.
Building occasionally connected applications using event sourcingDennis Doomen
I've recently got the opportunity to work on a large enterprise-class system that needs to be deployed on multiple occasionally connected oil platforms and boats. Already the system's architecture was based on the Command Query Separation principles, this gave us a completely new challenge. After several months of looking at alternatives, we decided to go the Event Sourcing direction. In this in-depth session, I'd like you to learn the many alternatives we observed, the pros and cons, and the technical details of our final solution in which we use EventStore 3.0 and elements of NCQRS and Lokad.CQRS to synchronize systems over unreliable connections in a very efficient way.
Best Python Libraries For Data Science & Machine Learning | EdurekaEdureka!
YouTube Link: https://youtu.be/LepMvJdr2-w
** Machine Learning Engineer Masters Program: https://www.edureka.co/masters-program/machine-learning-engineer-training **
This Edureka session will focus on the top Python libraries that you should know to master Data Science and Machine Learning. Here’s a list of topics that are covered in this session:
Introduction To Data Science And Machine Learning
Why Use Python For Data Science And Machine Learning?
Python Libraries for Data Science And Machine Learning
Python libraries for Statistics
Python libraries for Visualization
Python libraries for Machine Learning
Python libraries for Deep Learning
Python libraries for Natural Language Processing
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Data Science is the Sexiest job in 21st century. Big Data Concept is going to rule the 21st century. Here is the presentation to give complete information and overview of data science big data.
The domain model is an abstraction of the problem domain that your system supports. It contains the objects and operations that are crucial to your system and its users. Therefore the design of the domain model deserves the utmost care and attention. In this session you will be introduced to Domain-Driven Design and you will learn how to put Domain-Driven Design (DDD) into practice. We will explore how to apply DDD on tactical level to design a rich domain model that encapsulates behaviour, protects its invariants and can be tested in isolation from its runtime environment
Improving application design with a rich domain model (springone 2007)Chris Richardson
A classic from 2007. This is a presentationthat I gave at SpringOne in Antwerp, Belgium. It describes show to improve application design by using a rich domain model
Overview of tools available in python for performing data visualization (statistical, geographical, reporting, etc). Prepared for Minsk DataViz Day (October 4, 2017)
Python For Data Analysis | Python Pandas Tutorial | Learn Python | Python Tra...Edureka!
This Edureka Python Pandas tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you learn the basics of Pandas. It also includes a use-case, where we will analyse the data containing the percentage of unemployed youth for every country between 2010-2014. Below are the topics covered in this tutorial:
1. What is Data Analysis?
2. What is Pandas?
3. Pandas Operations
4. Use-case
A presentation on "Rest api with Python" presented at Python Developers Nepal Meetup #6 by Santosh Ghimire. It focuses more on Django Rest Framework library.
End-to-End Deep Learning with Horovod on Apache SparkDatabricks
Data processing and deep learning are often split into two pipelines, one for ETL processing, the second for model training. Enabling deep learning frameworks to integrate seamlessly with ETL jobs allows for more streamlined production jobs, with faster iteration between feature engineering and model training.
Introduction to various data science. From the very beginning of data science idea, to latest designs, changing trends, technologies what make then to the application that are already in real world use as we of now.
Data Science For Beginners | Who Is A Data Scientist? | Data Science Tutorial...Edureka!
** Data Science Certification using R: https://www.edureka.co/data-science **
This Edureka "Data Science for Beginners" PPT talks about the basic concepts of Data Science, which includes machine learning algorithms as well as the roles & responsibilities of a Data Scientist. It also includes a demo using R Studio, that attempts to make sense of all the Data generated in the real world. This PPT talks about the most crucial aspects of data science and covers the following topics:
Why Data Science?
What is Data Science?
Who is a Data Scientist?
What does a Data Scientist do?
How to solve a problem in Data Science?
Data Science Tools
Demo
Check out our Data Science Tutorial blog series: http://bit.ly/data-science-blogs
Check out our complete YouTube playlist here: http://bit.ly/data-science-playlist
Follow us to never miss an update in the future.
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
The 'macro view' on Big Query:
We started with an overview, some typical uses and moved to project hierarchy, access control and security.
In the end we touch about tools and demos.
Building occasionally connected applications using event sourcingDennis Doomen
I've recently got the opportunity to work on a large enterprise-class system that needs to be deployed on multiple occasionally connected oil platforms and boats. Already the system's architecture was based on the Command Query Separation principles, this gave us a completely new challenge. After several months of looking at alternatives, we decided to go the Event Sourcing direction. In this in-depth session, I'd like you to learn the many alternatives we observed, the pros and cons, and the technical details of our final solution in which we use EventStore 3.0 and elements of NCQRS and Lokad.CQRS to synchronize systems over unreliable connections in a very efficient way.
Best Python Libraries For Data Science & Machine Learning | EdurekaEdureka!
YouTube Link: https://youtu.be/LepMvJdr2-w
** Machine Learning Engineer Masters Program: https://www.edureka.co/masters-program/machine-learning-engineer-training **
This Edureka session will focus on the top Python libraries that you should know to master Data Science and Machine Learning. Here’s a list of topics that are covered in this session:
Introduction To Data Science And Machine Learning
Why Use Python For Data Science And Machine Learning?
Python Libraries for Data Science And Machine Learning
Python libraries for Statistics
Python libraries for Visualization
Python libraries for Machine Learning
Python libraries for Deep Learning
Python libraries for Natural Language Processing
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
Data Science is the Sexiest job in 21st century. Big Data Concept is going to rule the 21st century. Here is the presentation to give complete information and overview of data science big data.
The domain model is an abstraction of the problem domain that your system supports. It contains the objects and operations that are crucial to your system and its users. Therefore the design of the domain model deserves the utmost care and attention. In this session you will be introduced to Domain-Driven Design and you will learn how to put Domain-Driven Design (DDD) into practice. We will explore how to apply DDD on tactical level to design a rich domain model that encapsulates behaviour, protects its invariants and can be tested in isolation from its runtime environment
Improving application design with a rich domain model (springone 2007)Chris Richardson
A classic from 2007. This is a presentationthat I gave at SpringOne in Antwerp, Belgium. It describes show to improve application design by using a rich domain model
Handling Eventual Consistency in JVM Microservices with Event Sourcing (javao...Chris Richardson
This is the talk that the Kenny Bastani and I gave at JavaOne 2016.
When you’re building JVM applications in a microservice architecture, managing state becomes a distributed systems problem. Instead of being able to manage state as transactions inside the boundaries of a single monolithic application, a microservice must be able to manage consistency by using transactions that are distributed across a network of many different applications and databases. This session explores the problems of data consistency and high availability in JVM-based microservices and how to use event sourcing to solve these problems.
Microservices are an essential enabler of agility but developing and deploying them is a challenge. In order for microservices to be loosely coupled,each service must have its own datastore. This makes it difficult to maintain data consistency across services.
Deploying microservices is also a complex problem since an application typically consists of 10s or 100s of services, written in a variety of languages and frameworks. In this presentation, you will learn how to solve these problems by using an event-driven architecture to maintain data consistency and by using Docker to simplify deployment.
Developing microservices with aggregates (SpringOne platform, #s1p)Chris Richardson
The Domain Model pattern is a great way to develop complex business logic. Unfortunately, a typical domain model is a tangled, birds nest of classes. It can’t be decomposed into microservices. Moreover, business logic often relies on ACID transactions to maintain consistency.
Fortunately, there is a solution to this problem: aggregates. An aggregate is an often overlooked modeling concept from the must read book Domain Driven Design. In this talk you will learn how aggregates enable you to develop business logic for the modern world of microservices and NoSQL. We will describe how to use aggregates to design modular business logic that can be partitioned into microservices. You will learn how aggregates enable you to use eventual consistency instead of ACID. We will describe the design of a microservice that is built using aggregates, and Spring Cloud.
Developing microservices with aggregates (devnexus2017)Chris Richardson
he Domain Model pattern is a great way to develop complex business logic. Unfortunately, a typical domain model is a tangled, birds nest of classes. It can’t be decomposed into microservices. Moreover, business logic often relies on ACID transactions to maintain consistency. Fortunately, there is a solution to this problem: aggregates.
An aggregate is an often overlooked modeling concept from the must read book Domain Driven Design. In this talk you will learn how aggregates enable you to develop business logic for the modern world of microservices and NoSQL. We will describe how to use aggregates to design modular business logic that can be partitioned into microservices. You will learn how aggregates enable you to use eventual consistency instead of ACID. We will describe the design of a microservice that is built using aggregates, and Spring Cloud.
Leider sind in der "freien Wildbahn" viele Architekturen und APIs stark durch die verwendeten Technologien, Frameworks, Generatoren etc. getrieben. Die eigentliche Fachlichkeit der Anwendung bleibt dabei häufig auf der Strecke und ist im Quellcode kaum noch auffindbar. Das Chaos beim Bug-Fixing ist entsprechend vorprogrammiert.
Die Session zeigt einfache, aber sehr effektive Strategien, wie bestehende Anwendungen in ein fachlich getriebenes Architektur- und API-Design überführt werden können - Aha-Effekte garantiert.
Agile Modeling in Color is a technique that applies color to add additional dimensions of information to UML models. This technique comes from the Feature Driven Development methodology, but is applicable to anyone interested in an effective agile modeling/design technique.
An Architectural Model for Adapting Domain-Specific AOM Applicationseduardomg23
An Adaptive Object Model (AOM) is a common architectural style for systems in which classes, attributes, relationships and behaviors of applications are represented as metadata consumed at runtime. This allows them to be very flexible and changeable at runtime not only by programmers, but also by end users, improving system time-to-market. Nevertheless, this flexibility comes with a cost of a greater complexity when developing the system, and therefore one usually uses a bottom-up approach, adding flexibility only when and where it is needed. As a consequence, many AOM applications are tied to the specific domain to which they were developed and this fact makes it difficult to develop and use generic and reusable AOM frameworks that properly handle specific requirements of the AOM architecture. This work presents an architectural model that aims to adapt domain-specific AOM core structures to a common core structure by identifying AOM roles played by each element through custom metadata configuration. By doing this, this model allows the integration of domain-specific AOM applications and AOM frameworks, making it feasible to develop reusable components for the AOM architecture. This model is evaluated by creating an AOM framework and performing a modularity analysis on a case study based on it.
Presentation of a paper published on SBCARS 2012 and available on http://ieeexplore.ieee.org/xpl/articleDetails.jsp?tp=&arnumber=6394972&contentType=Conference+Publications&sortType%3Dasc_p_Sequence%26filter%3DAND%28p_IS_Number%3A6394968%29
Transactions and Concurrency Control PatternsVlad Mihalcea
30 years of RDBMS and this topic is pretty much "uncharted territory" for the vast majority of back-end developers.
This talk is relevant because data integrity is very important for many enterprise applications. At the end of this talk, the audience will get a better picture of the strengths and limitations of database systems concurrency control mechanisms.
CommunityOneEast 09 - Dynamic Languages: the next big thing for the JVM or an...Chris Richardson
There is a good reason why dynamic languages such as Groovy and Ruby are getting a lot of attention. They are powerful, expressive languages that enable developers to easily write concise programs. However, not all of their benefits derive from being dynamic. Many important benefits are simply due to modern language design such as the support for closures. Moreover, dynamic languages have some inherent drawbacks. The extremely limited compile-time checking requires developers to write significantly more tests and severely limits how much help an IDE can provide to a developer.
In this session, which is aimed at Java developers and architects, you will learn
• What it means for a language to be dynamic
• Which Groovy features we liked the most
• The frustrating side of Groovy development
• How Groovy compares to Scala, which is a modern statically typed language that provides many of benefits of Groovy
Evolving a Clean, Pragmatic Architecture at JBCNConf 2019Victor Rentea
Are you in a mood for a brainstorm? Join this critical review of the major decisions taken in a typical enterprise application architecture and learn to balance pragmatism with your design goals. Find out how to do just-in-time design to keep as much use-cases as simple as possible. The core purpose of this presentation is to learn to strike a **balance between pragmatism and maintainability** in your design. Without continuous refactoring, a simple design will inevitably degenerate into a Big Ball of Mud, under the assault of the new features and bugfixes. On the other hand, very highly-factored code can burden the take-off of the development and end up freezing the mindset in some rigid 'a-priori' design. The end goal of this talk is to challenge you to rethink critically the architecture of your own systems, and seek ways to simplify it to match your actual needs, with a pragmatic mindset. "Architecture is the art of postponing decisions", said Uncle Bob. This talk takes this idea further and explains an optimal mindset about designing enterprise applications: Evolving (Continuously Refactoring) a Pragmatic (Simple), Clean (aka Onion) Architecture, aiming to provide Developer Safety™️ and Comfort™️. It’s the philosophy that Victor distilled over the past 5 years, designing and implementing 9 applications as IBM Lead Architect, and delivering trainings and advises to many other companies. You’ll learn how to break data into pieces (Fit Entities, Value Objects, Data Transfer Objects), how to keep the logic simple (Facades, Domain Services, logic extraction patterns, Mappers, AOP), layering to enforce boundaries (keeping DTOs out of your logic, Dependency Inversion Principle), and many more, all in a dynamic, interactive and extremely entertaining session.
Talk by Adithya Reddy, Software Development Engineer at Branch Financial on the topic "AppSync in real world - pitfalls, unexpected benefits & lessons learnt" at AWS Community Day, Bangalore 2018
Qiaoling Liu, Lead Data Scientist, CareerBuilder at MLconf ATL 2017MLconf
CompanyDepot: Employer Name Normalization in the Online Recruitment Industry
In the recruitment domain, the employer name normalization task, which links employer names in job postings or resumes to entities in an employer knowledge base (KB), is important to many business applications. It has several unique challenges: handling employer names from both job postings and resumes, leveraging the corresponding location and url context, as well as handling name variations, irrelevant input data, and noises in the KB. In this talk, we present a system called CompanyDepot which uses machine learning techniques to address these challenges. The proposed system achieves 2.5%- 21.4% higher coverage at the same precision level compared to a legacy system used at CareerBuilder over multiple real-world datasets. After applying it to several applications at CareerBuilder, we faced a new challenge: how to avoid duplicate normalization results when the KB is noisy and contains many duplicate entities. To address this challenge, we extend the CompanyDepot system to normalize employer names not only at entity level, but also at cluster level by mapping a query to a cluster in the KB that best matches the query. The proposed system performs an efficient graph-based clustering based on external knowledge from five mapping sources. We also propose a new metric based on success rate and diversity reduction ratio for evaluating the cluster-level normalization. Through experiments and applications, we demonstrate a large improvement on normalization quality from entity-level to cluster-level normalization.
FITC events. For digital creators.
Save 10% off ANY FITC event with discount code 'slideshare'
See our upcoming events at www.fitc.ca
A Journey with React
with Tasveer Singh
OVERVIEW
React has been receiving a lot of buzz lately but does it live up to it? Taz was curious about this exact question and decided to embark on a journey to find out more. Since then he has fallen in love with React, its simple paradigm, and what it has enabled him to do. From modelling large front-end applications with Flux and WebPack code splitting to search engine optimized isomorphic rendering, he really has explored React from one end to the other and will share his experience and insights with you along with tips and tricks along the way.
OBJECTIVE
To provide the audience with enough information to understand how React is different and to explore further.
TARGET AUDIENCE
Intermediate to Advanced JavaScript developers.
ASSUMED AUDIENCE KNOWLEDGE
Basic knowledge of client side JavaScript frameworks, JavaScript modules, ES6, asset management, SEO, and isomorphic JavaScript.
FIVE THINGS AUDIENCE MEMBERS WILL LEARN
What is React
How React is different
Pros and Cons of a Flux architecture
Pros and Cons of WebPack
Pros and Cons of Isomorphic JavaScript
AWS Neptune - A Fast and reliable Graph Database Built for the CloudAmazon Web Services
Dickson Yue, Solutions Architect, AWS
Amazon Neptune is a fully managed graph database service which has been built ground up for handling rich highly connected data. Come learn how to transform your business with Amazon Neptune and hear diverse use cases such as recommendation engines, knowledge graphs, fraud detection, social networks, network management and life sciences.
This is a Introduction to Object Oriented (OO) Concepts, Java Programming Language and leveraging Eclipse (IBM WebSphere) to develop Java applications.
This is based on JDK 1.4 concepts/features. A newer version maybe provided at a future date.
In this webinar we’ll give you an overview the next generation technology for building APIs called GraphQL and how AWS AppSync takes advantage of GraphQL to make it easy to build collaborative mobile and web applications that deliver responsive and enhanced user experiences.
Modern developers need easy tools for real time, offline access and synchronisation. These techniques are no longer optional for a great end user experience, yet they are difficult to engineer and scale from scratch. Implementing these concepts with modern data fetching patterns across web or mobile can also be difficult.
AWS AppSync automatically updates the data for web and mobile applications in real time and synchronize data for offline users as soon as they reconnect, managing everything needed to store, process, and retrieve the data for your application. In this session, we will also cover how AWS AppSync allows you to query your data using GraphQL and how it handles mutations, subscriptions, pagination, relations, offline access, real time communications, conflict resolution, and efficient data fetching.
What to expect:
Learn GraphQL Concepts
Understand how to use AWS AppSync with different data sources
Manage application data with real time and offline capabilities in the cloud
Executing a Large Scale Migration to AWS (ENT337-R2) - AWS re:Invent 2018Amazon Web Services
Enterprise customers who are planning to lift and shift out of a data center and move to AWS rely on discovery and migration tools for fast and reliable mass migrations. In this session, we show you how to quickly discover and asses your existing IT infrastructure using AWS Application Discovery Service. We also discuss best practices for automating discovery and migration execution. Finally, we dive deep into using AWS Migration Hub with AWS migration tools, like AWS Server Migration Service, and partner tools to track and execute application migrations at scale.
Developing and Deploying Java applications on the Amazon Elastic Compute Clou...Chris Richardson
Traditionally, computer hardware was a scarce, expensive resource. Running performance tests often meant scavenging for machines around the office. Today, however, things are different. With Amazon's EC2, a cluster of servers is now just a web service call away. In this presentation you will learn about design and implementation of Cloud Tools, which is a Groovy-based framework for deploying and testing Java EE applications on EC2. This framework provides a simple (internal) DSL for configuring a cluster (database + web container + apache), deploying a web application, and running performance tests using JMeter. You will learn about capabilities of EC2 and how to use it for development and deployment. We describe how we use Amazon S3 to work around EC2's lack of a persistent file system and avoid time-consuming uploads of WAR files.
A common microservice architecture anti-pattern is more the merrier. It occurs when an organization team builds an excessively fine-grained architecture, e.g. one service-per-developer. In this talk, you will learn about the criteria that you should consider when deciding service granularity. I'll discuss the downsides of a fine-grained microservice architecture. You will learn how sometimes the solution to a design problem is simply a JAR file.
YOW London - Considering Migrating a Monolith to Microservices? A Dark Energy...Chris Richardson
This is a talk I gave at YOW! London 2022.
Let's imagine that you are responsible for an aging monolithic application that's critical to your business. Sadly, getting changes into production is a painful ordeal that regularly causes outages. And to make matters worse, the application's technology stack is growing increasingly obsolete. Neither the business nor the developers are happy. You need to modernize your application and have read about the benefits of microservices. But is the microservice architecture a good choice for your application?
In this presentation, I describe the dark energy and dark matter forces (a.k.a. concerns) that you must consider when deciding between the monolithic and microservice architectural styles. You will learn about how well each architectural style resolves each of these forces. I describe how to evaluate the relative importance of each of these forces to your application. You will learn how to use the results of this evaluation to decide whether to migrate to the microservice architecture.
Dark Energy, Dark Matter and the Microservices Patterns?!Chris Richardson
Dark matter and dark energy are mysterious concepts from astrophysics that are used to explain observations of distant stars and galaxies. The Microservices pattern language - a collection of patterns that solve architecture, design, development, and operational problems — enables software developers to use the microservice architecture effectively. But how could there possibly be a connection between microservices and these esoteric concepts from astrophysics?
In this presentation, I describe how dark energy and dark matter are excellent metaphors for the competing forces (a.k.a. concerns) that must be resolved by the microservices pattern language. You will learn that dark energy, which is an anti-gravity, is a metaphor for the repulsive forces that encourage decomposition into services. I describe how dark matter, which is an invisible matter that has a gravitational effect, is a metaphor for the attractive forces that resist decomposition and encourage the use of a monolithic architecture. You will learn how to use the dark energy and dark matter forces as guide when designing services and operations.
Dark energy, dark matter and microservice architecture collaboration patternsChris Richardson
Dark energy and dark matter are useful metaphors for the repulsive forces, which encourage decomposition into services, and the attractive forces, which resist decomposition. You must balance these conflicting forces when defining a microservice architecture including when designing system operations (a.k.a. requests) that span services.
In this talk, I describe the dark energy and dark matter forces. You will learn how to design system operations that span services using microservice architecture collaboration patterns: Saga, Command-side replica, API composition, and CQRS patterns. I describe how each of these patterns resolve the dark energy and dark matter forces differently.
It sounds dull but good architecture documentation is essential. Especially when you are actively trying to improve your architecture.
For example, I spend a lot time helping clients modernize their software architecture. More often than I like, I’m presented with a vague and lifeless collection of boxes and lines. As a result, it’s sometimes difficult to discuss the architecture in a meaningful and productive way. In this presentation, I’ll describe techniques for creating minimal yet effective documentation for your application’s microservice architecture. In particular, you will learn how documenting scenarios can bring your architecture to life.
Using patterns and pattern languages to make better architectural decisions Chris Richardson
This is a presentation that gave at the O'Reilly Software Architecture Superstream: Software Architecture Patterns.
The talk's focus is the microservices pattern language.
However, it also shows how thinking with the pattern mindset - context/problem/forces/solution/consequences - leads to better technically decisions.
The microservices architecture offers tremendous benefits, but it’s not a silver bullet. It also has some significant drawbacks. The microservices pattern language—a collection of patterns that solve architecture, design, development, and operational problems—enables software developers to apply the microservices architecture effectively. I provide an overview of the microservices architecture and examines the motivations for the pattern language, then takes you through the key patterns in the pattern language.
Rapid, reliable, frequent and sustainable software development requires an architecture that is loosely coupled and modular.
Teams need to be able complete their work with minimal coordination and communication with other teams.
They also need to be able keep the software’s technology stack up to date.
However, the microservice architecture isn’t always the only way to satisfy these requirements.
Yet, neither is the monolithic architecture.
In this talk, I describe loose coupling and modularity and why they are is essential.
You will learn about three architectural patterns: traditional monolith, modular monolith and microservices.
I describe the benefits, drawbacks and issues of each pattern and how well it supports rapid, reliable, frequent and sustainable development.
You will learn some heuristics for selecting the appropriate pattern for your application.
Events to the rescue: solving distributed data problems in a microservice arc...Chris Richardson
To deliver a large complex application rapidly, frequently and reliably, you often must use the microservice architecture.
The microservice architecture is an architectural style that structures the application as a collection of loosely coupled services.
One challenge with using microservices is that in order to be loosely coupled each service has its own private database.
As a result, implementing transactions and queries that span services is no longer straightforward.
In this presentation, you will learn how event-driven microservices address this challenge.
I describe how to use sagas, which is an asynchronous messaging-based pattern, to implement transactions that span services.
You will learn how to implement queries that span services using the CQRS pattern, which maintain easily queryable replicas using events.
A pattern language for microservices - June 2021 Chris Richardson
The microservice architecture is growing in popularity. It is an architectural style that structures an application as a set of loosely coupled services that are organized around business capabilities. Its goal is to enable the continuous delivery of large, complex applications. However, the microservice architecture is not a silver bullet and it has some significant drawbacks.
The goal of the microservices pattern language is to enable software developers to apply the microservice architecture effectively. It is a collection of patterns that solve architecture, design, development and operational problems. In this talk, I’ll provide an overview of the microservice architecture and describe the motivations for the pattern language. You will learn about the key patterns in the pattern language.
QConPlus 2021: Minimizing Design Time Coupling in a Microservice ArchitectureChris Richardson
Delivering large, complex software rapidly, frequently and reliably requires a loosely coupled organization. DevOps teams should rarely need to communicate and coordinate in order to get work done. Conway's law states that an organization and the architecture that it develops mirror one another. Hence, a loosely coupled organization requires a loosely coupled architecture.
In this presentation, you will learn about design-time coupling in a microservice architecture and why it's essential to minimize it. I describe how to design service APIs to reduce coupling. You will learn how to minimize design-time coupling by applying a version of the DRY principle. I describe how key microservices patterns potentially result in tight design time coupling and how to avoid it.
Mucon 2021 - Dark energy, dark matter: imperfect metaphors for designing micr...Chris Richardson
In order to explain certain astronomical observations, physicists created the mysterious concepts of dark energy and dark matter.
Dark energy is a repulsive force.
It’s an anti-gravity that is forcing matter apart and accelerating the expansion of the universe.
Dark matter has the opposite attraction effect.
Although it’s invisible, dark matter has a gravitational effect on stars and galaxies.
In this presentation, you will learn how these metaphors apply to the microservice architecture.
I describe how there are multiple repulsive forces that drive the decomposition of your application into services.
You will learn, however, that there are also multiple attractive forces that resist decomposition and bind software elements together.
I describe how as an architect you must find a way to balance these opposing forces.
Skillsmatter CloudNative eXchange 2020
The microservice architecture is a key part of cloud native.
An essential principle of the microservice architecture is loose coupling.
If you ignore this principle and develop tightly coupled services the result will mostly likely be yet another "microservices failure story”.
Your application will be brittle and have all of disadvantages of both the monolithic and microservice architectures.
In this talk you will learn about the different kinds of coupling and how to design loosely coupled microservices.
I describe how to minimize design time and increase the productivity of your DevOps teams.
You will learn how how to reduce runtime coupling and improve availability.
I describe how to improve availability by minimizing the coupling caused by your infrastructure.
DDD SoCal: Decompose your monolith: Ten principles for refactoring a monolith...Chris Richardson
This is a talk I gave at DDD SoCal.
1. Make the most of your monolith
2. Adopt microservices for the right reasons
3. It’s not just architecture
4. Get the support of the business
5. Migrate incrementally
6. Know your starting point
7. Begin with the end in mind
8. Migrate high-value modules first
9. Success is improved velocity and reliability
10. If it hurts, don’t do it
Decompose your monolith: Six principles for refactoring a monolith to microse...Chris Richardson
This was a talk I gave at the CTO virtual summit on July 28th. It describes 6 principles for refactoring to a microservice architecture.
1. Make the most of your monolith
2. Adopt microservices for the right reasons
3. Migrate incrementally
4. Begin with the end in mind
5. Migrate high-value modules first
6. Success is improved velocity and reliability
The microservice architecture is becoming increasingly important. But what is it exactly? Why should you care about microservices? And, what do you need to do to ensure that your organization uses the microservice architecture successfully? In this talk, I’ll answer these and other questions. You will learn about the motivations for the microservice architecture and why simply adopting microservices is insufficient. I describe essential characteristics of microservices, You will learn how a successful microservice architecture consists of loosely coupled services with stable APIs that communicate asynchronously.
GraphSummit Singapore | The Art of the Possible with Graph - Q2 2024Neo4j
Neha Bajwa, Vice President of Product Marketing, 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.
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfPaige Cruz
Monitoring and observability aren’t traditionally found in software curriculums and many of us cobble this knowledge together from whatever vendor or ecosystem we were first introduced to and whatever is a part of your current company’s observability stack.
While the dev and ops silo continues to crumble….many organizations still relegate monitoring & observability as the purview of ops, infra and SRE teams. This is a mistake - achieving a highly observable system requires collaboration up and down the stack.
I, a former op, would like to extend an invitation to all application developers to join the observability party will share these foundational concepts to build on:
Pushing the limits of ePRTC: 100ns holdover for 100 daysAdtran
At WSTS 2024, Alon Stern explored the topic of parametric holdover and explained how recent research findings can be implemented in real-world PNT networks to achieve 100 nanoseconds of accuracy for up to 100 days.
Climate Impact of Software Testing at Nordic Testing DaysKari Kakkonen
My slides at Nordic Testing Days 6.6.2024
Climate impact / sustainability of software testing discussed on the talk. ICT and testing must carry their part of global responsibility to help with the climat warming. We can minimize the carbon footprint but we can also have a carbon handprint, a positive impact on the climate. Quality characteristics can be added with sustainability, and then measured continuously. Test environments can be used less, and in smaller scale and on demand. Test techniques can be used in optimizing or minimizing number of tests. Test automation can be used to speed up testing.
Removing Uninteresting Bytes in Software FuzzingAftab Hussain
Imagine a world where software fuzzing, the process of mutating bytes in test seeds to uncover hidden and erroneous program behaviors, becomes faster and more effective. A lot depends on the initial seeds, which can significantly dictate the trajectory of a fuzzing campaign, particularly in terms of how long it takes to uncover interesting behaviour in your code. We introduce DIAR, a technique designed to speedup fuzzing campaigns by pinpointing and eliminating those uninteresting bytes in the seeds. Picture this: instead of wasting valuable resources on meaningless mutations in large, bloated seeds, DIAR removes the unnecessary bytes, streamlining the entire process.
In this work, we equipped AFL, a popular fuzzer, with DIAR and examined two critical Linux libraries -- Libxml's xmllint, a tool for parsing xml documents, and Binutil's readelf, an essential debugging and security analysis command-line tool used to display detailed information about ELF (Executable and Linkable Format). Our preliminary results show that AFL+DIAR does not only discover new paths more quickly but also achieves higher coverage overall. This work thus showcases how starting with lean and optimized seeds can lead to faster, more comprehensive fuzzing campaigns -- and DIAR helps you find such seeds.
- These are slides of the talk given at IEEE International Conference on Software Testing Verification and Validation Workshop, ICSTW 2022.
Threats to mobile devices are more prevalent and increasing in scope and complexity. Users of mobile devices desire to take full advantage of the features
available on those devices, but many of the features provide convenience and capability but sacrifice security. This best practices guide outlines steps the users can take to better protect personal devices and information.
Securing your Kubernetes cluster_ a step-by-step guide to success !KatiaHIMEUR1
Today, after several years of existence, an extremely active community and an ultra-dynamic ecosystem, Kubernetes has established itself as the de facto standard in container orchestration. Thanks to a wide range of managed services, it has never been so easy to set up a ready-to-use Kubernetes cluster.
However, this ease of use means that the subject of security in Kubernetes is often left for later, or even neglected. This exposes companies to significant risks.
In this talk, I'll show you step-by-step how to secure your Kubernetes cluster for greater peace of mind and reliability.
Dr. Sean Tan, Head of Data Science, Changi Airport Group
Discover how Changi Airport Group (CAG) leverages graph technologies and generative AI to revolutionize their search capabilities. This session delves into the unique search needs of CAG’s diverse passengers and customers, showcasing how graph data structures enhance the accuracy and relevance of AI-generated search results, mitigating the risk of “hallucinations” and improving the overall customer journey.
Communications Mining Series - Zero to Hero - Session 1DianaGray10
This session provides introduction to UiPath Communication Mining, importance and platform overview. You will acquire a good understand of the phases in Communication Mining as we go over the platform with you. Topics covered:
• Communication Mining Overview
• Why is it important?
• How can it help today’s business and the benefits
• Phases in Communication Mining
• Demo on Platform overview
• Q/A
Generative AI Deep Dive: Advancing from Proof of Concept to ProductionAggregage
Join Maher Hanafi, VP of Engineering at Betterworks, in this new session where he'll share a practical framework to transform Gen AI prototypes into impactful products! He'll delve into the complexities of data collection and management, model selection and optimization, and ensuring security, scalability, and responsible use.
GraphSummit Singapore | The Future of Agility: Supercharging Digital Transfor...Neo4j
Leonard Jayamohan, Partner & Generative AI Lead, Deloitte
This keynote will reveal how Deloitte leverages Neo4j’s graph power for groundbreaking digital twin solutions, achieving a staggering 100x performance boost. Discover the essential role knowledge graphs play in successful generative AI implementations. Plus, get an exclusive look at an innovative Neo4j + Generative AI solution Deloitte is developing in-house.
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf91mobiles
91mobiles recently conducted a Smart TV Buyer Insights Survey in which we asked over 3,000 respondents about the TV they own, aspects they look at on a new TV, and their TV buying preferences.
Sudheer Mechineni, Head of Application Frameworks, Standard Chartered Bank
Discover how Standard Chartered Bank harnessed the power of Neo4j to transform complex data access challenges into a dynamic, scalable graph database solution. This keynote will cover their journey from initial adoption to deploying a fully automated, enterprise-grade causal cluster, highlighting key strategies for modelling organisational changes and ensuring robust disaster recovery. Learn how these innovations have not only enhanced Standard Chartered Bank’s data infrastructure but also positioned them as pioneers in the banking sector’s adoption of graph technology.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...James Anderson
Effective Application Security in Software Delivery lifecycle using Deployment Firewall and DBOM
The modern software delivery process (or the CI/CD process) includes many tools, distributed teams, open-source code, and cloud platforms. Constant focus on speed to release software to market, along with the traditional slow and manual security checks has caused gaps in continuous security as an important piece in the software supply chain. Today organizations feel more susceptible to external and internal cyber threats due to the vast attack surface in their applications supply chain and the lack of end-to-end governance and risk management.
The software team must secure its software delivery process to avoid vulnerability and security breaches. This needs to be achieved with existing tool chains and without extensive rework of the delivery processes. This talk will present strategies and techniques for providing visibility into the true risk of the existing vulnerabilities, preventing the introduction of security issues in the software, resolving vulnerabilities in production environments quickly, and capturing the deployment bill of materials (DBOM).
Speakers:
Bob Boule
Robert Boule is a technology enthusiast with PASSION for technology and making things work along with a knack for helping others understand how things work. He comes with around 20 years of solution engineering experience in application security, software continuous delivery, and SaaS platforms. He is known for his dynamic presentations in CI/CD and application security integrated in software delivery lifecycle.
Gopinath Rebala
Gopinath Rebala is the CTO of OpsMx, where he has overall responsibility for the machine learning and data processing architectures for Secure Software Delivery. Gopi also has a strong connection with our customers, leading design and architecture for strategic implementations. Gopi is a frequent speaker and well-known leader in continuous delivery and integrating security into software delivery.
Alt. GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using ...
Building Rich Domain Models
1. Improving Application Design
with a Rich Domain Model
Chris Ri h d
Ch i Richardson
Author of POJOs in Action
Chris Richardson Consulting, Inc
http://www.chrisrichardson.net
p //
3/1/2009 Slide 1
Copyright (c) 2007 Chris Richardson. All rights reserved.
2. Overall presentation g
p goal
Learn how to improve application
design by using truly object-
g y g y j
oriented business logic
3/1/2009 2
Copyright (c) 2007 Chris Richardson. All rights reserved.
3. About Chris
Grew up in England
Live in Oakland, CA
Over twenty years of software
development experience
Building object-oriented
software since 1986
Using Java since 1996
Using J2EE since 1999
Author of POJOs in Action
Speaker at JavaOne, JavaPolis,
NFJS, JUGs, ….
Chair of the eBIG Java SIG in
Oakland (www.ebig.org)
Run a consulting and training
company that helps
organizations build better
software faster
3/1/2009 3
Copyright (c) 2007 Chris Richardson. All rights reserved.
4. Agenda
g
Where are the real objects?
Wh th l bj t ?
Overview of the Domain Model pattern
Domain model building blocks
Role of frameworks
Obstacles to OO
Eliminating common code smells
Refactoring existing code
3/1/2009 4
Copyright (c) 2007 Chris Richardson. All rights reserved.
5. Objects in LISP (
j (1987-1993)
)
(defclass Account ()
((account-id :accessor account-id :initarg :account-id)
State
(balance :accessor account-balance :initarg :balance))
+
)
Behavior
(defmethod debit ((Account account) amount)
(decf (account-balance account) amount))
(defmethod credit ((Account account) amount)
(incf (account balance account) amount))
(account-balance
CL-USER 5 > (setq a (make-instance 'account :account-id quot;abc123quot; :balance 10.0))
#<ACCOUNT 200C05AF>
CL-USER 6 > (describe a)
#<ACCOUNT 200C05AF> is an ACCOUNT
ACCOUNT-ID quot;abc123quot;
BALANCE 10.0
CL-USER
CL USER 7 > (debit a 5)
5.0
CL-USER 8 > (describe a)
#<ACCOUNT 200C05AF> is an ACCOUNT
ACCOUNT-ID
ACCOUNT ID quot; b 123quot;
quot;abc123quot;
BALANCE 5.0
3/1/2009 5
Copyright (c) 2007 Chris Richardson. All rights reserved.
6. Objects in C++ (
j (1993-1996)
)
#ifndef ACCOUNT_H_
#define ACCOUNT_H_
class Account {
public:
Account(char* account_id, double balance);
void debit(double amount);
void credit(double amount);
double getBalance();
private:
char* account_id;
State
double balance;
};
+
#endif /*ACCOUNT_H_*/
Behavior
#include quot;Account.hquot;
#incl de quot;Acco nt hquot;
Account::Account(char* account_id, double balance) {
…
}
void Account::debit (double amount) {
balance -= amount;
bl
}
void Account::credit(double amount) {
balance += amount;
}
double Account::getBalance() { return balance; }
3/1/2009 6
Copyright (c) 2007 Chris Richardson. All rights reserved.
7. Objects in Java (
j (1996-1999)
)
public class Account {
private int id;
private double balance;
private OverdraftPolicy overdraftPolicy;
State
private String accountId;
+
private CalendarDate dateOpened;
Behavior
Account() {
}
p
public void debit(double amount) {
( )
assert amount > 0;
double originalBalance = balance;
double newBalance = balance - amount;
overdraftPolicy.beforeDebitCheck(this, originalBalance,
newBalance);
balance = newBalance;
overdraftPolicy.afterDebitAction(this, originalBalance, newBalance);
d ftP li ft D bitA ti (thi i i lB l Bl )
}
public void credit(double amount) {
assert amount > 0;
balance += amount;
}
3/1/2009 7
Copyright (c) 2007 Chris Richardson. All rights reserved.
8. EJB objects (
j (1999- ?)
)
Applications were still built
pp
from objects
But those objects were very
different …
3/1/2009 8
Copyright (c) 2007 Chris Richardson. All rights reserved.
9. Example Banking UI
p g
3/1/2009 9
Copyright (c) 2007 Chris Richardson. All rights reserved.
10. Example p
p procedural design
g
3/1/2009 10
Copyright (c) 2007 Chris Richardson. All rights reserved.
11. Example p
p procedural code
public class MoneyTransferServiceProceduralImpl implements MoneyTransferService { public class Account {
p
public BankingTransaction transfer(String fromAccountId, String toAccountId,
g ( g , g , p
public static final int NEVER = 1;
;
double amount) { public static final int ALLOWED = 2;
Account fromAccount = accountDAO.findAccount(fromAccountId);
Account toAccount = accountDAO.findAccount(toAccountId); private int id;
assert amount > 0; private double balance;
double newBalance = fromAccount.getBalance() - amount; private int overdraftPolicy;
switch (fromAccount.getOverdraftPolicy()) { private String accountId;
Behavior State
case Account.NEVER: private Date dateOpened;
if (newBalance < 0) private double requiredYearsOpen;
throw new MoneyTransferException(quot;In sufficient fundsquot;); private double limit;
break;
case Account.ALLOWED: Account() {}
Calendar then = Calendar.getInstance();
then.setTime(fromAccount.getDateOpened());
Calendar now = Calendar.getInstance(); public Account(String accountId, double balance, int
overdraftPolicy,
double yearsOpened = now.get(Calendar.YEAR) - then.get(Calendar.YEAR); Date dateOpened, double requiredYearsOpen,
int monthsOpened = now.get(Calendar.MONTH) - then.get(Calendar.MONTH); double limit)
if (monthsOpened < 0) { {….. }
yearsOpened--;
O d
monthsOpened += 12; public int getId() {return id;}
}
yearsOpened = yearsOpened + (monthsOpened / 12.0); public String getAccountId() {return accountId;}
if (yearsOpened < fromAccount.getRequiredYearsOpen()
|| newBalance < fromAccount.getLimit()) public void setBalance(double balance) { this.balance = balance; }
throw new MoneyTransferException(quot;Limit exceededquot;);
break; public double getBalance() { return balance; }
default:
throw new MoneyTransferException(quot;Unknown overdraft type: quot;
MoneyTransferException( Unknown public int getOverdraftPolicy() { return overdraftPolicy; }
+ fromAccount.getOverdraftPolicy());
public Date getDateOpened() { return dateOpened; }
}
fromAccount.setBalance(newBalance); public double getRequiredYearsOpen() {
toAccount.setBalance(toAccount.getBalance() + amount); return requiredYearsOpen; }
TransferTransaction txn = new TransferTransaction(fromAccount, toAccount,
amount, new Date()); public double getLimit() {return limit; }
bankingTransactionDAO.addTransaction(txn); }
return txn;
}
3/1/2009 11
Copyright (c) 2007 Chris Richardson. All rights reserved.
12. Why write code like this?
y
EJB made writing object-oriented code
difficult/impossible
diffi lt/i ibl
Implementing new functionality is easy
Add a new transaction script
i i
Add code to a new transaction script
Manipulating relational data is easier
Distribution is easier
No
N need to do any real design, e.g.
dt d ld i
Create new classes
Determine responsibilities
3/1/2009 12
Copyright (c) 2007 Chris Richardson. All rights reserved.
13. Unable to handle complexity
p y
Works well for simple business logic
E.g.
E g the example wasn’t that bad
wasn t
But with complex business logic:
Large transaction scripts: 100s/1000s LOC
Difficult/impossible to understand, test, and
maintain
What s
What’s worse: business logic has a habit
of growing
New requirements ⇒ Add a few more lines
to the transaction script
Many new requirements ⇒ big mess
Soon or later you end up with
unmaintainable code
3/1/2009 13
Copyright (c) 2007 Chris Richardson. All rights reserved.
14. The legacy of EJB
gy
Java is an object-oriented language
AND
Object-oriented design is a better way to tackle
complexity
YET
Many complex enterprise Java applications are
written in a procedural style
3/1/2009 14
Copyright (c) 2007 Chris Richardson. All rights reserved.
15. Today – rich domain models are
growing in popularity
POJOs
Plain Old Java Objects
Leverage OO features of Java
O/R mapping frameworks for
persisting POJOs:
Hibernate
Java Persistence API
…
Spring AOP and A
Si d AspectJ f
tJ for
handling cross-cutting
concerns:
Transaction management
Security
S it
Logging
Auditing
…
3/1/2009 15
Copyright (c) 2007 Chris Richardson. All rights reserved.
16. Agenda
g
Where are the real objects?
Overview of the Domain Model
pattern
Domain model building blocks
Role of frameworks
Obstacles to OO
Eliminating common code smells
g
Refactoring existing code
3/1/2009 16
Copyright (c) 2007 Chris Richardson. All rights reserved.
17. Using the Domain Model Pattern
g
Business logic spread amongst a
Bi li d t
collection of classes
Many classes correspond to real world
concepts: Order, Customer, …
Many classes are true objects having
both:
State – fields
Behavior – methods that act on the state
3/1/2009 17
Copyright (c) 2007 Chris Richardson. All rights reserved.
18. Procedural versus OO
Presentation Tier
Presentation Tier
Business Tier
Business Tier
Transaction
Scripts
Facade
(Session
Beans)
Domain Model
Data
Objects
Data Access Tier
Data Access Tier
3/1/2009 18
Copyright (c) 2007 Chris Richardson. All rights reserved.
19. An example domain model
p
Web Tier
Behavior
Business Tier
MoneyTransferService
BankingTransaction transfer(fromId, toId, amount)
from
Account
Banking Account
BankingTransaction
Transaction Repository
Repository
balance
to
amount findAccount(id)
addTransaction(…) debit(amount)
date
credit(amount)
Explicit
<<interface>>
OverdraftPolicy
Representation
State +
of key
Behavior Limited
conceptst
NoOverdraft Overdraft
Policy
limit
3/1/2009 19
Copyright (c) 2007 Chris Richardson. All rights reserved.
21. Benefits of the Domain Model
Pattern
Improved maintainability
The design reflects reality
Key domain classes are represented by
classes
The design is more modular
Improved testability
Small classes that can be tested in isolation
Improved reusability
Classes can be used in other applications
Building a domain model
Creates shared understanding
Develops an ubiquitous language
p q gg
3/1/2009 21
Copyright (c) 2007 Chris Richardson. All rights reserved.
22. Q
Quantifiably simpler code
y p
Procedural – few longer more
few, longer, Object-oriented more, simpler
Object oriented – more simpler,
complex methods shorter methods
3/1/2009 22
Copyright (c) 2007 Chris Richardson. All rights reserved.
23. Drawbacks of the Domain Model
p
pattern
Requires object-oriented design skills
Works best if domain model is
transparently “mappable” to the data
E.g. nice database schema
Ugly schemas and data stored in other
applications is a challenge
l h ll
3/1/2009 23
Copyright (c) 2007 Chris Richardson. All rights reserved.
24. When to use it
The business logic is reasonably
complex or you anticipate that it will
be
You have the skills to design one
You can either:
Use an ORM framework
Invest in writing a data access
framework
3/1/2009 24
Copyright (c) 2007 Chris Richardson. All rights reserved.
25. Agenda
g
Where are the real objects?
Wh th l bj t ?
Overview of the Domain Model pattern
Domain model building blocks
Role of frameworks
Obstacles to OO
Eliminating common code smells
Refactoring existing code
3/1/2009 25
Copyright (c) 2007 Chris Richardson. All rights reserved.
26. Domain model building blocks
g
Roles aka
stereotypes
Benefits of roles:
Guide design
Help name
objects
bj t
Aid understanding
Roles (from
Domain-Driven
Design)
3/1/2009 26
Copyright (c) 2007 Chris Richardson. All rights reserved.
27. Entity
y
Objects with a public class Account {
distinct identity private int id;
Typically correspond
private double balance;
to real world
private OverdraftPolicy overdraftPolicy;
private String accountId;
concepts private CalendarDate dateOpened;
Almost always Account() {
persistent
}
public void debit(double amount) {
Encapsulate state and assert amount > 0;
double originalBalance = balance;
behavior double newBalance = balance - amount;
overdraftPolicy.beforeDebitCheck(this, originalBalance, newBalance);
balance = newBalance;
Often modal ⇒ call overdraftPolicy.afterDebitAction(this, originalBalance, newBalance);
}
methods in a public void credit(double amount) {
particular order assert amount > 0;
balance += amount;
}
3/1/2009 27
Copyright (c) 2007 Chris Richardson. All rights reserved.
28. Value Objects
j
Objects that are
public class CalendarDate {
defined by the values private Date date;
of their attributes CalendarDate() {
}
Two instances with public CalendarDate(Date date) {
identical values can be
this.date = date;
}
used i t
d interchangeably
h bl public Date getDate() {
return date;
Two flavors }
Persistent – parts of public double getYearsOpen() {
Calendar then = Calendar.getInstance();
entities then.setTime(date);
then setTime(date);
Calendar now = Calendar.getInstance();
Transient – intermediate
values int yearsOpened = now.get(Calendar.YEAR) –
then.get(Calendar.YEAR);
Ideally immutable int monthsOpened = now.get(Calendar.MONTH) -
then.get(Calendar.MONTH);
Often missing from
Oft ii f
if (monthsOpened < 0) {
yearsOpened--;
procedural code –
monthsOpened += 12;
}
Primitive Obsession return yearsOpened + (monthsOpened/12.0);
code smell }
}
3/1/2009 28
Copyright (c) 2007 Chris Richardson. All rights reserved.
29. More examples of Value Objects
p j
public class User {
public class User {
private int id;
private String firstName;
private PersonName name;
p
private String lastName;
g ;
private UserId login;
private String login;
private Password password;
private String password;
…
…
}
}
public class Password implements Serializable {
private String passwordString;
public class PersonName { public Password(String passwordString) {
private String firstName; this.passwordString = passwordString == null ? null : passwordString.trim();
private String lastName; }
PersonName() { …
} @Override
public String t St i () {
bli St i toString()
public PersonName(String firstName, return new ToStringBuilder(this).append(quot;passwordquot;, quot;****quot;).toString();
String lastName) { }
this.firstName = firstName;
this.lastName = lastName;
}
3/1/2009 29
Copyright (c) 2007 Chris Richardson. All rights reserved.
30. Aggregates
gg g
A cluster of related
entities and values
Behaves as a unit
Has
H a root t
Has a boundary
Objects outside the
aggregate can only
reference the root
Deleting the root
removes
everything
3/1/2009 30
Copyright (c) 2007 Chris Richardson. All rights reserved.
31. Repositories
p
public interface AccountRepository {
Manages a collection of
objects Account findAccount(String accountId);
void addAccount(Account account);
Provides methods for: }
Adding an object
Finding object or objects
Deleting objects public class HibernateAccountRepository implements AccountRepository {
Consists of an interface private HibernateTemplate hibernateTemplate;
and an implementation public HibernateAccountRepository(HibernateTemplate template) {
hibernateTemplate = template;
class
l }
Encapsulates database public void addAccount(Account account) {
hibernateTemplate.save(account);
access mechanism }
Keeps the ORM public Account findAccount(final String accountId) {
return (Account) DataAccessUtils.uniqueResult(hibernateTemplate
framework out of the .findByNamedQueryAndNamedParam(
domain model
quot;Account.findAccountByAccountIdquot;, quot;accountIdquot;,
accountId));
}
Similar to a DAO }
3/1/2009 31
Copyright (c) 2007 Chris Richardson. All rights reserved.
32. Services
public interface MoneyTransferService {
Implements logic that BankingTransaction transfer(String fromAccountId,
cannot be put in a single String toAccountId, double amount);
entity }
Not persistent
p
Consists of an interface public class MoneyTransferServiceImpl implements MoneyTransferService
{
and an implementation private final AccountRepository accountRepository;
class private final BankingTransactionRepository
Service method usually: bankingTransactionRepository;
public MoneyTransferServiceImpl(AccountRepository accountRepository,
Invoked (indirectly) by BankingTransactionRepository bankingTransactionRepository) {
presentation tier this.accountRepository = accountRepository;
this.bankingTransactionRepository = bankingTransactionRepository;
Invokes one or more }
repositories public BankingTransaction transfer(String fromAccountId,
String toAccountId, double amount) {
Invokes one or more …
entities }
Keep them thin }
3/1/2009 32
Copyright (c) 2007 Chris Richardson. All rights reserved.
33. Factories
Use when a constructor is insufficient
Encapsulates complex object creation
E l l bj i
logic
Handles varying products
Different kinds of factories
Factory classes
Factory methods
Example: OrderFactory
p y
Creates Order from a shopping cart
Adds line items
3/1/2009 33
Copyright (c) 2007 Chris Richardson. All rights reserved.
34. Agenda
g
Where are the real objects?
Wh th l bj t ?
Overview of the Domain Model pattern
Domain model building blocks
Role of frameworks
Obstacles to OO
Eliminating common code smells
Refactoring existing code
3/1/2009 34
Copyright (c) 2007 Chris Richardson. All rights reserved.
35. Use the POJO programming model
pg g
Your domain model might outlive
infrastructure frameworks ⇒ Minimize
dependencies on them
POJO = Plain Old Java Object
Don't implement any infrastructure
interfaces
Don't call infrastructure APIs
No infrastructure framework
annotations?
3/1/2009 Slide 35
Copyright (c) 2007 Chris Richardson. All rights reserved.
36. Use dependency injection
p yj
Spring instantiates and wires together components:
Services, factories and repositories
S i fti d it i
Dependency injection into entities
One option is @Configurable but it’s not POJO
Use Hibernate Interceptor + manual injection instead?
Benefits:
Decouples components from one another and the
infrastructure
Improves testability
<beans>
<bean id=quot;accountServicequot;
class=quot;net.chris...domain.AccountServiceImplquot;>
public AccountServiceImpl(AccountDao accountDao, <constructor-arg ref=quot;accountDaoquot;/>
<constructor-arg ref=quot;bankingTransactionDaoquot;/>
BankingTransactionDao bankingTransactionDao) {
</bean>
this.accountDAO = accountDao;
this.bankingTransactionDAO = bankingTransactionDao; …
} </beans>
3/1/2009 Slide 36
Copyright (c) 2007 Chris Richardson. All rights reserved.
37. Use Aspect-Oriented Programming
p g g
Spring AOP for service-level
crosscutting concerns:
E.g. transaction
management, security,
logging etc.
AspectJ for entity and value
object crosscutting concerns
E.g. tracking changes to
fields
But AJC/Load-time weaving
has a cost
Benefits
Decouples code from
infrastructure
Improves modularity
3/1/2009 37
Copyright (c) 2007 Chris Richardson. All rights reserved.
38. Use object/relational mapping
j / pp g
Persisting objects
g j <class name=quot;Accountquot;
table BANK_ACCOUNT
table=quot;BANK ACCOUNTquot; >
with JDBC is usually
<id name=quot;idquot; column=quot;ACCOUNT_IDquot;>
<generator class=quot;nativequot; />
</id>
too much work <property name=quot;balancequot; />
<property name=quot;accountIdquot; />
Implement DAOs
<property name=quot;dateOpenedquot; />
<many-to-one name=quot;overdraftPolicyquot; />
</class>
with Spring ORM
Benefits public class HibernateAccountDao
implements AccountDao {
private HibernateTemplate hibernateTemplate;
Less code public HibernateAccountDao(HibernateTemplate
template) {
Simpler code
Si l d this.hibernateTemplate = template;
}
Improved testability public void addAccount(Account account) {
hibernateTemplate.save(account);
}
…
}
3/1/2009 Slide 38
Copyright (c) 2007 Chris Richardson. All rights reserved.
39. Agenda
g
Where are the real objects?
Overview of the Domain Model
pattern
Domain model building blocks
Role of frameworks
Obstacles to good OO design
Eliminating common code smells
Refactoring existing code
3/1/2009 Slide 39
Copyright (c) 2007 Chris Richardson. All rights reserved.
40. Web frameworks need Java Beans
Web frameworks can bind request
parameters directly to domain objects
Easy creation of domain objects
Easy editing of detached domain objects
asy ed g o de ac ed do a objec s
1. Load object graph from database
2. Store object graph in HttpSession
3.
3 Bind Http parameters to object's properties
4. Reattach object graph and update the database
A lot less code
But domain objects must be JavaBeans:
Public default constructor
JavaBean-style setters
Ja aBean st le sette s
3/1/2009 Slide 40
Copyright (c) 2007 Chris Richardson. All rights reserved.
41. The trouble with setters
public class Address {
Poor encapsulation private String street1;
private String street2;
Objects are now exposing public String getStreet1() {...};
their internal state public void setStreet1(String street1) {...}
…
No immutable objects }
Increases code complexity public class Order {
Makes it more error-prone private Address deliveryAddress;
Developers might b
D l i ht bypass public void updateDeliveryAddress(
Address deliveryAddress) {
business method ⇒ Bugs, // validate before changing
p
poor design
g
…
}
public Address getAddress() {…}
…
}
order.getAddress().setStreet1(quot;Bad!quot;);
3/1/2009 Slide 41
Copyright (c) 2007 Chris Richardson. All rights reserved.
42. How to cope
p
Live with it:
It's often not that bad
But be vigilant for code bypassing
business methods
bi th d
Use DTOs
Hides domain objects from web tier
But you have to write more code
Encourage the development of better
frameworks
3/1/2009 Slide 42
Copyright (c) 2007 Chris Richardson. All rights reserved.
43. More on web binding
g
Web frameworks can bind to
properties of nested objects, e.g.
order.deliveryAddress.street1
But some frameworks require that
intermediate objects to be non-null
This can impact the domain model
3/1/2009 Slide 43
Copyright (c) 2007 Chris Richardson. All rights reserved.
44. Using ORM frameworks
g
ORM frameworks can access private fields
No setters (or g
( getters) required ☺
)q
But require:
Default constructor
Non-final fields
id fields
Subtle changes:
Collection fields: null ⇒ empty
py
Embedded objects with null fields ⇒ null reference
Objects sometimes require equals()/hashCode()
Proxy-based lazy loading:
Don't access fields outside of instance ⇒ affects
equals() and hashCode()
Can affect object identity: this !=
proxyToSameObjectAsThis
3/1/2009 Slide 44
Copyright (c) 2007 Chris Richardson. All rights reserved.
45. Performance tuning changes the
design
g
Different web requests DisplayProject DisplayProject
Details ForReview
display different object Controller Controller
graphs
Display project details
ProjectCoordinator
getProject(projectId)
Display project for
approval or rejection ProjectRepository
Improve performance hibernateTemplate.get()
findProject(projectId)
by loading object
graphs using optimized
queries (e.g. fetch ProjectCoordinator
join) getProjectDetails(projectId)
getProjectForReview(projectId)
Therefore we need
multiple Dao (and
from Project p
ProjectRepository
inner join fetch p.operations
Service) methods
findProjectDetails(projectId)
findProjectForReview(projectId)
from Project p
inner join fetch p.operations
Inner join fetch p.createdBy
3/1/2009 Slide 45
Copyright (c) 2007 Chris Richardson. All rights reserved.
46. Untangling what to load from the
code
Java Data Objects (JDO) has fetch
groups
Declarative specification of the object graph
to load
Fields and related objects
Flow:
Web tier
W b ti configures f t h groups
fi fetch
Calls ProjectCoordinator.get()
O/RM loads object graph specified by active
fetch groups
Look for this feature in JPA
implementations th t evolved f
i l t ti that l d from JDO
3/1/2009 Slide 46
Copyright (c) 2007 Chris Richardson. All rights reserved.
47. Agenda
g
Where are the real objects?
Wh th l bj t ?
Overview of the Domain Model pattern
Domain model building blocks
Role of frameworks
Obstacles to OO
Eliminating common code smells
Refactoring existing code
3/1/2009 47
Copyright (c) 2007 Chris Richardson. All rights reserved.
48. Overview of code smells
Code smell = something
about the code that does not
seem right
Impacts ease of
development and testing
Some are non-OOD
Some are the consequences
of non-OOD
3/1/2009 48
Copyright (c) 2007 Chris Richardson. All rights reserved.
49. Refactoring – the cure for stinky
code
Refactoring:
Systematic way to
restructure the
code
Without changing
behavior
bh i
Essential
cleanups for
decaying code
3/1/2009 49
Copyright (c) 2007 Chris Richardson. All rights reserved.
50. Basic refactorings
g
Extract Method
Eliminates long methods
Move Method
Move a method to a
different class (field or
parameter)
Moves method to where
the data is
Push Down
Move a method into
subclasses
Optionally leave an
abstract method behind
Part of eliminating
conditional logic
…
3/1/2009 50
Copyright (c) 2007 Chris Richardson. All rights reserved.
51. Compound refactorings
p g
A sequence of simpler refactorings
Compose method
Apply Extract Method repeatedly
Use to replace long method with more readable
shorter methods
Replace Type Code With Strategy
Define GOF Strategy class for each type code
Replace C diti
Rl Conditional With P l
l Polymorphism
hi
Turn into part of a switch statement into an
overriding method in a subclass
Replace D
Rl Data Value with Object
Vl i h Obj
Move field into it’s own class
Eliminates Primitive Obsession
3/1/2009 51
Copyright (c) 2007 Chris Richardson. All rights reserved.
52. Long method
g
Methods should be
short p
public class MoneyTransferServiceProceduralImpl implements MoneyTransferService {
y p p y
public BankingTransaction transfer(String fromAccountId, String toAccountId,
double amount) {
But business logic is Account fromAccount = accountDAO.findAccount(fromAccountId);
Account toAccount = accountDAO.findAccount(toAccountId);
assert amount > 0;
concentrated in the
double newBalance = fromAccount.getBalance() - amount;
switch (fromAccount.getOverdraftPolicy()) {
case Account.NEVER:
services ⇒ long
if (newBalance < 0)
throw new MoneyTransferException(quot;In sufficient fundsquot;);
MoneyTransferException( In funds );
break;
methods
case Account.ALLOWED:
Calendar then = Calendar.getInstance();
then.setTime(fromAccount.getDateOpened());
Calendar now = Calendar.getInstance();
Long methods are double yearsOpened = now.get(Calendar.YEAR) - then.get(Calendar.YEAR);
int monthsOpened = now.get(Calendar.MONTH) - then.get(Calendar.MONTH);
difficult to:
if (monthsOpened < 0) {
yearsOpened--;
monthsOpened + 12
th O d += 12;
}
Read and understand
yearsOpened = yearsOpened + (monthsOpened / 12.0);
if (yearsOpened < fromAccount.getRequiredYearsOpen()
|| newBalance < fromAccount.getLimit())
throw new MoneyTransferException(quot;Limit exceededquot;);
Maintain break;
default:
throw new MoneyTransferException(quot;Unknown overdraft type: quot;
Test
+ fromAccount.getOverdraftPolicy());
}
Fix:
fromAccount.setBalance(newBalance);
toAccount.setBalance(toAccount.getBalance() + amount);
TransferTransaction txn = new TransferTransaction(fromAccount, toAccount,
amount, new Date());
Splitting into smaller
bankingTransactionDAO.addTransaction(txn);
return txn;
}
methods
3/1/2009 52
Copyright (c) 2007 Chris Richardson. All rights reserved.
53. Compose Method Refactoring
p g
public class MoneyTransferServiceProceduralImpl implements
MoneyTransferService {
public class MoneyTransferServiceProceduralImpl
public BankingTransaction transfer(String fromAccountId, String
implements MoneyTransferService {
toAccountId,
toAccountId double amount) {
Account fromAccount =
public BankingTransaction transfer(String fromAccountId,
accountDAO.findAccount(fromAccountId);
String toAccountId, double amount) {
Account toAccount = accountDAO.findAccount(toAccountId);
Account fromAccount =
assert amount > 0;
accountDAO.findAccount(fromAccountId);
debit(fromAccount, amount);
Account toAccount =
credit(toAccount, amount);
accountDAO.findAccount(toAccountId);
TransferTransaction txn = new
Extract
Et t
double newBalance = fromAccount getBalance() –
fromAccount.getBalance()
TransferTransaction(fromAccount, toAccount,
amount;
Method amount, new Date());
switch (fromAccount.getOverdraftPolicy()) {
bankingTransactionDAO.addTransaction(txn);
case Account.NEVER:
return txn;
…
}
break;
default:
public void debit(Account fromAccount, double amount) {
…
double newBalance = fromAccount.getBalance() –
}
amount;
fromAccount.setBalance(newBalance);
switch (fromAccount.getOverdraftPolicy()) {
toAccount.setBalance(toAccount.getBalance() +
case Account.NEVER:
amount);
…
TransferTransaction txn = new
break;
TransferTransaction(fromAccount, toAccount,
default:
amount,
amount new Date());
…
bankingTransactionDAO.addTransaction(txn);
}
return txn;
fromAccount.setBalance(newBalance);
}
}
public void credit(Account toAccount, double amount) {
toAccount.setBalance(toAccount.getBalance() +
amount);
}
3/1/2009 53
Copyright (c) 2007 Chris Richardson. All rights reserved.
54. Feature Envy
y
public class MoneyTransferServiceProceduralImpl implements MoneyTransferService {
public BankingTransaction transfer(String fromAccountId, String toAccountId, double
amount) {
Methods that are Account fromAccount = accountDAO.findAccount(fromAccountId);
Account toAccount = accountDAO.findAccount(toAccountId);
assert amount > 0;
far too interested
double newBalance = fromAccount.getBalance() - amount;
switch (fromAccount.getOverdraftPolicy()) {
case Account.NEVER:
in data belonging
if (newBalance < 0)
throw new MoneyTransferException(quot;In sufficient fundsquot;);
break;
case Account.ALLOWED:
to th
t other classes
l Calendar then = C l d
C l d th Calendar.getInstance();
tI t ()
then.setTime(fromAccount.getDateOpened());
Calendar now = Calendar.getInstance();
Results in:
double yearsOpened = now.get(Calendar.YEAR) - then.get(Calendar.YEAR);
int monthsOpened = now.get(Calendar.MONTH) - then.get(Calendar.MONTH);
if (monthsOpened < 0) {
yearsOpened--;
Poor encapsulation monthsOpened += 12;
}
yearsOpened = yearsOpened + (monthsOpened / 12.0);
Long methods
if (yearsOpened < fromAccount.getRequiredYearsOpen()
|| newBalance < fromAccount.getLimit())
throw new MoneyTransferException(quot;Limit exceededquot;);
break;
Fix by moving
default:
throw new MoneyTransferException(quot;Unknown overdraft type: quot;
+ fromAccount.getOverdraftPolicy());
methods to the
th d t th }
fromAccount.setBalance(newBalance);
class that has the
toAccount.setBalance(toAccount.getBalance() + amount);
TransferTransaction txn = new TransferTransaction(fromAccount, toAccount,
amount, new Date());
bankingTransactionDAO.addTransaction(txn);
data
return txn;
}
3/1/2009 54
Copyright (c) 2007 Chris Richardson. All rights reserved.
55. Data class
public class Account {
public static final int NEVER = 1;
Classes that are public static final int ALLOWED = 2;
private int id;
just getters and private double balance;
private int overdraftPolicy;
private String accountId;
setters private Date dateOpened;
private double requiredYearsOpen;
p
private double limit;
;
No business logic - Account() {}
it’s in the service public Account(String accountId, double balance, int overdraftPolicy,
Date dateOpened, double requiredYearsOpen, double limit)
{….. }
Leads to: public int getId() {return id;}
Feature envy public String getAccountId() {return accountId;}
public void setBalance(double balance) { this.balance = balance; }
Fix by moving
y g public double getBalance() { return balance; }
methods that act
public int getOverdraftPolicy() { return overdraftPolicy; }
public Date getDateOpened() { return dateOpened; }
on data into class public double getRequiredYearsOpen() { return requiredYearsOpen; }
public double getLimit() {return limit; }
}
3/1/2009 55
Copyright (c) 2007 Chris Richardson. All rights reserved.
56. Move Method refactoring
g
public class MoneyTransferServiceProceduralImpl implements
MoneyTransferService {
public class MoneyTransferServiceProceduralImpl implements MoneyTransferService {
public BankingTransaction transfer(String fromAccountId, String
public BankingTransaction transfer(String fromAccountId, String toAccountId, double
toAccountId,
toAccountId double amount) {
amount) {
Account fromAccount = accountDAO.findAccount(fromAccountId);
Account fromAccount =
Account toAccount = accountDAO.findAccount(toAccountId);
accountDAO.findAccount(fromAccountId);
assert amount > 0;
double newBalance = fromAccount.getBalance() - amount;
Account toAccount = accountDAO.findAccount(toAccountId);
switch (fromAccount.getOverdraftPolicy()) {
assert amount > 0;
case Account.NEVER:
if (newBalance < 0)
fromAccount.debit(amount);
throw new MoneyTransferException(quot;In sufficient fundsquot;);
toAccount.credit(amount);
break;
case Account.ALLOWED:
TransferTransaction txn = new
Calendar then = Calendar.getInstance();
TransferTransaction(fromAccount, toAccount,
then.setTime(fromAccount.getDateOpened());
Calendar now = Calendar.getInstance();
amount, new Date());
bankingTransactionDAO.addTransaction(txn);
double yearsOpened = now.get(Calendar.YEAR) - then.get(Calendar.YEAR);
int monthsOpened = now.get(Calendar.MONTH) - then.get(Calendar.MONTH);
return txn;
if (monthsOpened < 0) {
}
yearsOpened--;
monthsOpened += 12;
}
yea sOpe ed
yearsOpened = yearsOpened + (monthsOpened / 12.0);
yea sOpe ed ( o t sOpe ed 0);
if (yearsOpened < fromAccount.getRequiredYearsOpen()
|| newBalance < fromAccount.getLimit())
throw new MoneyTransferException(quot;Limit exceededquot;);
public class Account {
break;
public void debit(fAccount fromAccount, double amount) {
default:
throw new MoneyTransferException(quot;Unknown overdraft type: quot;
double newBalance = getBalance() – amount;
+ fromAccount.getOverdraftPolicy());
switch (getOverdraftPolicy()) {
}
….
fromAccount.setBalance(newBalance);
}
toAccount.setBalance(toAccount.getBalance()
toAccount setBalance(toAccount getBalance() + amount);
TransferTransaction txn = new TransferTransaction(fromAccount, toAccount,
setBalance(newBalance);
amount, new Date());
}
bankingTransactionDAO.addTransaction(txn);
return txn;
}
public void credit(Account toAccount, double amount) {
setBalance(getBalance() + amount);
}
Extract and move feature envy
code into data class
3/1/2009 56
Copyright (c) 2007 Chris Richardson. All rights reserved.
57. Primitive Obsession
public class Account {
Code uses built- private Date dateOpened;
}
in types instead
yp
of application
public class Account {
private Date dateOpened;
classes
}
public class MoneyTransferServiceProceduralImpl
Consequences:
q implements MoneyTransferService {
public BankingTransaction transfer(String f
f fromAccountId,
Reduces String toAccountId,
double amount) {
understandability Account fromAccount = accountDAO.findAccount(fromAccountId);
Account toAccount = accountDAO.findAccount(toAccountId);
Long methods …
Calendar then = Calendar.getInstance();
Code duplication
C d d li ti then.setTime(fromAccount.getDateOpened());
th tTi (f A t tD t O d())
Calendar now = Calendar.getInstance();
Added double yearsOpened = now.get(Calendar.YEAR) -
complexity then.get(Calendar.YEAR);
int monthsOpened = now.get(Calendar.MONTH) –
Fix by moving
then.get(Calendar.MONTH);
if (monthsOpened < 0) {
data and code
yearsOpened--;
monthsOpened += 12;
}
into new class yearsOpened = yearsOpened + (monthsOpened / 12.0);
if (yearsOpened < fromAccount.getRequiredYearsOpen()
|| newBalance < fromAccount.getLimit())
…
}
3/1/2009 57
Copyright (c) 2007 Chris Richardson. All rights reserved.
58. Replace Data Value with Object
p j
public class CalendateDate {
private Date dateOpened;
public class Account { Date getDateOpened( return dateOpened; }
private Date dateOpened; }
}
public class Account {
private CalendateDate dateOpened;
Move Method public double getYearsOpen() {
Calendar then = Calendar.getInstance();
then.setTime(dateOpened.getDateOpened());
public class Account {
Calendar now = Calendar.getInstance();
private CalendateDate dateOpened;
double yearsOpened = now.get(Calendar.YEAR) -
public double getYearsOpen() {
then.get(Calendar.YEAR);
return dateOpened.getYearsOpened();
int monthsOpened = now.get(Calendar.MONTH) –
}
then.get(Calendar.MONTH);
if (monthsOpened < 0) {
yearsOpened--;
public class CalendateDate {
monthsOpened += 12;
private Date dateOpened;
}
yearsOpened = yearsOpened +
public double getYearsOpen() {
(monthsOpened / 12.0);
return yearsOpened;
t O d
Calendar then = Calendar.getInstance();
}
yearsOpened = yearsOpened +
(monthsOpened / 12.0);
return yearsOpened;
}
}
3/1/2009 58
Copyright (c) 2007 Chris Richardson. All rights reserved.
59. Switch Statements
Use of type codes and public class Account {
switch statements instead p
public static final int NEVER = 1;
;
of polymorphism public static final int ALLOWED = 2;
Key concepts are private int overdraftPolicy ;
…
represented by type codes
instead of classes
public class MoneyTransferServiceProceduralImpl
Consequences:
C implements MoneyTransferService {
Longer methods
public BankingTransaction transfer(String
Poor maintainability caused
fromAccountId, String toAccountId,
by code duplication
double amount) {
Increased code complexity …
Fix by introducing class switch (fromAccount.getOverdraftPolicy()) {
case Account.NEVER:
hierarchy and moving …
each part of switch break;
statement into a case Account ALLOWED:
Account.ALLOWED:
overriding method …
default:
…
}
…
}
3/1/2009 59
Copyright (c) 2007 Chris Richardson. All rights reserved.
60. Replace Type Code with Strategy
p yp gy
public class Account {
public static final int NEVER = 1;
public static final int ALLOWED = 2;
public class MoneyTransferServiceProceduralImpl … {
private OverdraftPolicy overdraftPolicy;
… public BankingTransaction transfer(String fromAccountId,
String toAccountId,
double amount) {
)
…
switch (fromAccount.getOverdraftPolicy().getTypeCode())
{
case Account.NEVER:
…
break;
b k
case Account.ALLOWED:
…
default:
…
}
…
}
3/1/2009 60
Copyright (c) 2007 Chris Richardson. All rights reserved.
61. Replace Conditional with
Polymorphism
y p
Extract/Move public class MoneyTransferServiceProceduralImpl … {
Method public BankingTransaction transfer( ) {
transfer(…)
…
fromAccount.getOverdraftPolicy().beforeDebitCheck(…);
…
}
Push Down
& simplify
3/1/2009 61
Copyright (c) 2007 Chris Richardson. All rights reserved.
62. Data clumps
p
Multiple fields or public class A
bli l Account {
t
method
parameters that public static final int NEVER = 1;
public static final int ALLOWED = 2;
belong together
Consequences: private int id;
private double balance;
Long methods private String accountId;
Duplication
D li ti private Date dateOpened;
Fix by: private int overdraftPolicy;
Moving fields into private double requiredYearsOpen;
their
th i own class
l private double limit;
Eliminate resulting Account() {}
Feature Envy
}
3/1/2009 62
Copyright (c) 2007 Chris Richardson. All rights reserved.
63. Extract Class
public class Account {
public static final int NEVER = 1;
public static final int ALLOWED = 2;
private int id;
Move Field private double balance;
private String accountId;
private Date dateOpened;
private OverdraftPolicy overdraftPolicy;
Account() {}
}
pub c c ass O e d a t o cy
public class OverdraftPolicy {
private int overdraftPolicy;
private double requiredYearsOpen;
p
private double limit;
;
…
3/1/2009 63
Copyright (c) 2007 Chris Richardson. All rights reserved.
64. Agenda
g
Where are the real objects?
Overview of the Domain Model
pattern
Domain model building blocks
Role of frameworks
Obstacles to OO
Eliminating common code smells
Refactoring existing code
3/1/2009 64
Copyright (c) 2007 Chris Richardson. All rights reserved.
65. Transforming p
g procedural code
Inside every procedural design is a
domain model just trying to get out
Incrementally transform a procedural
design into an OO design
Small, localized changes
Something to do on Monday morning!
3/1/2009 65
Copyright (c) 2007 Chris Richardson. All rights reserved.
67. Summary
y
A rich domain model:
Organizes the business logic as
classes with state AND behavior
Improves maintainability and
I i t i bilit d
testability
Enabled by POJOs and non invasive
non-invasive
frameworks (mostly)
Emerges from procedural code by
incremental refactoring
Use it – starting monday!
3/1/2009 67
Copyright (c) 2007 Chris Richardson. All rights reserved.
68. For more information
Buy my book ☺
Send email:
chris@chrisrichardson.net
Visit my website:
http://www.chrisrichardson.
net
Talk to me about
consulting and training
g g
3/1/2009 68
Copyright (c) 2007 Chris Richardson. All rights reserved.