Created
July 25, 2019 20:14
-
-
Save nafidurmus/4c0d99e62c2287c2ccec0903fef57ccb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prototype Pattern kullanmadan | |
class ProductDefinition | |
def create_product | |
@product = Product.new( | |
product_definition_name: self.name, | |
properties: self.properties, | |
active: self.active?, | |
category: self.category | |
) | |
end | |
end | |
#------------------------------------ | |
class Product | |
end | |
# Prototype Pattern kullanarak | |
class Product | |
def _clone(product_definition) | |
Product.new( | |
self.product_definition_name(product_definition), | |
self.properties, | |
self.active?, | |
self.category | |
) | |
end | |
end | |
#kullanımı | |
product_prototype = Product.new | |
product_instance_a = product_prototype._clone("Telescope") | |
product_instance_b = product_prototype._clone("Light Saber") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment