środa, 17 grudnia 2008

Całkiem niedługa metoda

Przeglądając kod pewnej klasy w pracy natrafiłem na interesującą metodę o wysublimowanej, ale wbrew pozorom wcale nie enigmatycznej nazwie:

testWriteStreamSpacesNoUnicodeMiscApostropheDoubleQuoteFileNoSpacesNoUnicode()

Czytając Martina Fowlera: "...small methods really work only when you have good names, so you need to pay attention to naming. People sometimes ask me what length I look for in a method. To me length is not the issue. The key is the semantic distance between the method name and the method body. If extracting improves clarity, do it, even if the name is longer than the code you have extracted.", można uznać, że ta metoda idealnie spełnia zasady dobrego refactoringu :)
Myślę, że startując w konkursie the longest method ever miałaby wysokie szanse na zwycięstwo :) Czy ktoś kiedyś widział równie długą metodę w rzeczywistym projekcie komercyjnym?


Brak komentarzy: