I'm not sure if "Template Oriented Programming" seems to be the way to go in D, but I've got my head mainly stuck around OOP.

I'm a bit confused about how to dive into it.

With OOP, we create interfaces, which provide a contract that all implementers of the interface have to abide by. Delegation is done through the interfaces to maximize independence between those that use it. Essentially the contract/interface is the law, and nothing is above it.

Now, with TOP, we used templates which are self contained blocks of code that functions similar to generic classes(in fact, identical in some cases). Templates, though, because they can contain compile time logic checking, also can create contracts.

Right?

It sounds like TOP allows more generic contracts because the programmer has a more powerful constraint syntax than what interfaces define. Interface inclusion is very strict and mainly based off of inclusion(if you include a method in an interface then every implementation also has to include that method). TOP, OTH, allows more loosely based constraints that are up to the programmer(the static if part of a template).

Is this the basic idea?

Use templates when you want more power? That is, TOP can do everything OOP can do but more? Or are these ultimately two orthogonal concepts?





Reply via email to