Both a class's and an object's lifetime spans from the time of its creation until its destruction. Watch this step-by-step programming tutorial to learn more about exploring object lifetime, as well as about the role of constructors and destructors, from the use of the New keyword to the calling up of a finalizer.
- View Offline
One place that is worth talking about language differences is in the idea of object lifetime.…How are objects created?…What happens when they're created? And what happens when with them?…We know the core idea is that once we define a class, we make an instance of it.…We make an object so we can use the object, and this is instantiation,…creating an instance.…To create an object, most object- oriented languages use the word new.…I'm going to show a few examples here.…Don't worry about syntax, just take a look at the different languages.…
So I have a Customer class, I want to make a Customer object.…In Java, I'd say Customer fred = new Customer.…It would be identical in C#, also using the word new.…In VB.NET, we'd have something fairly similar, again, using the word new, as does Ruby.…C++ looks very similar to Java, and C# except it's using the asterisk for a pointer symbol.…And Objective-C likes to be different, so it's using alloc and init instead of new.…Objective-C actually does have a new keyword, it's just more common to see this format.…
Let Simon Allardice introduce you to the terms—words like abstraction, inheritance, polymorphism, subclass—and guide you through defining your requirements and identifying use cases for your program. The course also covers creating conceptual models of your program with design patterns, class and sequence diagrams, and unified modeling language (UML) tools, and then shows how to convert the diagrams into code.
- Why use object-oriented design (OOD)?
- Pinpointing use cases, actors, and scenarios
- Identifying class responsibilities and relationships
- Creating class diagrams
- Using abstract classes
- Working with inheritance
- Creating advanced UML diagrams
- Understanding object-oriented design principles