SlideShare a Scribd company logo
Design Pattern
“A case study: Designing a document editor”
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (UP) INDIA
1
Contents
• Introduction to Lexi features
• Design problems
• Spelling Checking & Hyphenation
• Solution: Encapsulate Traversal
• Conclusion
2
Introduction to Lexi Features
• WYSIWYG Document Editor
• Mix text and graphics in a variety of styles
• Pull-down Menus
• Scrollbars
• Icons for jumping to a particular page
3
4
Design Problems
1. Document Structure
2. Formatting
3. Embellishing the user interface
4. Supporting multiple look-and-feel standards
5. Supporting multiple window systems
6. User Operations
5
Document Structure
• Goals:
–present document’s visual aspects
–drawing, hit detection, alignment
–support physical structure
(e.g., lines, columns)
• Constraints/forces:
–treat text & graphics uniformly
–no distinction between one & many
6
• Some constraints:
– we should treat text and graphics uniformly
– our implementation shouldn’t have to
distinguish between single elements and
groups of elements in the internal
representation
• Recursive Composition:
– a common way to represent hierarchically
structured information
7
8
• Glyphs:
– an abstract class for all objects that can appear
in a document structure
– three basic responsibilities, they know
• how to draw themselves, what space they
occupy, and their children and parent
• Composite Pattern:
– captures the essence of recursive composition
in object-oriented terms
9
10
11
Formatting
• A structure that corresponds to a properly formatted
document
• Representation and formatting are distinct
– the ability to capture the document’s physical structure doesn’t
tell us how to arrive at a particular structure
• “Formatting” mean breaking a collection of glyphs in to
lines
• Encapsulating the formatting algorithm
– keep formatting algorithms completely independent
of the document structure
– make it is easy to change the formatting algorithm
– We’ll define a separate class hierarchy for objects that
encapsulate formatting algorithm
12
• Compositor and Composition:
– We’ll define a Compositor class for objects
that can encapsulate a formatting algorithm
– The glyphs Compositor formats are the
children of a special Glyph subclass called
Composition
– When the composition needs formatting, it
calls its compositor’s Compose operation
– Each Compositor subclass can implement a
different line breaking algorithm
• 13
14
15
Embellishing the User Interface
• Considering adds a border around the text
editing area and scrollbars that let the user view
the different parts of the page here
• Transparent Enclosure
– object composition
• Border and Scroller should be a subclass of Glyph
– two notions
• single-child (single-component) composition
• compatible interfaces
16
• Monoglyph:
– We can apply the concept of transparent enclosure to
all glyphs that embellish other glyphs
– the class, Monoglyph
• Decorator Pattern:
– captures class and object relationships that support
embellishment by transparent enclosure
17
18
Supporting Multiple
Look-and-Feel Standards
• Design to support the look-and-feel changing at
run-time
• Abstracting Object Creation:
– widgets
– two sets of widget glyph classes for this purpose
– Lexi needs a way to determine the look-and-feel
standard being targeted
– We must avoid making explicit constructor calls
– We must also be able to replace an entire widget set
easily
– We can achieve both by abstracting the process of
object creation
19
• Factories and Product Classes
– Factories create product objects
– The example
• Abstract Factory Pattern
– capture how to create families of related product
objects without instantiating classes directly
20
21
22
Supporting Multiple Window
Systems
• Lexi to run on many existing window systems
having different programming interfaces
• Encapsulating Implementation Dependencies
– The Window class interface encapsulates the
things windows tend to do across window
systems
– The Window class is an abstract class
• Window and WindowImp
• Bridge Pattern
– to allow separate class hierarchies to work together
even as they evolve independently 23
24
25
26
User Operations
• Requirements:
– Lexi provides different user interfaces for the operations it
supported
– These operations are implemented in many different classes
– Lexi supports undo and redo
• The challenge is to come up with a simple and
extensible mechanism that satisfies all of these
needs
• Encapsulating a Request:
– We could parameterize MenuItem with a function to call, but
that’s not a complete solution
– We should parameterize MenuItems with an object, not a
function
27
• Command Class and Subclasses:
– The Command abstract class consists of a single abstract
operation called “Execute”
– MenuItem can store a Command object that encapsulates a
request
– When a user choose a particular menu item, the MenuItem
simply calls Execute on its Command object to carry out
the request
28
29
30
• Undoability:
– To undo and redo commands, we add an
Unexecute operation to Command’s interface
– A concrete Command would store the state of the
Command for Unexecute
– Reversible operation returns a Boolean value to
determine if a command is undoable
• Command History:
– a list of commands that have been executed
present
past commands
31
Spelling Checking &
Hyphenation
• Goals:
– analyze text for spelling errors
– introduce potential hyphenation sites
• Constraints/forces:
– support multiple algorithms
– don’t tightly couple algorithms with document
structure
32
Solution: Encapsulate Traversal
• Iterator
– encapsulates a traversal algorithm without exposing
representation details to callers
– uses Glyph’s child enumeration operation
– This is an example of a “preorder iterator”
• Intent
– access elements of a container without exposing its representation
• Applicability
– require multiple traversal algorithms over a container
– require a uniform traversal interface over different containers
– when container classes & traversal algorithm must vary independently
33
Structure
34
• Consequences:
+flexibility: aggregate & traversal are independent
+multiple iterators & multiple traversal algorithms
– additional communication overhead between iterator &
aggregate
• Implementation:
– internal versus external iterators
– violating the object structure’s encapsulation
– robust iterators
– synchronization overhead in multi-threaded programs
– batching in distributed & concurrent programs
• Known Uses:
– C++ STL iterators
– JDK Enumeration, Iterator
– Unidraw Iterator
35
Conclusion
• design reuse
• uniform design vocabulary
• understanding, restructuring, & team
communication
• provides the basis for automation
• a “new” way to think about design
36
37
Dr. Himanshu Hora
SRMS College of Engineering & Technology
Bareilly (UP) INDIA

