Lecture 11 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Describes goods and bads of software architecture as well as common design patterns.
YouTube Link: https://youtu.be/C_oPLDaSy-8
**Java, J2EE & SOA Certification Training - https://www.edureka.co/java-j2ee-training-course **
This Edureka PPT on "design patterns in java" will provide you with detailed knowledge about Java Design Patterns and along with it, This PPT will also cover some real-time examples of some important Design Patterns in Java, in order to provide you with a deep understanding about their functionality. This PPT will cover the following topics:
Why do we need Design Patterns?
What are Design Patterns?
Structure of a Design Pattern
Types of Design Patterns
Creational Design Pattern
Structural Design Pattern
Behavioural Design Pattern
JEE Design Pattern
Overview of design patterns
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
oops concept in java | object oriented programming in javaCPD INDIA
object oriented programming is a key concept for the development of application in windows as well as web based application environment. oops concept maps real world through its concept of classes, objects, inheritance, polymorphism which help in making a robust application.
YouTube Link: https://youtu.be/C_oPLDaSy-8
**Java, J2EE & SOA Certification Training - https://www.edureka.co/java-j2ee-training-course **
This Edureka PPT on "design patterns in java" will provide you with detailed knowledge about Java Design Patterns and along with it, This PPT will also cover some real-time examples of some important Design Patterns in Java, in order to provide you with a deep understanding about their functionality. This PPT will cover the following topics:
Why do we need Design Patterns?
What are Design Patterns?
Structure of a Design Pattern
Types of Design Patterns
Creational Design Pattern
Structural Design Pattern
Behavioural Design Pattern
JEE Design Pattern
Overview of design patterns
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
oops concept in java | object oriented programming in javaCPD INDIA
object oriented programming is a key concept for the development of application in windows as well as web based application environment. oops concept maps real world through its concept of classes, objects, inheritance, polymorphism which help in making a robust application.
Je vous partage l'un des présentations que j'ai réalisé lorsque j'étais élève ingénieur pour le module 'Anglais Business ' , utile pour les étudiants souhaitant préparer une présentation en anglais sur les Design Pattern - ou les patrons de conception .
In these slides i have explained an important design pattern that is "singleton pattern".
slides includes everything required about it, from definition to implementation and also different ways to achieve it according to situation and requirements.
Je vous partage l'un des présentations que j'ai réalisé lorsque j'étais élève ingénieur pour le module 'Anglais Business ' , utile pour les étudiants souhaitant préparer une présentation en anglais sur les Design Pattern - ou les patrons de conception .
In these slides i have explained an important design pattern that is "singleton pattern".
slides includes everything required about it, from definition to implementation and also different ways to achieve it according to situation and requirements.
PATTERNS05 - Guidelines for Choosing a Design PatternMichael Heron
An discussion about choosing design patterns in object orientation. Suitable for intermediate to advanced computing students and those studying software engineering.
Adapter Pattern is an example of some Demo implementations for OOP PHP Design Patterns in the Drupal 7 and Drupal 8 environments. Presentation at the Toronto Drupal Group
in these slides i have explained the Abstract Factory Design pattern. slides includes definition, explanation and then implementation by code examples.
Lecture 15 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Gives an overview of more advanced Java topics.
Lecture 6 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Gives an overview how a software developer should organize their daily work, apart from technical skills.
Introduces Agile software development practices from XP and Scrum.
Lecture 14 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
My lecture slides in Advanced Programming with Java course in K.N. Toosi University of Technology about JavaFX.
In this slides I described the basic concept of JavaFX like Shapes, Observer Pattern, Even-Driven Programming and more.
In the Part II I'll describe more advanced topic like FXML applications and CSS styling and more... .
In this session you will learn:
1. Principles of Object-Oriented Programming
2. Writing your first Java Application
3. Elements of Java programming language
4. Built in Data Types
5. Conditional Statements
6. Loops
In this core java training session, you will learn Elements of Java programming. Topics covered in this session are:
• Quick review of some important concepts from last class
• History of Java
• JDK and JRE
• Byte Code and JVM (Java Virtual Machine)
• Platform Independence
• Principles of Object Oriented Programming
• Writing your first Java Application
• Elements of Java programming language
• Built in Data Types
• Conditional Statements
• Loops
For more information about this course visit on this link: https://www.mindsmapped.com/courses/software-development/learn-java-fundamentals-hands-on-training-on-core-java-concepts/
Object Oriented Methodology (OOM) is a system development approach encouraging and facilitating re-use of software components. We enforce our concern on components re-usability of existing component using Java Language .
JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. It was developed by James Gosling and Patrick Naughton. It is a simple programming language. Writing, compiling and debugging a program is easy in java. It helps to create modular programs and reusable code.
Introduction To Java Programming_ A Beginner's Guide_16_06_23.pdfvibinjackson
"Python Fundamentals: A Beginner's Guide to Python Concepts" is an introductory article that covers the essential concepts and principles of Python programming. It provides beginners with a solid foundation in Python syntax, data types, control flow, functions, and object-oriented programming. The article aims to equip readers with the necessary knowledge to start writing their own Python programs and prepares them for more advanced Python topics and application development.
Lecture 13 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Java Course 12: XML & XSL, Web & ServletsAnton Keks
Lecture 12 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Lecture 10 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Java Course 7: Text processing, Charsets & EncodingsAnton Keks
Lecture 7 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Do you know the difference between charset & encoding? Every programmer nowadays MUST understand these terms, how they work, and how to use them. Otherwise we constantly face broken software refusing to work with international characters properly.
Lecture 3 from the IAG0040 Java course in TTÜ.
See the accompanying source code written during the lectures: https://github.com/angryziber/java-course
Discusses more Java basics and Object Oriented Programming.
Interactive technical talk for the Agile Saturday VI.
Accompanied with live coding. All code is available on github: https://github.com/angryziber/patterns
Talk from Agile Saturday 3 event in Estonia.
It is about being professional in general as well as following agile best practices, such as build automation and continuous integration.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
Epistemic Interaction - tuning interfaces to provide information for AI supportAlan Dix
Paper presented at SYNERGY workshop at AVI 2024, Genoa, Italy. 3rd June 2024
https://alandix.com/academic/papers/synergy2024-epistemic/
As machine learning integrates deeper into human-computer interactions, the concept of epistemic interaction emerges, aiming to refine these interactions to enhance system adaptability. This approach encourages minor, intentional adjustments in user behaviour to enrich the data available for system learning. This paper introduces epistemic interaction within the context of human-system communication, illustrating how deliberate interaction design can improve system understanding and adaptation. Through concrete examples, we demonstrate the potential of epistemic interaction to significantly advance human-computer interaction by leveraging intuitive human communication strategies to inform system design and functionality, offering a novel pathway for enriching user-system engagements.
DevOps and Testing slides at DASA ConnectKari Kakkonen
My and Rik Marselis slides at 30.5.2024 DASA Connect conference. We discuss about what is testing, then what is agile testing and finally what is Testing in DevOps. Finally we had lovely workshop with the participants trying to find out different ways to think about quality and testing in different parts of the DevOps infinity loop.
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...UiPathCommunity
💥 Speed, accuracy, and scaling – discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Mining™:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing – with little to no training required
Get an exclusive demo of the new family of UiPath LLMs – GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
👨🏫 Andras Palfi, Senior Product Manager, UiPath
👩🏫 Lenka Dulovicova, Product Program Manager, UiPath
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties – USA
Expansion of bot farms – how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks – Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
LF Energy Webinar: Electrical Grid Modelling and Simulation Through PowSyBl -...DanBrown980551
Do you want to learn how to model and simulate an electrical network from scratch in under an hour?
Then welcome to this PowSyBl workshop, hosted by Rte, the French Transmission System Operator (TSO)!
During the webinar, you will discover the PowSyBl ecosystem as well as handle and study an electrical network through an interactive Python notebook.
PowSyBl is an open source project hosted by LF Energy, which offers a comprehensive set of features for electrical grid modelling and simulation. Among other advanced features, PowSyBl provides:
- A fully editable and extendable library for grid component modelling;
- Visualization tools to display your network;
- Grid simulation tools, such as power flows, security analyses (with or without remedial actions) and sensitivity analyses;
The framework is mostly written in Java, with a Python binding so that Python developers can access PowSyBl functionalities as well.
What you will learn during the webinar:
- For beginners: discover PowSyBl's functionalities through a quick general presentation and the notebook, without needing any expert coding skills;
- For advanced developers: master the skills to efficiently apply PowSyBl functionalities to your real-world scenarios.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...
Java Course 11: Design Patterns
1. Java course - IAG0040
Design Patterns
Anton Keks 2011
2. The Increasing Complexity
Complexity of software systems
Time
New programming paradigms
Higher level of abstraction
HW Assembler Structural P. (DSL, AOP?)
CPUs Procedural P. OOP ...
Java course – IAG0040 Lecture 11
Anton Keks Slide 2
3. The emerge of OOP
●
Response to complexity
● Software crisis: difficulty of writing correct,
understandable, and verifiable programs
●
Emphasizes modularity & reusability
●
Solves the “Tramp Data” problem
●
Closer to the Real World
●
Program == cooperating objects,
not a list of instructions
Java course – IAG0040 Lecture 11
Anton Keks Slide 3
4. What are design patterns?
●
Anywhere in the world you can find recurring
patterns
●
Design patterns
– are building blocks of a system's architecture
– are recurring solutions to design problems
that you see over
– identify and specify abstractions that are
above the level of single classes and instances
Java course – IAG0040 Lecture 11
Anton Keks Slide 4
5. Where do they come from?
●
First referenced in early 80's,
with the emerge of OOP
● Formally defined in 1994 in the GOF book
(even before Java!)
●
Hundreds more have been identified since
then
●
Are usually discovered (through pattern-
mining) rather than invented
Java course – IAG0040 Lecture 11
Anton Keks Slide 5
6. GOF (Gang of Four) book
●
Title: Design Patterns:
Elements of Reusable
Object-Oriented
Software
●
Is the first and essential
book on patterns
●
Patterns are well
classified and described
● Every professional
software developer must
know them
Java course – IAG0040 Lecture 11
Anton Keks Slide 6
7. MVC
●
Model-View-Controller
●
One of the first patterns, comes from Smalltalk language
●
Is a “best practice” of splitting GUI applications into
– Model - holds/stores data and provides data access interface
– View - displays data to the user obtained from the model
– Controller - manipulates the model, selects appropriate views
● Therefore, the code consists of three decoupled layers, which
can work together or independently
● Any of the layers can be modified/rewritten without
modifications to other layers
Java course – IAG0040 Lecture 11
Anton Keks Slide 7
8. Pattern classification
● The GOF book defines 3 major types of patterns:
– Creational patterns are ones that create objects for
you, rather than having you instantiate objects directly.
This gives your program more flexibility in deciding
which objects need to be created for a given case.
– Structural patterns help you compose groups of objects
into larger structures, such as complex user interfaces
or accounting data.
– Behavioral patterns help you define the
communication between objects in your system and
how the flow is controlled in a complex program.
Java course – IAG0040 Lecture 11
Anton Keks Slide 8
9. Anti-patterns
●
This term is also widely used to define certain
patterns, which should be avoided in software design
●
Anti-patterns (aka pitfalls) are commonly reinvented
bad solutions to problems
●
Knowing anti-patterns is as important as knowing
patterns
● Another term used in Agile Software Development is
code smell (eliminated by refactoring)
●
See Wikipedia articles on both Anti-pattern and
Code smell for more info and examples
Java course – IAG0040 Lecture 11
Anton Keks Slide 9
10. Software Design vs Architecture
●
Software design is the structure of code and
relations between its elements (classes)
● Software architecture is the same as software
design, but used when people want to make it
look important (after Martin Fowler)
– Architecture is the part of design that is
difficult to change
– Therefore it is undesired :-)
Java course – IAG0040 Lecture 11
Anton Keks Slide 10
11. Some design considerations
●
Thinking about design is very important at all
stages during a project. If it needs corrections
then refactoring should be used
●
Consistent API and loosely coupled code are
very important - they make changes easy
●
Unit tests and TDD help a lot
●
Design patterns help make your design better
and more understandable to others
Java course – IAG0040 Lecture 11
Anton Keks Slide 11
12. General concepts of design
●
Fundamental reason for patterns: keep classes
separated, prevent them from knowing too much
about each other
●
Abstract classes and interfaces are major tools
●
Program to interfaces, not to implementations
● Prefer object composition to inheritance; it usually
results in cleaner code (this is simply a construction
of objects that contain others)
– Delegation may be used for reusing “parent” behavior
Java course – IAG0040 Lecture 11
Anton Keks Slide 12
13. Iterator
●
Behavioral pattern, synonym: Cursor
●
You already know it from the Collections API!
●
Iterator provides a way for accessing elements of an
aggregate object sequentially without exposing its
underlying representation
●
Iterator is a special object provided by an aggregate
object for holding of iteration state
– better than if aggregate objects change their state during
iteration (e.g. provide their own next() methods)
– better than index-based element access - hides
implementation details
– several iterators may be used at once on the same data
Java course – IAG0040 Lecture 11
Anton Keks Slide 13
14. Lazy Initialization
●
The idea is to initialize “expensive” objects on demand, e.g.
only when they are accessed (this is sometimes referred to as
“caching”)
– if expensive object is never accessed then it is never created
● If initialization takes time and several threads access the object,
then synchronization is needed
● Double-checked locking is a clever (but broken) trick:
– public Object getExpensiveObject() {
if (instance == null) {
synchronized (this) {
if (instance == null)
instance = new ...
}
}
return instance;
}
Java course – IAG0040 Lecture 11
Anton Keks Slide 14
15. Singleton
●
Creational pattern, sometimes uses lazy initialization
●
Ensures a class has only one instance, and provides
global access point to it
● public class Singleton {
private Singleton() {} // private constructor
private static Singleton uniqueInstance =
new Singleton();
public static Singleton getInstance() {
return uniqueInstance;
// can be lazily initialized
}
}
Java course – IAG0040 Lecture 11
Anton Keks Slide 15
16. Singleton (2)
● Better than global variables (controlled access,
doesn't pollute namespace)
● More flexible than class operations (static
methods): can be polymorphic and subclassed,
permits easy design changes, etc
● Disadvantages: may result in coupled code, if
used directly too much. Difficult to mock in unit
tests
● (better alternative – use singletons in an IoC
container, like PicoContainer or Spring)
Java course – IAG0040 Lecture 11
Anton Keks Slide 16
17. Factory Method
● Creational pattern, synonyms: Factory, Virtual
Constructor
● Defines an interface for creating an object of
particular abstract type, but lets subclasses decide
which concrete class to instantiate
● Used by many modern frameworks and APIs (e.g.
SAXParserFactory)
● public class BulldogFactory implements DogFactory {
public Dog createDog() { return new Bulldog(); } }
● public class DachshundFactory implements DogFactory {
public Dog createDog() {
return new Dachshund(); } }
Java course – IAG0040 Lecture 11
Anton Keks Slide 17
18. Factory Method (2)
●
Allows writing of polymorphic code that can work
with different implementations of interfaces without
any direct references to them, eliminates hardcoding
of implementation class names
● The method must be non-static, if you want to override
it in a superclass of factory
● Variation: factory method can be static and decide
itself what to instantiate
– using configuration
– with the help of parameters
Java course – IAG0040 Lecture 11
Anton Keks Slide 18
19. Abstract Factory
●
Creational pattern, synonym: Kit
●
Provides an interface for creating families of related
or dependent objects without specifying their
concrete classes
●
Abstract Factory is similar to Factory Method with the
exception that methods are never static and
Factories are always subclassed in order to return
different sets of instances
Java course – IAG0040 Lecture 11
Anton Keks Slide 19
20. Abstract Factory (2)
●
Example: GUI toolkit with Factories for creation of
widgets with different look and feel
● public interface AbstractWidgetFactory {
public Button createButton();
public ScrollBar createScrollBar();
}
public class MotifLookAndFeelWidgetFactory
implements AbstractWidgetFactory {
...
}
Java course – IAG0040 Lecture 11
Anton Keks Slide 20
21. Builder
●
Creational pattern
●
Eliminates 'telescoping' constructors
– without sacrificing immutability
– has all advantages of Factory
●
Create Builder inner static class with methods returning
'this' and build() method returning the class instance
● Pizza pizza = new Pizza.Builder().
withOnion().doubleCheese().build();
●
Very readable, better than infinite number of constructors
with boolean or numeric arguments, or setters
Java course – IAG0040 Lecture 11
Anton Keks Slide 21
23. Decorator
● Structural pattern, synonym: Wrapper
● Attach additional responsibilities to an object
dynamically.
● Decorators provide a flexible alternative to
subclassing for extending functionality
● Useful for adding responsibilities dynamically to
objects, not classes.
●
Decorator must have the same interface as the
decorated object.
Java course – IAG0040 Lecture 11
Anton Keks Slide 23
24. Decorator (2)
●
Decorator delegates all method calls to wrapped
instance and does something else before or after.
Every object can be decorated several times.
● BufferedInputStream decorates any
InputStream
● public class LoggingConnection implements Connection {
private Connection conn;
...
public boolean isActive() {
System.out.println(“isActive was called!”);
return conn.isActive();
}
...
}
Java course – IAG0040 Lecture 11
Anton Keks Slide 24
25. Adapter
●
Structural pattern, synonym: Wrapper
● Converts the interface of a class into another
interface clients expect
●
Adapter lets classes work together that
couldn't otherwise because of incompatible
interfaces
Java course – IAG0040 Lecture 11
Anton Keks Slide 25
26. Adapter (2)
●
In other words, Adapter just translates requests to
another API of the wrapped class
●
Examples
– InputStreamReader adapts an InputStream to
the Reader interface
– Arrays.asList() represents java arrays as List
instances
– Collections.enumeration() represents
Iterators as Enumerations
Java course – IAG0040 Lecture 11
Anton Keks Slide 26
27. Composite
●
Structural pattern, similar to Decorator
● Composes objects into tree structures to
represent part-whole hierarchies
●
Composite lets clients treat individual objects
and compositions of objects uniformly
Java course – IAG0040 Lecture 11
Anton Keks Slide 27
28. Composite (2)
● Example: in a GUI toolkit, a Window is a
composite of other Widgets, while is a Widget
itself
● Many GUI toolkits have base classes named
Composite, which can have a layout manager
assigned and an arbitrary number of child
Composites
● SequenceInputStream is a composite of many
InputStreams
Java course – IAG0040 Lecture 11
Anton Keks Slide 28
29. Proxy
●
Decorator, Adapter, and Composite
– any of them can be called 'Proxy'
●
Proxy is a class, functioning as an interface to
another thing
●
In a more specific sense (Virtual Proxy):
wrapping classes can
– control access to wrapped objects
– lazily initialize the delegates inside them
Java course – IAG0040 Lecture 11
Anton Keks Slide 29
30. Strategy
●
Behavioral pattern, synonym: Policy
●
Defines a family of algorithms, encapsulates each one,
and makes them interchangeable; eliminates
conditions from the code (GoF)
●
Capture the abstraction in an interface, bury
implementation details in derived classes
● Strategy lets the algorithm vary independently from
clients that use it
– Algorithms can be changed on-the-fly at runtime
Java course – IAG0040 Lecture 11
Anton Keks Slide 30
31. Strategy (2)
●
Strategy pattern allows adding of new algorithms
easily and/or dynamically
●
Participants:
– Strategy – an interface or abstract class of all
strategies
– ConcreteStrategy – each is a different
implementation of Strategy
– Context – a class, initialized to use and maintain a
ConcreteStrategy, can provide additional (context
specific) data to it
Java course – IAG0040 Lecture 11
Anton Keks Slide 31
32. State
●
Behavioral pattern, similar to Strategy
● Each “Strategy” is one of the states of the
Context
– Strategy usually represents a single abstraction
– each State can implement several behaviors
(different actions, methods)
– State interface may as well provide methods for
transitions in order to implement a Finite State
Machine
Java course – IAG0040 Lecture 11
Anton Keks Slide 32
33. Façade
● Structural pattern
●
Provides a unified interface to a set of interfaces in subsystem
● Facade defines a higher-level interface that makes the subsystem
easier to use
● Structuring a system into subsystems reduces complexity. Then
subsystems can communicate only through Facades, while using
their own lower-level interfaces internally. This reduces coupling
● Example: consider internals of a compiler: it can have classes like
Scanner, Parser, ProgramNode, BytecodeStream, etc, but externally
you use the Facade class named Compiler, which simply takes input
file and produces an output file
●
Facade just delegates requests to appropriate subsystem classes, it
doesn't do anything itself
Java course – IAG0040 Lecture 11
Anton Keks Slide 33
34. Prototype
● Creational pattern
●
Specifies the kind of objects to create using the
prototypical instance
– creates new objects by copying (cloning) the prototype
● Allows having an initialized reference instance of some
abstract class, then it can be cloned or recreated with
reflection API for creation of new objects
● Useful when creating new instances is too complex (and
slow) or less convenient than cloning
● Convenient for implementation of plug-in architectures,
where implementations may be added/removed dynamically
Java course – IAG0040 Lecture 11
Anton Keks Slide 34
35. Observer
●
Behavioral pattern, synonym: Publish-
Subscribe
● Defines a one-to-many dependency between
objects so that when one object changes
state, all its dependents are notified and
updated automatically
●
Provides decoupled classes, which can work
together or independently
Java course – IAG0040 Lecture 11
Anton Keks Slide 35
36. Observer (2)
●
Participants:
– Subject (Observable) – the data to observe
– Observer – an updating interface for objects, which
are notified
– ConcreteSubject – sends notifications to all
registered ConcreteObservers
– ConcreteObserver – knows about ConcreteSubject,
updates itself on notifications
● Java provides both Observable abstract class and
Observer interface
Java course – IAG0040 Lecture 11
Anton Keks Slide 36