Comments (2)
Yep, it is a good alternative to use sealed class instead of enum, especially when Country is something more then a dummy value.
For such simple example enum syntax is much more concise.
from design-patterns-in-kotlin.
Refactored to make use of sealed classes: https://github.com/dbacinski/Design-Patterns-In-Kotlin/blob/master/patterns/src/test/kotlin/FactoryMethod.kt
from design-patterns-in-kotlin.
Related Issues (11)
- Decorator doesn't demonstrate overriding behaviour, only extending it HOT 8
- What about Null Object pattern? HOT 5
- Factory and object instead of class HOT 3
- fields after methods HOT 2
- Use a list of observers instead of only one HOT 5
- request for example of repository pattern, with optional caching HOT 5
- Builder and apply HOT 1
- How to mock UserRepository? HOT 1
- Wrong usage of an Observer/Listener pattern example HOT 2
- Add println() inside PrintingTextChangedListener in Observer pattern otherwise we don't get any output
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from design-patterns-in-kotlin.