שבט (17)

Refactoring

הפעם פוסט קצת ארוך. אל תתייאשו, כי בסוף יש משהו אחר.

בטח ראיתם את הספר החדש ששרון הזמין לנו: Refactoring – Improving the Design of Existing Code
refactoring – שינוי של מבנה הקוד כך שיהיה קריא יותר, ו יתאים לשינויים עתידיים.
איך משתמשים ב- refactoring ב- Visual Studio:

אני כעת בעיצומו של הספר, וזה מרתק.
במקום שאני אסקור את הספר, אני מביאה כאן חלק מפוסט שקראתי, שיש בו סקירה על הספר. למעשה, סקירה זו היא שהביאה אותי לבקש משרון שיזמין את הספר.

Refactoring: Improving the Design of Existing Code by Martin Fowler.
When I read this book for the first time, in October 2003, I felt this horrid cold feeling, the way you might feel if you just realized you’ve been coming to work for 5 years with your pants down around your ankles. I asked around casually the next day: “Yeah, uh, you’ve read that, um, Refactoring book, of course, right? Ha, ha, I only ask because I read it a very long time ago, not just now, of course.” Only 1 person of 20 I surveyed had read it. Thank goodness all of us had our pants down, not just me.
This is a wonderful book about how to write good code, and there aren’t many books like it. None, maybe. They don’t typically teach you how to write good code in school, and you may never learn on the job. It may take years, but you may still be missing some key ideas. I certainly was.

The book talks about production code at the level of individual functions, and even snippets of code within a function. It starts by showing you ugly functions that work, then shows you, step by step, how to make them clean and beautiful without breaking them. Some of the techniques are quite powerful, and many can be automated. The book simultaneously showed me why some of my functions had grown large and gnarled, despite my best efforts, and then gave me tools and confidence for fixing it.
The book’s examples are in Java, but don’t let that put you off. The ideas are relevant for every programming language. I know a guy who read through it without knowing any Java, and immediately began putting the ideas to work in refactoring his Perl code. I even factor and refactor my Lisp code these days.
If you’re a relatively experienced engineer, you’ll recognize 80% or more of the techniques in the book as things you’ve already figured out and started doing out of habit. But it gives them all names and discusses their pros and cons objectively, which I found very useful. And it debunked two or three practices that I had cherished since my earliest days as a programmer. Don’t comment your code? Local variables are the root of all evil? Is this guy a madman? Read it and decide for yourself!
מתוך:
http://steve.yegge.googlepages.com/ten-great-books

=====================================================

חוץ מזה, יצאה עכשיו תוספת חדשה ל-Visual Studio, המכילה refactoring לדף ה-aspx עצמו (לא ל-Code behind):
http://blogs.msdn.com/bgold/archive/2007/02/02/refactor-for-asp-net-beta-released.aspx

כתבו תגובה

כתובת הדוא"ל שלכם לא תוצג.