Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Creational Pattern Pull Request)
Why I did it?
I have used the factory design pattern to do my creational pattern where i had to provide an interface for creating objects in superclass, but allowing subclasses to alter the type of objects that will be created. 
How i did it?
I created a new interface class for location to implement creational pattern and the interface for location class is missing so i just added an interface class and serialized the location into a dict.
  • Loading branch information
Billa32 authored Aug 14, 2021
commit c3d8c6ec538e8d9c75a917e7665aeb39e276a19d
12 changes: 11 additions & 1 deletion app/location/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,18 @@
from ..utils import countries
from ..utils.populations import country_population

from abc import abstractmethod, ABCMeta

class ILocation(metaclass=ABCMeta):

@abstractmethod
def serialize():
"""
Serializes the location into a dict.
"""

# pylint: disable=redefined-builtin,invalid-name
class Location: # pylint: disable=too-many-instance-attributes
class Location(ILocation): # pylint: disable=too-many-instance-attributes
"""
A location in the world affected by the coronavirus.
"""
Expand Down Expand Up @@ -74,6 +83,7 @@ def serialize(self):
}



class TimelinedLocation(Location):
"""
A location with timelines.
Expand Down