GUI frameworks typically have some sort of 'View' class that represents things drawn on the screen, and that class usually provides a method like
invalidateRect(Rect r) to mark part of its drawing area as needing to be redrawn. Clients might call that method to request an update to part of the view. But a view might also call its own method, like:
to cause redrawing of the entire area. For example, it might do this when it's first added to the view hierarchy.
There's nothing wrong with doing this -- the view's frame is a valid rectangle, and the view itself knows that it wants to redraw itself. The View class could provide a separate method that takes no parameters and uses the view's frame instead:
But why add a special method just for this when you can use the more general
invalidateRect()? Or, if you did choose to provide
invalidateFrame(), you'd very probably implement it in terms of the more general
Why pass variable as method parameter, if you already has access to it?
You should pass instance variables as parameters to your own method if the method doesn't operate specifically on that instance variable. In the example above, the view's frame is just another rectangle as far as the
invalidateRect() method is concerned.