Symptoms
CausesThe items are typically part of some other entity, but as yet no one has had the insight to realize that there's a missing class. Or sometimes, people know the class is missing, but think it's too small or unimportant to stand alone. (Identifying these classes is often a major step toward simplifying a system, and it often helps you to generalize classes more easily.) What to Do
PayoffImproves communication. May expose duplication. Usually reduces size. ContraindicationsOccasionally, passing a whole object will introduce a dependency you don't want (as lower-level classes get exposed to the whole new object instead of just its values). So you may pass in the pieces to prevent this dependency. Very rarely, there is a measured performance problem solved by passing in the parts of the object instead of the object itself. Recognize that this is a compromise in the object model for performance. Such code is worth commenting! |