Prototype Pattern in kotlin | Design Patterns

Prototype allows us to hide the complexity of making new instances from the client. The concept is to copy an existing object rather than creating a new instance from scratch, something that may include costly operations.

The existing object acts as a prototype and contains the state of the object.

The newly copied object may change same properties only if required. This approach saves costly resources and time, especially when the object creation is a heavy process.

package creational

data class Person(val name: String?, val lastName: String?)

fun main(args: Array<String>) {
    val prototype = Person("Bartosz", "Jarocki")
    val differentPerson = prototype.copy(lastName = "Ikcoraj")

Join My Facebook Group
Join Group

About Author

Myself KarthiQ, I am the author of this blog, I know ways to write a good article but some how I donot have the skills to make it to reach people, would you like help me to reach more people By sharing this Article in the social media.

Share this Article Facebook
Comment / Suggestion Section
Point our Mistakes and Post Your Suggestions

Recent Addition

new tutorial Protractor Online Training : We have closed registration for training

Please do email to for any queries

If you already registered then please do check your email for the Webex link for the training starting from 15th Nov 2018
Join My Facebook Group
Join Group