Conclusion

Heads up... You're reading this book for free, with parts of this chapter shown beyond this point as scrambled text.

In the last demo you learned about static properties and how you can share different properties across your app by making the property directly accessible by everyone.

Here are the things you learned in this lesson:

  • You introduced the ability to mark a contact as a company contact. That made the usage of your type a little inconvenient so you updated your code by creating two new types, one for person and one for company and you made both of them inherited from the main type ContactCard. That made your code cleaner and you were able to implement the relationship validations in an organized way

  • You used method overloading to create setters for the different properties with multiple functions that have the same name but different property numbers or same number but different type.

  • And at the end you used static keyword to be able to create an instance of the ContactsBook to be a single source of truth for all the different parts of your app.

In the next lesson, you’ll continue building on the ContactsBook and solve another issue where anyone can still create their own instances of the book and ignore the instance that you meant to share.

See forum comments
Download course materials from Github
Previous: Demo 3 Next: Quiz: Polishing OOP Concepts