Code Monkey home page Code Monkey logo

ssw.cleanarchitecture's People

Contributors

bradystroud avatar calinator444 avatar christoment avatar danielmackay avatar dependabot[bot] avatar gordonbeeming avatar hona avatar jernejk avatar matt-goldman avatar ncn-ssw avatar wicksipedia avatar william-liebenberg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ssw.cleanarchitecture's Issues

📝 CA Announcement PPT

Split the original Clean Architecture v2 PPT from the retreat into smaller PPT specific for announcing CA v2 template

♻️ Using Result object as control flow instead of exceptions

Premise:

  • Exceptions are slower than Result objects (https://youtu.be/a1ye9eGTB98 - quick benchmark shows ~1us slower)
  • Using Exceptions as a control flow is a questionable approach, since it allows code to jump from nested method all the way to the caller (questionable = both good and bad)
  • Using result objects everywhere means more codes to write

Consideration:

  • Using mixed method is a brain overload for a small performance benefit
  • We haven't seen any big performance problems yet on our clients

Proposed decision:

  • Keep using exceptions for now - keep it simple
  • When there's a need arise (e.g. performance requirement, validation requirement) - handle it case-by-case

🗣️ Agree on how to record decisions

While working on this template we often have discussions on particular concepts and decide to go one way or another. These decisions should be documented in an organized fashion and made public.

Some possible options:

Resources:

Ensure any tool allows you to easily access the content if we switch to something else.

Tasks

  1. danielmackay
  2. danielmackay
  3. danielmackay
  4. danielmackay
  5. danielmackay
  6. danielmackay

Common Base Entity Configuration

public class TodoItemConfiguration : IEntityTypeConfiguration<TodoItem>
{
    // TODO: Rip out the common pieces that are from BaseEntity
    // virtual method, override 
    // Good marker to enforce that all entities have configuration defined via arch tests
    public void Configure(EntityTypeBuilder<TodoItem> builder)
    {
        builder.HasKey(t => t.Id);
        builder.Property(t => t.Id)
            .HasConversion(x => x.Value, 
                x => new TodoItemId(x))
            .ValueGeneratedOnAdd();
        
        builder.Property(t => t.Title)
            .HasMaxLength(200)
            .IsRequired();
    }
}

Test Unhandled Exceptions

    private static IResult HandleException(this HttpContext context, Exception exception)
    {
        var type = exception.GetType();

        if (ExceptionHandlers.ContainsKey(type))
            return ExceptionHandlers[type].Invoke(context, exception);

        // TODO: Testing around unhandled exceptions
        return Results.Problem(statusCode: StatusCodes.Status500InternalServerError,
            type: "https://tools.ietf.org/html/rfc7231#section-6.6.1");
    }

Discussion Use of String in CreatedBy/UpdatedBY

public abstract class AuditableEntity
{
    public DateTimeOffset CreatedAt { get; set; }
    public string? CreatedBy { get; set; } // TODO: String as userId?
    public DateTimeOffset? UpdatedAt { get; set; }
    public string? UpdatedBy { get; set; } // TODO: String as userId?
}

🧪 Add Architecture unit tests

AC: GIVEN I am a developer
WHEN I Violate CA
THEN I get build/unit test errors

GIVEN I am a tech lead
WHEN I setup a project best practice
AND Developers violate the practices
THEN They get build/unit test errors

📦 Dotnet CLI Template (dotnet new cleanarchitecture)

To quickly set up a new project, utilize the dotnet CLI templates so that we can execute a command like:

dotnet new ssw-ca -n MyCleanArchitectureProject --ui BlazorWasm

to produce a ready-to-use solution.

Tasks:

  • create template
  • package via nuget
  • automate publish template via CI/CD pipeline

Resources

Discuss Use of System Clock

public interface IDateTime
{
    // TODO: Talk to Gordon about this - System Clock
    public DateTimeOffset Now => DateTimeOffset.UtcNow;
}

🎓 Develop CA v2 Workshop

Tasks

  1. danielmackay

♻️ Remove Repositories from the Template

  • Also move to reference architecture
  • Remove Repositories
  • Add EF Back to Application
  • Show benefits of using Specifications with DbContext
  • Investigate testing of Specifications

✨ EF Core Healthcheck

Currently we have a health check endpoint:

app.UseHealthChecks("/health");

Add comprehensive health checks:

Image

Consider adding healthcheck UI

Better Swagger Docs

Investigate examples for swagger docs. i.e. better docs than:

myWeirdField: "string" vs myWeirdField: "this-silly-string"

🔙 Restore Domain Events feature

Keep Domain Events and Application Events separate.

Domain Events are added to the Domain Entities and raised from ApplicationDbContext when changes are saved. The domain events are handled using the MediatR INotificationHandler

Application Events can be raised from within the Application Commands/Queries using mediator.Publish() and are also handled using the MediatR INotificationHandler

This does mean that we will need to pay the price of depending on MediatR in our Domain Layer - but it is a small price to pay.

✨ Add Specifications for querying data

APPROACH: Remove dependency from EF Core in application layer by adding repository pattern.

AC: Spec pattern allowing better unit testing for things that might be integration tested when using EF Core in application layer

🐛 Remove Static User Secrets ID

Currently we have the following in WebApi.csproj:

<UserSecretsId>fc525b0c-3d84-4847-9b4f-840f8db76d87</UserSecretsId>

By having a static UserSecretsId, we will always pick up the same underlying JSON file across all projects.

This should be removed so that a unique UserSecretsId is generated per project when managing secrets.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.