Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Clean Code with C#

You're reading from   Clean Code with C# Refactor your legacy C# code base and improve application performance using best practices

Arrow left icon
Product type Paperback
Published in Dec 2023
Publisher Packt
ISBN-13 9781837635191
Length 492 pages
Edition 2nd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jason Alls Jason Alls
Author Profile Icon Jason Alls
Jason Alls
Arrow right icon
View More author details
Toc

Table of Contents (18) Chapters Close

Preface 1. Chapter 1: Coding Standards and Principles in C# 2. Chapter 2: Code Review – Process and Importance FREE CHAPTER 3. Chapter 3: Classes, Objects, and Data Structures 4. Chapter 4: Writing Clean Functions 5. Chapter 5: Exception Handling 6. Chapter 6: Unit Testing 7. Chapter 7: Designing and Developing APIs 8. Chapter 8: Addressing Cross-Cutting Concerns 9. Chapter 9: AOP with PostSharp 10. Chapter 10: Using Tools to Improve Code Quality 11. Chapter 11: Refactoring C# Code 12. Chapter 12: Functional Programming 13. Chapter 13: Cross-Platform Application Development with MAUI 14. Chapter 14: Microservices 15. Assessments 16. Index 17. Other Books You May Enjoy

A brief introduction to GitHub

This section covers a brief introduction to programmers and developers who are new to GitHub and never used it since this chapter focuses on the use of GitHub for performing code reviews.

GitHub is a powerful platform that revolutionizes the way developers collaborate on projects. Whether you’re a seasoned programmer or just starting your coding journey, GitHub provides a centralized hub for version control, collaboration, and code sharing. This introduction aims to guide beginners through the fundamentals of GitHub and provide resources to help you embark on your journey to becoming a proficient GitHub user.

What is GitHub?

GitHub is a web-based platform built around Git, a distributed version control system. In simpler terms, it helps you manage and track changes to your code. GitHub extends Git’s functionality by providing a user-friendly interface and collaborative features, making it an essential tool for individual developers and large-scale teams alike.

Here are its key concepts:

  • Repositories: These are containers for your project. A repository, or “repo,” holds all the files, history, and documentation related to your project.
  • Commits: Each change you make to your project is captured in a commit. Commits help you track the progress of your project and can be accompanied by messages to describe the changes.
  • Branches: Branches allow you to work on different versions of your project simultaneously. You can experiment with new features or fix bugs without affecting the main project until you’re ready to merge your changes.
  • Pull Requests: When you’ve made changes in a branch and are ready to merge them into the main project, you create a pull request. This allows others to review your changes before they are incorporated.

GitHub’s use within the code review process

GitHub plays a crucial role in the code review process, facilitating collaboration and maintaining code quality within a development team. Here’s an overview of how GitHub is used in the code review process:

  1. Pull requests (PRs):
    • Developers typically create a branch for a new feature or bug fix. Once the changes have been implemented, they initiate a pull request.
    • A pull request is a proposal to merge the changes from one branch into another (often from a feature branch into the main branch).
    • PRs encapsulate the changes made, providing an overview of the additions, modifications, and deletions.
  2. Reviewers:
    • In a collaborative environment, code reviews involve one or more reviewers who examine the changes proposed in a pull request.
    • Reviewers may include peers, team leads, or anyone with expertise in the code base. Their role is to ensure code quality, adherence to coding standards, and the correctness of the implementation.
  3. Discussion and feedback:
    • GitHub’s interface allows reviewers to comment on specific lines of code. This feature facilitates detailed discussions about the proposed changes.
    • Reviewers can suggest improvements, request clarifications, or point out potential issues directly within the context of the code.
  4. Continuous integration (CI):
    • Many development teams integrate CI tools (such as Jenkins, Travis CI, or GitHub Actions) with GitHub.
    • CI automatically builds and tests code changes whenever a pull request is opened or updated. This ensures that proposed changes don’t break existing functionality and helps maintain a stable code base.
  5. Status checks:
    • GitHub allows integration with various status checks, including automated tests, code style checks, and other custom checks defined by the development team.
    • Pull requests can only be merged if all defined status checks pass. This ensures that the proposed changes meet the project’s quality standards.
  6. Iterative improvements:
    • Code reviews often involve multiple iterations. Developers can make additional commits to the same branch in response to feedback and then update the pull request.
    • The iterative process continues until the changes are approved and meet the team’s standards.
  7. Merge and deployment:
    • Once the code review process is complete, and the changes are approved, the pull request can be merged into the target branch (for example, main or master)
    • Merging triggers further actions, such as deployment to staging or production environments, depending on the team’s release process
  8. History and documentation:
    • GitHub maintains a detailed history of all changes made through pull requests. This historical record is invaluable for understanding the evolution of the code base and tracking who contributed to specific features or fixes.

By leveraging GitHub’s features for pull requests, code review, and integrations with CI tools, development teams can streamline their workflows, catch potential issues early in the development process, and maintain high-quality code bases. This collaborative approach promotes knowledge sharing, code consistency, and overall team efficiency.

Resources for learning

To learn more about using GitHub, coding best practices, and using software methodologies to manage your projects, you can use the following resources:

  • GitHub Learning Lab: GitHub provides an interactive learning experience through Learning Lab (https://github.com/apps/github-learning-lab). This platform offers hands-on courses on Git, GitHub, and other related topics.
  • GitHub Guides: GitHub Guides (https://guides.github.com/) covers a wide range of topics, from the basics of GitHub to more advanced workflows. The guides are well-structured and easy to follow.
  • YouTube tutorials: Numerous tutorials on YouTube cater to GitHub beginners. Channels such as The Net Ninja and Traversy Media provide step-by-step guides for using GitHub.
  • Documentation: GitHub’s official documentation (https://docs.github.com/en) is a valuable resource. It covers everything from the basics to advanced topics, providing in-depth explanations and examples.
  • Interactive Git tutorial: If you’re new to Git, try the tryGit (https://try.github.io/) interactive tutorial. It’s a hands-on way to learn the basics of Git right in your browser.
  • C# coding standards and best practices: Dofactory has a good web page (https://dofactory.com/csharp-coding-standards) that provides C# coding standards and best practices with C# code.
  • C# design patterns: Dofactory provides an excellent online resource (https://dofactory.com/net/design-patterns) that covers the gang-of-four (GoF) software design patterns with detailed explanations, UML diagrams, and source code.
  • Agile software development methodologies and how to apply them: The Code Project article at https://www.codeproject.com/articles/604417/agile-software-development-methodologies-and-how-t takes you on a journey from the Waterfall method through to the modern Scrum methodology and is an interesting article on choosing the right project management methodology for managing your software projects.
  • Code Project: Code Project (https://www.codeproject.com/) is a good place to search for articles, tutorials, and code examples, as well as search for software implementation guidance on topics such as YAGNI, DRY, SOLID, and the software development life cycle (SDLC).

GitHub is an indispensable tool for modern software development, fostering collaboration, version control, and efficient project management. By familiarizing yourself with its key concepts and exploring the recommended resources, you’ll be well on your way to mastering GitHub and enhancing your development workflow.

You have been reading a chapter from
Clean Code with C# - Second Edition
Published in: Dec 2023
Publisher: Packt
ISBN-13: 9781837635191
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image