
Simple and Efficient Programming with C#: Skills to Build Applications with Visual Studio and .NET, 2nd Edition
- Length: 340 pages
- Edition: 2
- Language: English
- Publisher: Apress
- Publication Date: 2022-12-28
- ISBN-10: 1484287363
- ISBN-13: 9781484287361
- Sales Rank: #0 (See Top 100 Books)
Apply skills and approaches to your programming to build a real-world application in C# 11 using the latest editions of Visual Studio, C#, and Microsoft .NET.
This revised edition is updated with C#11 and places more emphasis on the newly introduced top-level statements. Additionally, you will find useful techniques and an explanation of the differences between writing code in two different styles. It also covers the new templates introduced in .NET 6, along with usage of .NET 7 in Windows 10 to write code and generate output.
Each chapter opens with an introduction and original application written in C# 11 so that you can jump right into coding. From there, you are guided through an expected output and taught best practices along the way. Author Vaskaran Sarcar emphasizes extending and maintaining the same program and he demonstrates examples for different scenarios to make your program more efficient and effective.
This book is divided into five parts. The first part starts with a detailed discussion of polymorphism. It then shows you how to make proper use of abstract classes and interfaces, and teaches you to discern which technique to use for a specific scenario. Discussions on code comments teach you how to use them effectively, and why you need to be careful with code comments.
In the second part you will learn six design principles, including SOLID and DRY principles. These are the foundation of well-known design patterns, and they establish practices for developing software with considerations for maintaining and extending as a project grows.
The third part walks you through methods to make efficient applications. You will learn the common use of factories to separate code from its opposite and the alternative of inheritance using object composition and wrappers. This part also demonstrates the use of template methods, hooks, and facades in programming. Hints show you how professional coders develop an enterprise application.
Better handling of exceptions and null values is another integral part of professional programming, which the fourth part explores in detail. This will help you become a more professional programmer.
In the final part of the book, you will learn about effective memory management techniques and the use and misuse of design patterns. This part also briefly discusses how to decide between a static method and an instance method and other techniques.
After reading this book, you will be able to implement best practices to make your programs more effective and reliable.What Will You Learn
- Analyze alternative solutions before implementation by comparing pros and cons
- Make polymorphic code perform better
- Know the side effects of bad/redundant comments
- Understand the significance of the SOLID and DRY principles
- Add features using wrappers
- Redefine steps without altering the calling sequence of an algorithm
- Use hooks in your application
- Convert a complex system into a user-friendly system using facades
- Run your application in .NET 6
Who Is This Book ForDevelopers with a basic knowledge of C#.
Contents About the Author About the Technical Reviewers Introduction How Is the Book Organized? Prerequisite Knowledge Who Is This Book For? Guidelines for Using This Book Conventions Used in This Book Final Words Chapter 1: Flexible Code Using Polymorphism Recap of Polymorphism Initial Program Demonstration 1 Output Analysis Better Program Demonstration 2 Analysis Useful Notes Summary Chapter 2: Abstract Class or Interface? Recap of Abstract Classes and Interfaces Initial Program Demonstration 1 Better Program Demonstration 2 Output Analysis Summary Chapter 3: Wise Use of Code Comments Recap of Code Comments Initial Program Demonstration 1 Output Analysis Better Program Demonstration 2 Analysis Use the Power of C# Demonstration 3 Analysis Summary Chapter 4: Know SOLID Principles Single Responsibility Principle Initial Program Demonstration 1 Output Analysis Better Program Demonstration 2 Output Open/Closed Principle Initial Program Demonstration 3 Output Analysis Better Program Demonstration 4 Output Analysis Liskov Substitution Principle Initial Program Demonstration 5 Output Better Program Demonstration 6 Output Analysis Interface Segregation Principle Initial Program Demonstration 7 Output Analysis Better Program Demonstration 8 Output Analysis Dependency Inversion Principle Initial Program Demonstration 9 Output Analysis Better Program Demonstration 10 Output Analysis Summary Chapter 5: Use the DRY Principle Reasons for DRY Initial Program Demonstration 1 Output Analysis Better Program Demonstration 2 Output Analysis Further Improvement Demonstration 3 Output Demonstration 4 Output Summary Chapter 6: Separate Changeable Code Using Factories The Problem Statement Initial Program Demonstration 1 Output Analysis Better Program Demonstration 2 Output Analysis A New Requirement Demonstration 3 Output Analysis Demonstration 4 Output Summary Chapter 7: Add Features Using Wrappers The Problem Statement Initial Program (Using Subclassing) Demonstration 1 Better Program (Using Object Composition) Class Diagram Demonstration 2 Output Analysis Summary Chapter 8: Make Efficient Templates Using Hooks The Problem Statement Initial Program Class Diagram Demonstration 1 Output Analysis Enhanced Requirement Demonstration 2 Output Summary Chapter 9: Simplify Complex Systems Using Facades The Problem Statement Initial Program Demonstration 1 Output Analysis Better Program Class Diagram Demonstration 2 Output Analysis Summary Chapter 10: Organizing Exceptions Recap of Exceptions Case 1: Handling Different Exceptions in the Same Way Initial Program Demonstration 1 Output Analysis Better Program Demonstration 2 Output Analysis Case 2: Handling the Same Exception in Different Ways Initial Program Demonstration 3 Output Analysis Better Program Demonstration 4 Output Analysis Summary Chapter 11: Special Attention to the Null Values Initial Program Demonstration 1 Output Analysis Better Programs Demonstration 2 Output Analysis Demonstration 3 Analysis Summary Chapter 12: Memory Management Overview Stack Memory vs. Heap Memory Q&A Session The Garbage Collector in Action Different Phases of Garbage Collection Different Cases of Invoking the Garbage Collector Demonstration 1 Output Analysis Q&A Session Disposing of an Object Finalize vs. Dispose Demonstration 2 Output Analysis Q&A Session Summary Chapter 13: Analyzing Memory Leaks Managed vs. Unmanaged Memory Leaks Memory Leak Analysis Demonstration Snapshots from Diagnostic Tools Summary Chapter 14: More Tips Learn Design Patterns Brief History of Design Patterns The Good News Q&A Session Avoid Anti-patterns Brief History of Anti-patterns Examples of Anti-patterns Q&A Session Final Suggestions Decide Between a Static Method and an Instance Method Know the Common Terminology Accept Failures! Q&A Session Summary Appendix A: Winning Notes A Personal Appeal to You Appendix B: Resources Index
How to download source code?
1. Go to: https://github.com/Apress
2. In the Find a repository… box, search the book title: Simple and Efficient Programming with C#: Skills to Build Applications with Visual Studio and .NET, 2nd Edition
, sometime you may not get the results, please search the main title.
3. Click the book title in the search results.
3. Click Code to download.
1. Disable the AdBlock plugin. Otherwise, you may not get any links.
2. Solve the CAPTCHA.
3. Click download link.
4. Lead to download server to download.