Applying UML and Patterns: An Introduction to ObjectOriented Analysis and Design and Iterative Development, Third Edition [Electronic resources]

Craig Larman

نسخه متنی -صفحه : 472/ 224
نمايش فراداده

Chapter 17. GRASP: Designing Objects with Responsibilities

Understanding responsibilities is key to good object-oriented design.

Martin Fowler

Objectives

  • Learn to apply five of the GRASP principles or patterns for OOD.

This chapter and the next contribute significantly to an understanding of core OO design (OOD). OOD is sometimes taught as some variation of the following:

After identifying your requirements and creating a domain model, then add methods to the appropriate classes, and define the messaging between the objects to fulfill the requirements.

Ouch! Such vague advice doesn't help us, because deep principles and issues are involved. Deciding what methods belong where and how objects should interact carries consequences and should be undertaken seriously. Mastering OODand this is its intricate charminvolves a large set of soft principles, with many degrees of freedom. It isn't magicthe patterns can be

named (important!), explained, and applied. Examples help. Practice helps. And this small step helps: After studying these case studies, try recreating (from memory) the Monopoly solution on walls with partners, and apply the principles, such as Information Expert.

[View full size image]