c# - Standard term for instantiation practice -
is there standard term practice of instantiate class without using explicit constructor instead initializing of properties?
new someclass { propertya = true, propertyb = "ugly code ugly" }; i'm guessing there standard not judgemental term , there negative term.
** --- ** --- edited post clarifying comments , answers --- *** ---
object initialization is.
after reading comments understand object initialization not bad practice; problem lack of defined constructors in favor of object initialization spread across solution, makes solution harder maintain , understand.
an example of bad use of object initialization:
- class
studenthas 10 properties includingcode,program. - the code instantiating class 10+ different points.
- every time,
code,programbeing defined through object initialization.
in case, class student should have constructor enforcing code , program passed on instantiation.
it called object initialization
Comments
Post a Comment