Skip to content

Instantly share code, notes, and snippets.

@carloswm85
Created November 15, 2024 23:04
Show Gist options
  • Save carloswm85/2d0798aa6de0cc450f96932ee1c4f5dc to your computer and use it in GitHub Desktop.
Save carloswm85/2d0798aa6de0cc450f96932ee1c4f5dc to your computer and use it in GitHub Desktop.
This is what the component should include. I'm not sure how to turn it into a component diagram though (not sure if even necessary either).
public enum RoleEnum
{
Student,
Company
}
public interface ISearchEngine
{
void Search(string query); // General search method
}
public class CompanySearchEngine : ISearchEngine
{
public void Search(string query)
{
// Implementation specific to companies
}
}
public class StudentSearchEngine : ISearchEngine
{
public void Search(string query)
{
// Implementation specific to students
}
}
public class SearchEngineFactory
{
public static ISearchEngine GetSearchEngine(RoleEnum role)
{
return role switch
{
RoleEnum.Company => new CompanySearchEngine(),
RoleEnum.Student => new StudentSearchEngine(),
_ => throw new ArgumentException("Invalid role"),
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment