DEV Community

Discussion on: Hacky and Clean Programming

Collapse
 
danielkun profile image
Daniel Albuschat

Great question! And a question that you should ask yourself and your teammates every time you are not sure.

Here is a fictional example:

public void Print(Point position, string text)
{
   
}
Enter fullscreen mode Exit fullscreen mode

What would be obvious and what would not be obvious about this function?

It obviously prints text at position.

What is not obvious: Is there a maximum length for text? What happens when position is outside of the canvas? Will an exception be thrown? What happens when position is inside the canvas, but text will flow outside? Will it be wrapped?
What color is text printed in? What font face, font size, etc.?

And, since C# and Java are one of the stupid languages that mostly-always allow null for everything even when it makes no sense at all, you should state what happens when either of the argument is null. (Incidentally, System.Windows.Point is a struct in C# and therefore does not allow null, yay!)