Illustrate Construction vs. SetData()
Learn about initializing objects using two different ways.
We'll cover the following
Problem
Between the constructor
and setData( )
function, which should be preferred to initialize an object?
Coding solution
Here is a solution to the problem above.
DRY Principle: The initialization at multiple places should be avoided. The
constructor
can call thesetData()
function for initialization.
Get hands-on with 1400+ tech skills courses.