01.02.2013 Views

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

Software Development Cross Solution - Index of - Free

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

srp analysis<br />

Spotting multiple responsibilies in your design<br />

Most <strong>of</strong> the time, you can spot classes that aren’t using the SRP<br />

with a simple test:<br />

1<br />

2<br />

3<br />

On a sheet <strong>of</strong> paper, write down a bunch <strong>of</strong> lines like this: The [blank]<br />

[blanks] itself. You should have a line like this for every method in the class<br />

you’re testing for the SRP.<br />

In the first blank <strong>of</strong> each line, write down the class name. In the second<br />

blank, write down one <strong>of</strong> the methods in the class. Do this for each<br />

method in the class.<br />

Read each line out loud (you may have to add a letter or word to get it to<br />

read normally). Does what you just said make any sense? Does your class<br />

really have the responsibility that the method indicates it does?<br />

156 Chapter 5<br />

If what you’ve just said doesn’t make sense,<br />

then you’re probably violating the SRP with that<br />

method. The method might belong in a different<br />

class—think about moving the method.<br />

SRP Analysis for<br />

Write the class name<br />

in this blank, all the<br />

way down the sheet.<br />

The itself.<br />

The itself.<br />

The itself.<br />

Download at WoweBook.Com<br />

Write each method<br />

from the class in this<br />

blank, one per line.<br />

Repeat this line for each<br />

method in your class.<br />

Here’s what your<br />

SRP analysis sheet<br />

should look like.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!