Wrox Home  
Search

Topic: .NET

.NET Domain-Driven Design with C#: Problem - Design - Solution (0470147563) cover image

.NET Domain-Driven Design with C#: Problem - Design - Solution

Tim McCarthy
ISBN: 978-0-470-14756-6
Paperback
432 pages
April 2008
This title is out-of-print and not currently available for purchase from this site.


Do you think you've discovered an error in this book? Please check the list of errata below to see if we've already addressed the error. If not, please submit the error via our Errata Form. We will attempt to verify your error; if you're right, we will post a correction below.

ChapterPageDetailsDatePrint Run
22 Code Correction
In the GetHashCode() method in the code listing,
the key may be null and should therefore be
checked before invoking its GetHashCode()
method.
05/05/2008
32-33 Error in Code Example
The code sample should look like this: using System; using System.Collections.Generic; using SmartCA.Infrastructure.DomainBase; using SmartCA.Infrastructure.RepositoryFramework; using System.Transactions; namespace SmartCA.Infrastructure { public class UnitOfWork : IUnitOfWork { private Dictionary<EntityBase, IUnitOfWorkRepository> addedEntities; private Dictionary<EntityBase, IUnitOfWorkRepository> changedEntities; private Dictionary<EntityBase, IUnitOfWorkRepository> deletedEntities; public UnitOfWork() { this.addedEntities = new Dictionary<EntityBase, IUnitOfWorkRepository>(); this.changedEntities = new Dictionary<EntityBase, IUnitOfWorkRepository>(); this.deletedEntities = new Dictionary<EntityBase, IUnitOfWorkRepository>(); } #region IUnitOfWork Members public void RegisterAdded(EntityBase entity, IUnitOfWorkRepository repository) { this.addedEntities.Add(entity, repository); } public void RegisterChanged(EntityBase entity, IUnitOfWorkRepository repository) { this.changedEntities.Add(entity, repository); } public void RegisterRemoved(EntityBase entity, IUnitOfWorkRepository repository) { this.deletedEntities.Add(entity, repository); } public void Commit() { using (TransactionScope scope = new TransactionScope()) { foreach (EntityBase entity in this.deletedEntities.Keys) { this.deletedEntities[entity].PersistDeletedItem(entity); } foreach (EntityBase entity in this.addedEntities.Keys) { this.addedEntities[entity].PersistNewItem(entity); } foreach (EntityBase entity in this.changedEntities.Keys) { this.changedEntities[entity].PersistUpdatedItem(entity); } scope.Complete(); } this.deletedEntities.Clear(); this.addedEntities.Clear(); this.changedEntities.Clear(); } #endregion } } the actual code files for the chapter are correct
05/29/08
33 Reference Correction
The reference to the Nilsson book in the third
section of the Unity of Work chapter has a
incomplete year (200).
05/05/2008
33-35 Error in Code Example
the second code example code should look like this: using System; using SmartCA.Infrastructure.DomainBase; using System.Collections.Generic; namespace SmartCA.Infrastructure.RepositoryFramework { public abstract class RepositoryBase<T> : IRepository<T>, IUnitOfWorkRepository where T : EntityBase { private IUnitOfWork unitOfWork; protected RepositoryBase() : this(null) { } protected RepositoryBase(IUnitOfWork unitOfWork) { this.unitOfWork = unitOfWork; } #region IRepository<T> Members public abstract T FindBy(object key); public abstract IList<T> FindAll(); public void Add(T item) { if (this.unitOfWork != null) { this.unitOfWork.RegisterAdded(item, this); } } public void Remove(T item) { if (this.unitOfWork != null) { this.unitOfWork.RegisterRemoved(item, this); } } public T this[object key] { get { return this.FindBy(key); } set { if (this.FindBy(key) == null) { this.Add(value); } else { if (this.unitOfWork != null) { this.unitOfWork.RegisterChanged(value, this); } } } } #endregion #region IUnitOfWorkRepository Members public void PersistNewItem(EntityBase item) { this.PersistNewItem((T)item); } public void PersistUpdatedItem(EntityBase item) { this.PersistUpdatedItem((T)item); } public void PersistDeletedItem(EntityBase item) { this.PersistDeletedItem((T)item); } #endregion protected abstract void PersistNewItem(T item); protected abstract void PersistUpdatedItem(T item); protected abstract void PersistDeletedItem(T item); } } the actual code file for the chapter is correct
05/29/08
44 Error in Text
First line under heading "The EntityFactoryBuilder Class":

repositories

should be:
IEntityFactory<T> instances
07/21/08
4 109 Error in Text
In the next few sections, I will be designing the domain model, determining the Project Aggregate and its boundaries, and designing the repository for Projects.

should be:
In the next few sections, I will be designing the domain model, determining the aggregates and their boundaries, and designing the repositories for Companies and Contacts".
07/29/08
173 Code Correction
The code listing on page 173 should now look like this:

using System;
using SmartCA.Model.Projects;
namespace SmartCA.Model.Submittals
{
public class TrackingItem
{
private SpecificationSection specSection;
private int totalItemsReceived;
private int totalItemsSent;
private int deferredApproval;
private int substitutionNumber;
private string description;
private ActionStatus status;

public TrackingItem(SpecificationSection specSection)
{
this.specSection = specSection;
this.totalItemsReceived = 0;
this.totalItemsSent = 0;
this.deferredApproval = 0;
this.description = string.Empty;
this.status = ActionStatus.NoExceptionTaken;
}

public SpecificationSection SpecSection
{
get { return this.specSection; }
set { this.specSection = value; }
}

public int TotalItemsReceived
{
get { return this.totalItemsReceived; }
set
{
if (value != this.totalItemsReceived) { this.totalItemsReceived = value;
// Default to making the total number
// of items sent equal to what was received
this.totalItemsSent = value;
}
}
}

public int TotalItemsSent
{
get { return this.totalItemsSent; }
set { this.totalItemsSent = value; }
}

public int DeferredApproval
{
get { return this.deferredApproval; }
set { this.deferredApproval = value; }
}

public int SubstitutionNumber
{
get { return this.substitutionNumber; }
set { this.substitutionNumber = value; }
}

public string Description
{
get { return this.description; }
set { this.description = value; }
}

public ActionStatus Status
{
get { return this.status; }
set { this.status = value; }
}
}
}
05/08/2008
Printer-Ready Version   Share This
With you wherever you go: pdf + ePub + kindle -- DRM-free