Adaptive Code via C#: Class and Interface Design, Design Patterns, and SOLID Principles (Developer Reference) (英語) ペーパーバック – 2014/8/25
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
Your process may be agile, but are you building agility directly into the code base? This book teaches .NET programmers how to give code the flexibility to adapt to changing requirements and customer demands by applying cutting-edge techniques, including SOLID principles, design patterns, and other industry best practices.
- Understand why composition is preferable to inheritance and how flexible the interface really can be
- Gain deep knowledge of key design patterns and anti-patterns, when to apply them, and how to give their code agility
- Bridge the gap between the theory behind SOLID principles, design patterns, and industry best practices by pragmatically solving real-world problems
- Get code samples written in upcoming version of Microsoft Visual C#
- Topics include: Agile with Scrum process; dependencies and layering; the interface; patterns and anti-patterns; introduction to SOLID principles, including open/closed and dependency interjection; and using application templates
Gary McLean Hall is a senior software developer who focuses on producing agile software for a leading investment-management firm.
Okay, first let me give a little bit of my background so that you will know whether or not this book is for you. First of all, I do not have a formal computer science degree. I do have a degree in electrical/computer engineering, but not computer science. I have had a few formal classes in object-oriented design, data structures and algorithms, operating systems, and an elective in web programming. As far as my experience goes, I have about 1 years of professional software development experience with .NET and C#. I knew nothing about SOLID or TDD at the time I started reading the book. I actually didn't even know what an interface was, but did know that I needed to improve my software design skills. On the back of the book it actually says "Not for beginner programmers... for experienced developers", but I would still consider myself a beginner with C#. Maybe Gary just explains things so well, and makes the concepts easy to understand.
Now, for the review. I have skipped the first chapter which is about SCRUM and some project management concepts I am not interested in right now. That being said, I am about 70 pages in and wow... I've had my eyes opened up to the way that software is supposed to be done. The second chapter of the book (where I started) talks about the basics of layering patterns and managing dependencies through simple interfaces. I immediately started finding examples that I could go and apply at work. That's the great thing about this book, Gary will explain a concept, and is right there with an example to show you how its done.
How exactly did this book help me? I was able to design some interfaces (not previously knowing what they were) using some of Gary's patterns and I have a much better way of managing my libraries/dependencies now.
Gary's formula for describing the different problems in software, and then explaining/giving examples on how to handle them makes this a great buy!
I will update this review if things change as I continue into the book.
The book starts with a summary of Scrum, and I think it makes a good quick reference. For a more in-depth description of Scrum, see the book Scrum: The Art of Doing Twice the Work in Half the Time, which I also recommend (I actually listened to the audiobook).
The chapter on dependencies and layering was an excellent discussion on organizing projects in Visual Studio solutions. The idea is to minimize dependencies between your code and external APIs. This helps to untangle your code and keep its components isolated, which makes it easier to maintain them. I applied this concept to one of my projects and I immediately saw the benefits.
The book has a chapter on unit testing, but it’s more of a refresher. If you really want to understand unit testing well, read The Art of Unit Testing and Growing Object-Oriented Software, Guided by Tests. Also, I much prefer using NUnit and NSubstitute as my unit testing and mocking frameworks. The book uses MSTest and Moq.
The second part of the book discusses the SOLID principles. Each principle gets its own chapter, so it’s quite detailed. What I really like about these chapters is that the author doesn’t stop at theory or simply tell you what your code should look like. He actually goes through relevant examples and shows you how to make your code follow the SOLID principles.
The decorator pattern described in the chapter on the single responsibility principle was a huge eye-opener. I’ve known about this pattern before, but the way that he uses it to make code more adaptive is something I hadn’t seen before. It elevates interfaces as major players in your code.
The third and final part of the book contains chapters that go through a couple of iterations of a sample project. The characters in these chapters use Scrum to plan the project and use the adaptive patterns in the book to develop it. It felt realistic and it was entertaining, and it helped to remind me of the practices recommended in the book.
There wasn’t much that I disliked about the book, but one thing stands out. A lot of the examples (and even the sample project) focused on ASP.NET MVC development. Being a desktop app developer, I’m more interested in WPF and MVVM. He mentions them a few times, but only to say that the same principles as MVC apply to them. I don’t think they do. WPF and MVVM focus on data-binding, which make view models much more dynamic than the static view models in an ASP.NET MVC application.
In summary, this book will help you in becoming a better developer. Your code will go from being a big ball of mud to clean code that is adaptive to change.
I had one programming style (resulting code nothing but a big pile of mud) until I read this book. A game changer.
There are some comments from experienced developers that there were coding errors in this book. Even then, for a beginner to an intermediate programmer, this book is a must-read if the programmer does not know SOLID principles.
There are also some comments about the lack of necessity regarding 1st section of the book, covering Scrum. This is debatable. I thought that it laid a foundation quickly why Adaptive Coding to an Agile environment is required.