Avoiding obligatory SUPER constructor call

Public support forum for peer to peer support with related to the Visual Objects and Vulcan.NET products
Post Reply
Serggio
Posts: 46
Joined: Sun May 14, 2017 5:03 pm
Location: Ukraine

Avoiding obligatory SUPER constructor call

Post by Serggio »

Is there any way to avoid calling SUPER constructor in a constructor of an inherited class?
There are situations when SUPER constructor is of totally different nature and simply may not be called and should be completely overriden.
I know, that's not very OOP-ish and one should use interface or something like that to untie that properly.
But. The question I'm asking is not just the point of mere interest but a, so to say, decision input, because refactoring price and changing OOP-model seem to be quite costly.
User avatar
Chris
Posts: 4936
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

Avoiding obligatory SUPER constructor call

Post by Chris »

Hi Serggio,

Just use something like that in your child's class constructor:

Code: Select all

CONSTRUCTOR()
	IF FALSE
		SUPER()
	END IF
	// .normal code
RETURN

the compiler will detect you are handling SUPER() yourself and will not add implicitly code to call it. But please just don't show the above X# trick to any c# guy, because they will sue us for breaking every OOP law available :)
Chris Pyrgas

XSharp Development Team
chris(at)xsharp.eu
Serggio
Posts: 46
Joined: Sun May 14, 2017 5:03 pm
Location: Ukraine

Avoiding obligatory SUPER constructor call

Post by Serggio »

Thank you very much, Chris! That should save me a lot of time.
Post Reply