Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6576009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:27:27+00:00 2026-05-25T15:27:27+00:00

Please explain the reasoning behind making EventStoreRepository.GetById create a new stream when an aggregate

  • 0

Please explain the reasoning behind making EventStoreRepository.GetById create a new stream when an aggregate doesn’t exist. This behavior appears to give GetById a dual responsibility which in my case could result in undesirable results. For example, my aggregates always implement a factory method for their creation so that their first event results in the setting of the aggregate’s Id. If a command was handled prior to the existance of the aggregate it may succeed even though the aggregate doesn’t have it’s Id set or other state initialized (crash-n-burn with null reference exception is equally as likely).

I would much rather have GetById throw an exception if an aggregate doesn’t exist to prevent premature creation and command handling.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T15:27:28+00:00Added an answer on May 25, 2026 at 3:27 pm

    That was a dumb design decision on my part. I went back and forth on this one. To be honest, I’m still back and forth on it.

    The issue is that exceptions should really be used to indicate exceptional or unexpected scenarios. The problem is that a stream not being found can be a common operation and even an expected operation in some regards. I tinkered with the idea of throwing an exception, returning null, or returning an empty stream.

    The way to determine if the aggregate is empty is to check the Revision property to see if it’s zero.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Please explain what this task is about? Create a generic linked list class that
Please explain why this doesn't work? What is it about the constraint IPoolable<T> that
Someone please explain to me why this doesn't work, and what I am doing
Please explain to me how this JavaScript row works: <a href=javascript: onclick=document.location='AddItem.aspx?catid=<%# Eval(CollectionID)%>'>[edit items]</a>
Please explain this simple code: public int fibonacci(int n) { if(n == 0) return
Please explain the difference between: ChildForm := TForm.CreateParented(AOwner) ChildForm := TForm.CreateParentedControl(AOwner) ChildForm := TForm.Create(AOwner);
Please explain what is the purpose of this line in CMakeLists.txt: include (InstallRequiredSystemLibraries) I
Please explain this sed command? sed -n s/[^>]*>/ /gp What is gp?
Please explain invokeAndWait() method in SwingUtilities.I am unable to understand this. Explain it very
Please explain this curl command: curl --digest \ -u{username}:{password} \ -v \ -X PUT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.