Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
Neversettle
intive.com
_GRASP
Karol Kreft
PHPers Summit 2019
06.09.2019, Poznań
Neversettle
intive.com
2
Neversettle
intive.com
3
Neversettle
intive.com
4
Neversettle
intive.com
• www.craiglarman.com
• UML, OOP, Analysis & Design
• GRASP
• Agile and LeSS
5
Craig Larman
Neversettle
intive.com
6
The GRASP name was
chosen to suggest the
importance of grasping
these principles to
successfully ...
Neversettle
intive.com
7
General
Responsibility
Assignment
Software
Patterns
Neversettle
intive.com
8
Responsibilities
Neversettle
intive.com
• do something
• know something{
Responsibilities
Neversettle
intive.com
10
Neversettle
intive.com
11
Neversettle
intive.com
GRASP
1. Information Expert
2. Creator
3. Controller
4. Low coupling
5. High cohesion
6. Indirectio...
Neversettle
intive.com
Information Expert
_Assign a responsibility to the information expert
– the class that has the info...
Neversettle
intive.com
Information Expert
_Place responsibilities with data
_That which knows, does
_Do it Myself
_Put Ser...
Neversettle
intive.com
15
Neversettle
intive.com
16
Neversettle
intive.com
Creator
_Who should be responsible for creating a new
instance of some class?
_Choose class B when
...
Neversettle
intive.com
18
Neversettle
intive.com
Neversettle
intive.com
Controller
_Who should be responsible for handling
system event?
Neversettle
intive.com
21
Neversettle
intive.com
Bloated Controller
_Controllers which handle too many system
events leading to low cohesion. This c...
Neversettle
intive.com
Low coupling
High cohesion
Neversettle
intive.com
Low Coupling
_How to support low dependency
and increased reuse?
High Cohesion
_How to keep complex...
Neversettle
intive.com
Low Coupling
_Assign responsibilities so that coupling
remains low.
High Cohesion
_Assign responsib...
Neversettle
intive.com
High Coupling
_Changes in related classes force local changes
_Harder to understand in isolation
_H...
Neversettle
intive.com
Low Cohesion
_Hard to comprehend
_Hard to reuse
_Hard to maintain
_Delicate; constantly effected by...
Neversettle
intive.com
_Low Coupling and High Cohesion are principles
to keep in mind during all design decisions.
_They a...
Neversettle
intive.com
29
Neversettle
intive.com
30
_Where to assign a responsibility to avoid
direct coupling between two or more
things?
Neversettle
intive.com
31
_Where to assign a responsibility to avoid
direct coupling between two or more
things?
_Assign t...
Neversettle
intive.com
32
Neversettle
intive.com
GRASP
1. Information Expert
2. Creator
3. Controller
4. Low coupling
5. High cohesion
6. Indirectio...
Neversettle
intive.com
34
Do we need
object oriented design?
Neversettle
intive.com
35
Neversettle
intive.com
36
http://bit.ly/grasp-talk
@karol_kreft
Neversettle
intive.com
37
• Photo by La-Rel Easter on Unsplash
• Photo by Feliphe Schiarolli on Unsplash
• Photo by Andrej...
Upcoming SlideShare
Loading in …5
×

GRASP - one more way to reach clean code

67 views

Published on

Slides from my speech at PHPersSummit 2019.

Published in: Engineering
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD FULL BOOKS, INTO AVAILABLE FORMAT ......................................................................................................................... ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. PDF EBOOK here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. EPUB Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... 1.DOWNLOAD FULL. doc Ebook here { https://tinyurl.com/y6a5rkg5 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Be the first to like this

GRASP - one more way to reach clean code

  1. 1. Neversettle intive.com _GRASP Karol Kreft PHPers Summit 2019 06.09.2019, Poznań
  2. 2. Neversettle intive.com 2
  3. 3. Neversettle intive.com 3
  4. 4. Neversettle intive.com 4
  5. 5. Neversettle intive.com • www.craiglarman.com • UML, OOP, Analysis & Design • GRASP • Agile and LeSS 5 Craig Larman
  6. 6. Neversettle intive.com 6 The GRASP name was chosen to suggest the importance of grasping these principles to successfully design object-oriented software.
  7. 7. Neversettle intive.com 7 General Responsibility Assignment Software Patterns
  8. 8. Neversettle intive.com 8 Responsibilities
  9. 9. Neversettle intive.com • do something • know something{ Responsibilities
  10. 10. Neversettle intive.com 10
  11. 11. Neversettle intive.com 11
  12. 12. Neversettle intive.com GRASP 1. Information Expert 2. Creator 3. Controller 4. Low coupling 5. High cohesion 6. Indirection 7. Polymorphism 8. Pure Fabrication 9. Protected Variations
  13. 13. Neversettle intive.com Information Expert _Assign a responsibility to the information expert – the class that has the information necessary to fulfill the responsibility.
  14. 14. Neversettle intive.com Information Expert _Place responsibilities with data _That which knows, does _Do it Myself _Put Services with the Attributes They Work On
  15. 15. Neversettle intive.com 15
  16. 16. Neversettle intive.com 16
  17. 17. Neversettle intive.com Creator _Who should be responsible for creating a new instance of some class? _Choose class B when _B aggregates A objects _B contains A objects _B closely uses A objects _B as the initializing data that are required to creatingA
  18. 18. Neversettle intive.com 18
  19. 19. Neversettle intive.com
  20. 20. Neversettle intive.com Controller _Who should be responsible for handling system event?
  21. 21. Neversettle intive.com 21
  22. 22. Neversettle intive.com Bloated Controller _Controllers which handle too many system events leading to low cohesion. This can be avoided by addition of a few more controllers. _Always remember about delegating responsibilities to other objects. _Use Command Pattern in a message-handling systems.
  23. 23. Neversettle intive.com Low coupling High cohesion
  24. 24. Neversettle intive.com Low Coupling _How to support low dependency and increased reuse? High Cohesion _How to keep complexity manageable?
  25. 25. Neversettle intive.com Low Coupling _Assign responsibilities so that coupling remains low. High Cohesion _Assign responsibilities so that cohesion remains high.
  26. 26. Neversettle intive.com High Coupling _Changes in related classes force local changes _Harder to understand in isolation _Harder to reuse because its use requires the additional presence of the classes it dependent upon _Coupling may not be important if reuse is not a goal.
  27. 27. Neversettle intive.com Low Cohesion _Hard to comprehend _Hard to reuse _Hard to maintain _Delicate; constantly effected by change
  28. 28. Neversettle intive.com _Low Coupling and High Cohesion are principles to keep in mind during all design decisions. _They are evaluative patterns which a designer applies while evaluating all design decisions.
  29. 29. Neversettle intive.com 29
  30. 30. Neversettle intive.com 30 _Where to assign a responsibility to avoid direct coupling between two or more things?
  31. 31. Neversettle intive.com 31 _Where to assign a responsibility to avoid direct coupling between two or more things? _Assign the responsibility to an intermediate object to mediate between other components or services to avoid direct coupling.
  32. 32. Neversettle intive.com 32
  33. 33. Neversettle intive.com GRASP 1. Information Expert 2. Creator 3. Controller 4. Low coupling 5. High cohesion 6. Indirection 7. Polymorphism 8. Pure Fabrication 9. Protected Variations
  34. 34. Neversettle intive.com 34 Do we need object oriented design?
  35. 35. Neversettle intive.com 35
  36. 36. Neversettle intive.com 36 http://bit.ly/grasp-talk @karol_kreft
  37. 37. Neversettle intive.com 37 • Photo by La-Rel Easter on Unsplash • Photo by Feliphe Schiarolli on Unsplash • Photo by Andrej Lišakov on Unsplash • Photo by Rohit Choudhari on Unsplash • Photo by Javier Allegue Barros on Unsplash Photos

×