Skip to content

Latest commit

 

History

History
27 lines (17 loc) · 773 Bytes

File metadata and controls

27 lines (17 loc) · 773 Bytes

ECM3440-Python-classes

Examples and exercises in designing, building, and testing classes.

Operator overloading

The built-in numeric types in Python can be combined in the usual ways using operators such as + and -. This facility can be added to your own classes through what is called operator overloading. This can be applied to any type you create, not just those that represent numbers, but do take care not to confuse your users.

Reminder. Python strings make use of operator overloading.

print ("Hello " + "world")
print ("_" * 11)
Hello world
___________

Operator overloading exercise

Domain-Driven Design

In DDD we identify entities, values, and services.

DDD services exercise