Comment

Comment by tjtrapp

iirc the last time i used a switch was to create a static factory method to instantiate objects. the static class had a static method that took an enum as input. the return type was an abstract base class. the method switched off of the enum, new'd up the type - did some common initialization - and returned the new object to the caller. this approach keeps your "creation" logic in one place.
parent tjtrapp 9 years ago

No comments yet

Be the first to share your thoughts.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton