I guess I am counting everything that happens from when the function is called, to when it returns, as the "one thing" that it does.
O_o
If that is true, how do you design anything without overwhelming every single function?
I mean, `main' is a function that is called and also returns. With that same view, does `main' do "one thing"?
I don't know, maybe I'm reading too much into the comment, or maybe you aren't parsing "one thing" as laserlight intends.
Look at the "one thing" concept from the perspective of implementation instead of interface.
Code:
class SVector
{
// ...
void push_back
(
int fData
)
{
if(mSize == mCapacity)
{
// resize storage
}
// copy `fData' into storage
}
// ...
};
Code:
class SVector
{
// ...
void push_back
(
int fData
)
{
if(isFull())
{
expand();
}
insert(mLast, fData);
}
// ...
};
The difference isn't that `push_back' does actually something different but for what it is responsible.
The design:
`isFull' considers the state of storage.
`expand' increases the storage.
`insert' moves the data into storage.
`push_back' isn't responsible for all of these things.
Soma