GithubHelp home page GithubHelp logo

anemicdomainmodel's People

Contributors

vkhorikov 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  avatar

Watchers

 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

anemicdomainmodel's Issues

Transaction commit pattern

First of all, thanks for putting this repo online. It's a great source of inspiration to me.

However, I have one specific question: is there a reason why you commit the transaction on disposal? The controller might have already returned an OK response to the client while the transaction might fail during disposal afterwards.

Shouldn't you simply commit the transaction within UnitOfWork.Commit()?

Validation Logic

How would you share the validation logic between the Create and Update methods on the CustomerController if you needed to check for name, email and email validation uniqueness on both methods? Would a private method be sufficient? What if that logic needed to be shared somewhere else?

Test/Mock of ValueObject

I would like to be able to create a unit test where the ValueObject is not dependent on internal objects that can change.
A specific issue is how you can test something that is using the ExpirationDate class. How would you mock the public bool IsExpired => this != Infinite && Date < DateTime.UtcNow;
that is using DateTime - that will change each time the test runs.

Dollars Value Object operators

Hi,

I'm watching your course on pluralsight and it gave me a lot of good ideas on how to implement what you've done in your sample project that i can apply in my future projects. Good stuff...

I just have some questions on Dollars operators particularly the operator *.

public static Dollars operator *(Dollars dollars, decimal multiplier)
. If i pass a negative multiplier, the Dollars class is now in invalid state because it is negative. Shouldn't the statement be a call to static Create so that it will still go the validation checks?

Validation of DTO properties which not mapped to ValueObjects

Hello Vladimir. Thank you for course "Refactoring from anemic to rich model"!
I have a question about validation.
We removed all validation attributes (for example Required) from DTO. Also we removed checking of model state from controller (if (!ModelState.IsValid) return BadRequest();)
And we moved validation to ValueObjects. Ok.
But how we will validate properties from DTO which not mapped to ValueObjects? Lets imagine that Customer entity has one more string property Name1 with length < 50 (and this property is not value object). Where we will check this constraint? We will add at attribute StringLenght(50) to property in DTO and return checking of Model state in controller? Or we will use another solution, for example validation of Name1.Length in constructor of Customer entity?

Should the Entity Class Move to an Infrastructure Project?

I wanted to see if there has been any thought with getting the Entity class outside of the Logic project? I ask as I have written many anemic applications in my life and one of the principles of the Onion architecture that I liked/followed was to try to keep infrastructure knowledge out of the Logic/Core project.

  1. Do you consider this to be an important principle?
  2. If important, how would you refactor?

Thanks for any consideration.

When to return result vs throw exception?

Hey Vladimir,

Big fan and thanks for the course!

Per the title, I'm a little confused when you were returning Results versus throwing exceptions. From your previous content, I believe your stance boils down to return Results for expected errors, and throw exceptions representing programmer errors or ones that can't be handled.

Customer.promote throws when already promoted, even though this is an error we expect and can handle. Unless the programmer error is he didn't check canPromote beforehand. Similarly, the value objects used factory methods return Results with input validation, but the Customer constructor throws with invalid arguments. The implication is the programmer has to validate the name and email before calling the Customer constructor.

This feels a little inconsistent and breaks encapsulation. I wonder if you still completely agree with the code here, and if so, how you would formalize this heuristic? Should value objects comprising an entity provide input validation via Results, while entities should throw errors to protect their invariants?

Thanks again.

`DBCreationScript.txt` is missing

Hi @vkhorikov,

when I look into the README.md file of this repository with a normal text editor, I see that there is an unused reference-link to [L2]: DBCreationScript.txt at the bottom of the file. I would expect that file to be in the top level directory of the repository, but it isn't anywhere in the repository. Would you consider adding it to the repository to help trainees get the database up and running?

Btw, I am very much enjoying your pluralsight course(s), awesome work ๐Ÿ‘

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.