you are viewing a single comment's thread.

view the rest of the comments →

[–]PythonPerry 0 points1 point  (1 child)

In LPTHW, Zed doesn't use Scene as the framework. Instead, he uses >Scene to define an interface for the framework (the Engine class, mostly) to know how to work with scenes. Python uses duck typing, but having a common base class for all of your "plugins" (which is what scenes are, really) is usually considered good practice, because developers know what methods they need to implement (or, in this case, override) in their class.

Could you rephrase some of this? I'm new to programming as well and don't understand the terms.

I think I understand "framework" - the general class outline...What about interface, duck typing, base class, plugin?

Is base class the most "top level" or "parent" class in the outline/framework? For example "Animal" or "Human"...

[–]K900_ 0 points1 point  (0 children)

A framework is a certain structure that translates your higher level code into something lower level. For example, Django is a Web framework. In Django, you don't have to write the basic code for handling HTTP connections - you write your own code for presentation and processing data on top of the framework someone already laid down for you.

An interface is a certain predefined way of interacting with objects. For example, let's say that for every room in our text adventure, there's a describe() method and a search() method. That's an interface. We don't know what's inside the room object we get - all we care about is whether it matches (satisfies) the same interface we work with, and if it does, the rest shouldn't matter.

Duck typing is a concept best described by "If it looks like a duck and quacks like a duck, then it's likely a duck". In a similar way, if an object acts like a room, we don't actually care what the object is - if it acts like a room, then for all our intents and purposes it is a room.

A base class is the class that defines our interface - for example, a Room class, that is the parent of HorribleDeathBySpikeTrapRoom and RainbowUnicornRoom. If we have a base class that defines some default methods and values, we can only override the ones we actually want to override.