
The following statement comes from the documentation: The function body is 100% optional because in the future it is supposed to be overridden. 💡 TIP: Notice that in regular java interfaces, typically you only do declarations, not implementations. The following code will do the trick to make this Interface 👇 Create the VirusFactory which will eventually generate a proper Virus given the virus type from the enumeration.Create an enumeration which will hold virus types (constants).Create concrete virus classes that implement the Virus interface.We need to convert the following UML into actual code, so lets split the work into tasks. Taking a look at the UML we will be implementing. This article can also be found on my blog archive which is located here. We are going to make a virus factory, that creates virus Java objects! I know this is not 100% practical, but. Since it's 2020 and we're all quarantined, I used an example that is relevant to 2020's pandemic 🦠.


In this article, we will get our hands dirty with Kotlin coding as well as UML & some hot tips!īefore proceeding, you need to be familiar with UML, some basic Kotlin knowledge and have an idea of how Java handles inheritance. We all know design patterns or at least heard of them once in our lives as developers, they are supposed to ensure the maintenance integrity of our codebase and reduce headaches, but do they? The truth is, there are cases where you do not need this pattern and those cases may vary from not using an OOP language, writing a project where you don't really care about its scalability, or it's not complex enough to use a design pattern.
