Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Class Design Question
Message
General information
Forum:
Visual FoxPro
Category:
Object Oriented Programming
Title:
Class Design Question
Miscellaneous
Thread ID:
01160735
Message ID:
01160735
Views:
50
I am creating a PRG-based class library which will be compiled into a DLL.

I have created a base class from which all other classes in the library will
be based.

The issue is that there are some properties and methods created in the
base that I don't want exposed outside any of the classes in the library.

The solution seems to be to redefine the classes at the child class level
as protected and then call back into the parent using DODEFAULT() or the
the scope resolution operator.

Is there another way to do this? My sample is below
DEFINE CLASS ClassBase as Session

	DIMENSION aErrorInfo[1]		&& Array of error info
	bErrorOccurred = .F.		&& Set to True when an error occurs

	** This method will be protected in subclasses
	PROCEDURE _HandleError()
		
		WITH This
		
			** Save the error info to the error array property
			=AERROR(.aErrorInfo)

			** Turn on the error flag
			.bErrorOccurred = .T.

		ENDWITH
		
	ENDPROC


	** This method will be protected in subclasses
	PROCEDURE _ResetErrState()
	
		WITH This

			** Reset the error array
			DIMENSION .aErrorInfo[1]
			.aErrorInfo = ""

			** Turn off the error flag
			.bErrorOccurred = .F.
		
		ENDWITH
	
	ENDPROC



ENDDEFINE


*** Base class. All PEM's will be hidden in child classes
DEFINE CLASS Child AS ClassBase

	** Use the scope resolution operator to call base class
	** methods that were protected in this class

	PROTECTED PROCEDURE _HandleError()
**		ClassBase::_HandleError()
		DODEFAULT()
	ENDPROC

	PROTECTED PROCEDURE _ResetErrState()
		ClassBase::_ResetErrState()
	ENDPROC

	PROCEDURE MyProc() AS Boolean
		This._ResetErrState()
		This._HandleError()
	ENDPROC

ENDDEFINE
Everything makes sense in someone's mind
public class SystemCrasher :ICrashable
In addition, an integer field is not for irrational people
Next
Reply
Map
View

Click here to load this message in the networking platform