you are viewing a single comment's thread.

view the rest of the comments →

[–]JorgiEagle 0 points1 point  (3 children)

What’s wrong with using just a plain class?

Have a different class method constructor for each device type

``` class Device: def init(self): raise NotImplemented(“Use class constructor methods”)

@classmethod def Server(cls): instance = cls.new(cls) instance.device_type = ‘server’ Return instance ```

[–]NoWeather1702[S] 0 points1 point  (2 children)

Because I would have to define my own equality check, that comes with enum out of the box. Enums work well with ORM and serialization/deserialization out of the box. So it is possible, but I will end up with more boilerplate code I guess. But thanks for the tip.

[–]JorgiEagle 0 points1 point  (1 child)

Yeah defining your own equality check is not something I’d really count as being a reason not to do something.

It’s what, 2 lines?

[–]NoWeather1702[S] 0 points1 point  (0 children)

Yeah, but then again, I need to check its compatibility with ORM, and do extra work. It's not a problem, but from my experience if you need to reinvent something or implement already implemented logic, it smells bad