More Related Content

PPTX
Object Oriented Testing
PDF
Software Process Models
PPT
Webservices
PPTX
Overview of UML Diagrams
PPTX
Waterfall model in SDLC
PPTX
Object model
PPTX
Design Concepts in Software Engineering-1.pptx
PPTX
Improving of software processes
Object Oriented Testing
Software Process Models
Webservices
Overview of UML Diagrams
Waterfall model in SDLC
Object model
Design Concepts in Software Engineering-1.pptx
Improving of software processes

What's hot (20)

PDF
Agile model
PDF
Software Engineering : Requirement Analysis & Specification
PPT
Design Patterns
PPTX
Waterfall Model PPT in Software Engineering
PPT
C#.NET
PPTX
SRS(software requirement specification)
PPTX
V model presentation
PPT
UML diagrams and symbols
PPT
Uml class-diagram
PPTX
Software development process models
PPT
Software design
PPTX
Testing web application
PPT
Distributed objects & components of corba
PPT
Taxonomy for bugs
PPTX
Io t system management with
PPTX
Agile Software Development Model
PPTX
COCOMO (Software Engineering)
PPTX
Software myths | Software Engineering Notes
PPTX
Design concept -Software Engineering
PPTX
Waterfall model ppt final
Agile model
Software Engineering : Requirement Analysis & Specification
Design Patterns
Waterfall Model PPT in Software Engineering
C#.NET
SRS(software requirement specification)
V model presentation
UML diagrams and symbols
Uml class-diagram
Software development process models
Software design
Testing web application
Distributed objects & components of corba
Taxonomy for bugs
Io t system management with
Agile Software Development Model
COCOMO (Software Engineering)
Software myths | Software Engineering Notes
Design concept -Software Engineering
Waterfall model ppt final
Ad

Viewers also liked (7)

PPTX
Behavioral pattern By:-Priyanka Pradhan
PPTX
Security and Integrity of Data
PPTX
Creational pattern
PPT
Design patterns ppt
PPTX
Adapter Design Pattern
ZIP
Adapter Design Pattern
PPT
Structural patterns
Behavioral pattern By:-Priyanka Pradhan
Security and Integrity of Data
Creational pattern
Design patterns ppt
Adapter Design Pattern
Adapter Design Pattern
Structural patterns
Ad

Similar to Design Pattern (20)

PPTX
Design patterns
PPT
Software Design Patterns
PPT
Software Design Patterns
PDF
Design Patterns - GOF
PPT
Software Engineering Lec 8-design-
PPTX
Design pattern of software words computer .pptx
PDF
Andrii Sliusar "Module Architecture of React-Redux Applications"
PPTX
AngularJS
PDF
software _Desing_Methodology-partI.pptx.pdf
PPTX
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
PPTX
Cs 1023 lec 8 design pattern (week 2)
PPTX
Data Structure and Algorithms
PPT
Introduction to Software Integration and Architecture_2.ppt
PPTX
UNIT IV DESIGN PATTERNS.pptx
PPTX
Design patterns Structural
PPT
Chapter 4_Introduction to Patterns.ppt
PPT
Chapter 4_Introduction to Patterns.ppt
PDF
Asp 1-mvc introduction
PPTX
Real-Time Design Patterns
PPTX
Patterns
Design patterns
Software Design Patterns
Software Design Patterns
Design Patterns - GOF
Software Engineering Lec 8-design-
Design pattern of software words computer .pptx
Andrii Sliusar "Module Architecture of React-Redux Applications"
AngularJS
software _Desing_Methodology-partI.pptx.pdf
Unit - I Intro. to OOP Concepts and Control Structure -OOP and CG (2024 Patte...
Cs 1023 lec 8 design pattern (week 2)
Data Structure and Algorithms
Introduction to Software Integration and Architecture_2.ppt
UNIT IV DESIGN PATTERNS.pptx
Design patterns Structural
Chapter 4_Introduction to Patterns.ppt
Chapter 4_Introduction to Patterns.ppt
Asp 1-mvc introduction
Real-Time Design Patterns
Patterns

More from Himanshu (20)

PPTX
Software product line
PPT
Shared information systems
PPTX
Saam
PPTX
Architecture Review
PPTX
Reliability and its principals
PPTX
Structural and functional testing
PPTX
White box black box & gray box testing
PPTX
Pareto analysis
PPTX
Load runner & win runner
PPTX
Crud and jad
PPTX
Junit and cactus
PPTX
Risk based testing and random testing
PPTX
Testing a data warehouses
PPTX
Software testing tools and its taxonomy
PPTX
Software reliability engineering process
PPTX
Software reliability growth model
PPTX
Software reliability tools and common software errors
PPTX
Regression and performance testing
PPTX
Eleven step of software testing process
PPTX
Off the-shelf components (cots)
Software product line
Shared information systems
Saam
Architecture Review
Reliability and its principals
Structural and functional testing
White box black box & gray box testing
Pareto analysis
Load runner & win runner
Crud and jad
Junit and cactus
Risk based testing and random testing
Testing a data warehouses
Software testing tools and its taxonomy
Software reliability engineering process
Software reliability growth model
Software reliability tools and common software errors
Regression and performance testing
Eleven step of software testing process
Off the-shelf components (cots)

Recently uploaded (20)

PPTX
UNIT III MENTAL HEALTH NURSING ASSESSMENT
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
RMMM.pdf make it easy to upload and study
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PPTX
Introduction to Building Materials
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PPTX
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
PDF
Computing-Curriculum for Schools in Ghana
PDF
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
Hazard Identification & Risk Assessment .pdf
DOC
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
PDF
A systematic review of self-coping strategies used by university students to ...
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
Practical Manual AGRO-233 Principles and Practices of Natural Farming
PDF
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
PDF
1_English_Language_Set_2.pdf probationary
PDF
LDMMIA Reiki Yoga Finals Review Spring Summer
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
UNIT III MENTAL HEALTH NURSING ASSESSMENT
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
RMMM.pdf make it easy to upload and study
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
Introduction to Building Materials
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Introduction-to-Literarature-and-Literary-Studies-week-Prelim-coverage.pptx
Computing-Curriculum for Schools in Ghana
SOIL: Factor, Horizon, Process, Classification, Degradation, Conservation
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Hazard Identification & Risk Assessment .pdf
Soft-furnishing-By-Architect-A.F.M.Mohiuddin-Akhand.doc
A systematic review of self-coping strategies used by university students to ...
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
Practical Manual AGRO-233 Principles and Practices of Natural Farming
ChatGPT for Dummies - Pam Baker Ccesa007.pdf
1_English_Language_Set_2.pdf probationary
LDMMIA Reiki Yoga Finals Review Spring Summer
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...

Design Pattern

  • 1. Design Pattern “A case study: Designing a document editor” Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (UP) INDIA 1
  • 2. Contents • Introduction to Lexi features • Design problems • Spelling Checking & Hyphenation • Solution: Encapsulate Traversal • Conclusion 2
  • 3. Introduction to Lexi Features • WYSIWYG Document Editor • Mix text and graphics in a variety of styles • Pull-down Menus • Scrollbars • Icons for jumping to a particular page 3
  • 4. 4
  • 5. Design Problems 1. Document Structure 2. Formatting 3. Embellishing the user interface 4. Supporting multiple look-and-feel standards 5. Supporting multiple window systems 6. User Operations 5
  • 6. Document Structure • Goals: –present document’s visual aspects –drawing, hit detection, alignment –support physical structure (e.g., lines, columns) • Constraints/forces: –treat text & graphics uniformly –no distinction between one & many 6
  • 7. • Some constraints: – we should treat text and graphics uniformly – our implementation shouldn’t have to distinguish between single elements and groups of elements in the internal representation • Recursive Composition: – a common way to represent hierarchically structured information 7
  • 8. 8
  • 9. • Glyphs: – an abstract class for all objects that can appear in a document structure – three basic responsibilities, they know • how to draw themselves, what space they occupy, and their children and parent • Composite Pattern: – captures the essence of recursive composition in object-oriented terms 9
  • 10. 10
  • 11. 11
  • 12. Formatting • A structure that corresponds to a properly formatted document • Representation and formatting are distinct – the ability to capture the document’s physical structure doesn’t tell us how to arrive at a particular structure • “Formatting” mean breaking a collection of glyphs in to lines • Encapsulating the formatting algorithm – keep formatting algorithms completely independent of the document structure – make it is easy to change the formatting algorithm – We’ll define a separate class hierarchy for objects that encapsulate formatting algorithm 12
  • 13. • Compositor and Composition: – We’ll define a Compositor class for objects that can encapsulate a formatting algorithm – The glyphs Compositor formats are the children of a special Glyph subclass called Composition – When the composition needs formatting, it calls its compositor’s Compose operation – Each Compositor subclass can implement a different line breaking algorithm • 13
  • 14. 14
  • 15. 15
  • 16. Embellishing the User Interface • Considering adds a border around the text editing area and scrollbars that let the user view the different parts of the page here • Transparent Enclosure – object composition • Border and Scroller should be a subclass of Glyph – two notions • single-child (single-component) composition • compatible interfaces 16
  • 17. • Monoglyph: – We can apply the concept of transparent enclosure to all glyphs that embellish other glyphs – the class, Monoglyph • Decorator Pattern: – captures class and object relationships that support embellishment by transparent enclosure 17
  • 18. 18
  • 19. Supporting Multiple Look-and-Feel Standards • Design to support the look-and-feel changing at run-time • Abstracting Object Creation: – widgets – two sets of widget glyph classes for this purpose – Lexi needs a way to determine the look-and-feel standard being targeted – We must avoid making explicit constructor calls – We must also be able to replace an entire widget set easily – We can achieve both by abstracting the process of object creation 19
  • 20. • Factories and Product Classes – Factories create product objects – The example • Abstract Factory Pattern – capture how to create families of related product objects without instantiating classes directly 20
  • 21. 21
  • 22. 22
  • 23. Supporting Multiple Window Systems • Lexi to run on many existing window systems having different programming interfaces • Encapsulating Implementation Dependencies – The Window class interface encapsulates the things windows tend to do across window systems – The Window class is an abstract class • Window and WindowImp • Bridge Pattern – to allow separate class hierarchies to work together even as they evolve independently 23
  • 24. 24
  • 25. 25
  • 26. 26
  • 27. User Operations • Requirements: – Lexi provides different user interfaces for the operations it supported – These operations are implemented in many different classes – Lexi supports undo and redo • The challenge is to come up with a simple and extensible mechanism that satisfies all of these needs • Encapsulating a Request: – We could parameterize MenuItem with a function to call, but that’s not a complete solution – We should parameterize MenuItems with an object, not a function 27
  • 28. • Command Class and Subclasses: – The Command abstract class consists of a single abstract operation called “Execute” – MenuItem can store a Command object that encapsulates a request – When a user choose a particular menu item, the MenuItem simply calls Execute on its Command object to carry out the request 28
  • 29. 29
  • 30. 30
  • 31. • Undoability: – To undo and redo commands, we add an Unexecute operation to Command’s interface – A concrete Command would store the state of the Command for Unexecute – Reversible operation returns a Boolean value to determine if a command is undoable • Command History: – a list of commands that have been executed present past commands 31
  • 32. Spelling Checking & Hyphenation • Goals: – analyze text for spelling errors – introduce potential hyphenation sites • Constraints/forces: – support multiple algorithms – don’t tightly couple algorithms with document structure 32
  • 33. Solution: Encapsulate Traversal • Iterator – encapsulates a traversal algorithm without exposing representation details to callers – uses Glyph’s child enumeration operation – This is an example of a “preorder iterator” • Intent – access elements of a container without exposing its representation • Applicability – require multiple traversal algorithms over a container – require a uniform traversal interface over different containers – when container classes & traversal algorithm must vary independently 33
  • 35. • Consequences: +flexibility: aggregate & traversal are independent +multiple iterators & multiple traversal algorithms – additional communication overhead between iterator & aggregate • Implementation: – internal versus external iterators – violating the object structure’s encapsulation – robust iterators – synchronization overhead in multi-threaded programs – batching in distributed & concurrent programs • Known Uses: – C++ STL iterators – JDK Enumeration, Iterator – Unidraw Iterator 35
  • 36. Conclusion • design reuse • uniform design vocabulary • understanding, restructuring, & team communication • provides the basis for automation • a “new” way to think about design 36
  • 37. 37 Dr. Himanshu Hora SRMS College of Engineering & Technology Bareilly (UP) INDIA