kgrzybek / modular-monolith-with-ddd

Full Modular Monolith application with Domain-Driven Design approach.
MIT License
10.82k stars 1.7k forks source link

refactor: Enhancements to Query Management and Consistency in SQL Queries #297

Closed AlmarAubel closed 8 months ago

AlmarAubel commented 8 months ago

Title: Enhancements to Query Management and Consistency in SQL Queries

Hello,

I've made several improvements to the codebase, focusing on enhancing readability and consistency across all SQL queries. Below is a detailed breakdown of the changes:

  1. Adoption of C# Raw String Literals: Utilizing the new Raw string literal feature introduced in C# 11, I've refactored the queries for improved readability and reduced complexity. This feature allows for multi-line strings without the need for escape characters, making the SQL queries more readable and maintainable.

  2. Dynamic Alias Names in SQL Queries: Wherever alias names in SQL queries were hard-coded, I have updated them to dynamically derive from the DTO property names. This ensures better alignment between the database layer and the data transfer objects, enhancing code consistency and reducing the risk of errors during refactoring or property name changes.

  3. Partial Refactor of Update Queries: I've rewritten a portion of the update queries to i clarity. The remaining update queries will be addressed in a subsequent PR.

  4. I have moved all queries into their own constant strings. This change streamlines the code structure.

The primary goal of these changes is to increase the readability and consistency of the SQL queries throughout the entire codebase. This should aid future development and maintenance efforts.

Looking forward to your feedback and suggestions.

kgrzybek commented 8 months ago
  1. Adoption of C# Raw String Literals: Utilizing the new Raw string literal feature introduced in C# 11, I've refactored the queries for improved readability and reduced complexity. This feature allows for multi-line strings without the need for escape characters, making the SQL queries more readable and maintainable.

I like it and I agree - it is more readable and maintainable

  1. Dynamic Alias Names in SQL Queries: Wherever alias names in SQL queries were hard-coded, I have updated them to dynamically derive from the DTO property names. This ensures better alignment between the database layer and the data transfer objects, enhancing code consistency and reducing the risk of errors during refactoring or property name changes.

Yes, there were places without that and this is important because of reasons you mentioned.

  1. Partial Refactor of Update Queries: I've rewritten a portion of the update queries to i clarity. The remaining update queries will be addressed in a subsequent PR.

Ok

  1. I have moved all queries into their own constant strings. This change streamlines the code structure.

Yep, if something can a be constant it should be.

To sum up - everything is ok, thanks for another great change - I am merging :)