1-) Factory Method Design Pattern

recep orhan
1 min readJun 24, 2021

The factory method pattern is a creational pattern that uses factory methods to deal with the problem of creating objects without having to specify the exact class of the object that will be created. Let’s code

We have an application in which we manage hiring processes. Firstly create an Interface IInterwiev and AskQuestion Method. Implement IInterview to Coding and Personal.

Create an abstract class HiringManager. Create MakeInterview Abstract Method that returns IInterviewMethod. Define to derived DevelopmentManager and RecruitmentManager classes from HiringManager. With override the MakeInterview method we produce to return different concrete classes according to derived class.

Lastly, create a candidate class that can use this infrastructure. Use RecruitmentManager and DevelopmentManager respectively.

With open a console application and write the bottom code, use the hiring manager application.

If we need that general manager join the interview too, define to GeneralManager classes with deriving from HiringManager without changing previous classes. Candidate's final version is below.

--

--