Summarizing the Basic Implementation
00:00
So let me walk you through the basic implementation, referring back to the graphic we had during the introduction. So we have the client who uses an interface, which is serialize_song()
and data_format
, to speak or communicate with the creator and a creator is the internal function _get_serializer()
. The creator is supposed to call a factory, which it doesn’t do very clearly right now.
00:26
And that factory creates the products which are the internal functions, _serialize_to_json()
and _serialize_to_xml()
.
00:36 So these are the components of the basic implementation.
00:42 Looking at this solution and this structure, though, there are some potential improvements. For example, we really should work towards a clearly-defined factory method, which we haven’t done yet.
00:54 Product classes would probably be useful instead of functions. Working with classes is more object-oriented, and it allows us to have some more flexibility and better structure as we will see in the following examples.
01:09 Same thing for the creator. We could have a class instead of a function, which again would help with structure and with functionality. So in general, yes, we could have more flexibility and a better structure, and you’ll be implementing all those improvements and more actually in the advanced implementation of the Factory Method in the next lessons.
Become a Member to join the conversation.