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 617873
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T18:28:58+00:00 2026-05-13T18:28:58+00:00

I am currently thinking about with what pattern I should solve the following issue.

  • 0

I am currently thinking about with what pattern I should solve the following issue.

I’ve got an entity called IdentificationRequest. This entity is used to identify a Person by some criteria.

public class IdentificationRequest
{
     public IdentificationCriteria Criteria;
     public Person IdentifiedPerson;

     protected internal virtual void RedirectToManualIdentification()
     {
        ChangeState(IdentificationRequestState.ManualIdentificationRequested);
     }

     public virtual void StartManualIdentification()
     {
        ChangeState(IdentificationRequestState.ManualIdentificationInProgress);
     }

     public virtual void AssignIdentifiedPerson(Person person)
     {
        identifiedPerson = person;
        ChangeState(IdentificationRequestState.IdentificationFinished);       
     }
}

public class IdentificationCriteria
{
     public string Name;
}

This is a simplified example. In realitiy the IdentificationRequest contains much more information, as well as the IdentificationCriteria.

So basically a client creates an IdentificationRequest with its IdentificationCriteria and then the correct Person needs to be identified. For this, the criteria needs to be passed to the persistence layer to check whether there is a person in the database matching the criteria. If not person can be found, a human interaction is then required to assign the correct Person to the request.

For the process of identification I am currently using a service. Like:

    public class IdentificationService : IIdentificationService
        {
            private readonly IPersonRepository personRepository ;
            private readonly IIdentificationRequestRepository identificationRequestRepository;

            public IdentificationService(IPersonRepository personRepository )
            {
                this.personRepository = personRepository ;
            }

            public bool IdentifyPerson(IdentificationRequest identificationRequest)
            {
                var matches = personRepository.FindByIdentificationCriteria(identificationRequest.Criteria);

                // some additional post analysis of the matches returned from the persistence layer
                var criteriaAnalyzer = new IdentificationCriteriaAnalyzer(identificationRequest.Criteria);
                var uniqueMatch = criteriaAnalyzer.TryIdentify(matches);

                if(uniqueMatch != null)
                {
                    identificationRequest.AssignIdentifiedPerson(uniqueMatch);
                    return true;
                }
                else
                {
                    identificationRequest.RedirectToManualIdentification();
                    return false;
                }            
            }
        }

This service is part of the domain assembly. Now my question is, if that is the right pattern to perform the identification? Or would I use a factory, to create the identification request and then directly try to identify it, like:

public class IdentificationRequestFactory
{
    private readonly IPersonRepository personRepository;

    public IdentificationRequestFactory(IPersonRepository personRepository)
    {
        this.personRepository = personRepository;
    }

    public IdentificationRequest Create(IdentificationCriteria identificationCriteria)
    {
        var request = new IdentificationRequest(identificationCriteria);

        var matches = personRepository.FindByIdentificationCriteria(identificationRequest.Criteria);
        var criteriaAnalyzer = new IdentificationCriteriaAnalyzer(identificationRequest.Criteria);
        var uniqueMatch = criteriaAnalyzer.TryIdentify(matches);

        if(uniqueMatch != null)
        {
            identificationRequest.AssignIdentifiedPerson(uniqueMatch);

        }
        else
        {
            identificationRequest.RedirectToManualIdentification();

        }

        return request;
    }
}

This way, an IdentificationRequest can only be constructed by the factory, making sure that the process of identification is done already and the request is in a valid state.

Or would you let the IdentificationRequest identify itself by doing a method injection like:

public class IdentificationRequest
{
    public IdentificationCriteria Criteria;
    public Person IdentifiedPerson;

    public void Identify(IPersonRepository personRepository)
    {
        // identification logic here
    }
}

This example would couple the process of identification to the request directly.

What is a common pattern for such a case? Is there a common pattern anyway? What are the pros and cons?

Thx in advance!

Update

Maybe I dont understand the command pattern correctly, but what benefits do I get of it in this case? Is the following implementation correct?

public class IdentificationCommandFactory
{
    private readonly IPersonRepository personRepository;

    public IdentificationCommandFactory(IPersonRepository personRepository)
    {

        this.personRepository = personRepository;
    }

    public IIdentificationCommand Create(IdentificationRequest identificationRequest)
    {
        var matches = personRepository.FindByIdentificationCriteria(identificationRequest);
        var criteriaAnalyzer = new IdentificationCriteriaAnalyzer(identificationRequest);
        var uniqueMatch = criteriaAnalyzer.TryIdentify(matches);

        if(uniqueMatch != null)
        {                
            return new AssignIdentifiedPersonCommand(identificationRequest, uniqueMatch);
        }
        else
        {                
            return new RedirectToManualIdentificationCommand(identificationRequest);
        }    
    }

}

public interface IIdentificationCommand
{
    void Execute();
}

public class RedirectToManualIdentificationCommand : IIdentificationCommand
{
    private readonly IdentificationRequest identificationRequest;

    public RedirectToManualIdentificationCommand(IdentificationRequest identificationRequest)
    {
        this.identificationRequest = identificationRequest;
    }

    public void Execute()
    {
        identificationRequest.RedirectToManualIdentification();
    }
}

public class AssignIdentifiedPersonCommand : IIdentificationCommand
{
    private readonly IdentificationRequest identificationRequest;
    private readonly Person personIdentified;

    public AssignIdentifiedPersonCommand(IdentificationRequest identificationRequest, Person personIdentified)
    {
        this.identificationRequest = identificationRequest;
        this.personIdentified = personIdentified;
    }

    public void Execute()
    {
        identificationRequest.AssignIdentifiedPerson(personIdentified);
    }
 }

The caller:

    var identificationCommandFactory = new IdentificationCommandFactory(personRepository);

    var command = identificationCommandFactory.Create(request);

    command.Execute();
  • 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-13T18:28:58+00:00Added an answer on May 13, 2026 at 6:28 pm

    The primary goal of your development should be to meet the requirements with the simplest, cleanest code possible. (http://msdn.microsoft.com/en-us/magazine/cc163962.aspx)

    With that said, unless you have a specific reason to use one of these patterns, stop now. If there is no specific reason to go to this work, you’re just writing more code in the hope that it will be useful someday. Just write what works. Refactor it later, if the need arises.

    If the need is present, continue down the path of keeping it simple. Pick a pattern, library, or other tool that will allow you to write clean, simple, readable code that does the job.

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

Sidebar

Ask A Question

Stats

  • Questions 299k
  • Answers 299k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer What you probably want is comet, not setInterval as you'll… May 13, 2026 at 7:45 pm
  • Editorial Team
    Editorial Team added an answer Just create a form like this: <form action="formhandler.php" method="post"> <!--… May 13, 2026 at 7:45 pm
  • Editorial Team
    Editorial Team added an answer Here are the steps to deploy ASP.NET Website on Windows… May 13, 2026 at 7:45 pm

Related Questions

I have mapped several java classes like Customer, Assessment, Rating, ... to a database
I have a problem which I believe is the classic master/worker pattern, and I'm
I'm writing my first app with ASP.NET MVP (attempting Supervisory Controller) and Unit Testing
I have just started working on a reusable library. This library is going to
I have a main form at present it has a tab control and 3

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.