5:54 Why would you want a static factory method over using a constructor? Is it just for improved naming? Or because the function can be passed around?
The reason for the factory method is so it can return different subclasses once I've created them. By adding this layer of indirection I avoid having to update all the places in the code that call the constructor directly to instead construct subclasses.
Absolutely love your channel! I'm really curious to hear your thoughts on AI's impact on software engineering and whether it'll enhance the quality of codebases. Keep up the fantastic work!
5:54 Why would you want a static factory method over using a constructor? Is it just for improved naming? Or because the function can be passed around?
The reason for the factory method is so it can return different subclasses once I've created them. By adding this layer of indirection I avoid having to update all the places in the code that call the constructor directly to instead construct subclasses.
Absolutely love your channel! I'm really curious to hear your thoughts on AI's impact on software engineering and whether it'll enhance the quality of codebases. Keep up the fantastic work!
Thanks! I'm also interested in AI coding assistants, thanks for the prompt to talk more about it on the channel.
Amazing video Bache, thanks! May I know the IDE name? :)
This demo in C# uses the Rider IDE. There's a longer version of this demo in another video - ruclips.net/video/IvFX8Ivit1k/видео.html