Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Global App Object
Message
From
21/12/2015 15:11:17
 
 
To
21/12/2015 15:07:07
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows 10
Network:
Windows 2008 Server
Database:
Visual FoxPro
Application:
Web
Miscellaneous
Thread ID:
01629191
Message ID:
01629192
Views:
76
Seems to me it violates Single Responsibility Principle https://en.wikipedia.org/wiki/Single_responsibility_principle

>I'm wanting to get some ideas of properties, methods, features, etc. that would go into making a generic, reusable Application Object. One that would be a good basic App Object that could be used universally in creating common business apps in FoxPro. Ideally, this global App object would have basic properties, and methods that we'd all likely find useful if we were using it in one of our apps.
>
>I assume almost everyone has such an object in their apps, or at least a bunch of hodge-podge functions that simulate such a thing.
>
>So, please share you comments and ideas with me...
>
>For instance, here is what I've started out with as I began to abstract my specific goApp class to a generic one:
>
>
>Define Class AppObjectBase As Custom
>
>	lExe = .f.
>	lDevMode = .f.
>	cAppName = ""
>	cCurrentModule = ""
>	cActiveForm = ""
>	cCurrentVersion = ""
>	cTempFilesPath = "C:\Temp\"
>	
>	oConfig = .null.
>	oUser   = .null.
>	oSql = .null.
>	oTracker = .null.
>	oBO = .null.
>
>	*---------------------------------------------------------------------------------------
>	Procedure Init
>
>		*-- In your override of this method, you'd wire up all the objects and properties
>		*-- that are hosted in this class. 
>		
>		*-- Example setup work displayed below. Every app is different, so do whatever you need to 
>		*-- get this global goApp ready for use by your application
>		*---------------------------------------------------------------------------------------
>		
>		* This.oConfig = NewObject("LmConfig", "LmConfig.prg")
>		* This.oValues = NewObject("Values", "Values.prg")
>		
>		* lcRunningFilename = JustFname(_vfp.ServerName)
>		* This.cCurrentVersion = lcRunningFilename
>		
>		* If This.lDevMode and This.lUseTestData
>		*	This.oConfig.Connstring = Strtran(This.oConfig.Connstring, "LMDB", "LMDB_TEST",1,99,1)
>		* Endif
>		
>	EndProc
>	
>	*---------------------------------------------------------------------------------------
>	Procedure LogError(tcErrorMessage)
>	
>		*-- Again, in your override, handle any calls to LogError() however you neede to.
>		*-- If you assign This.oBO in the Init() method, then you can use the wwBusinessPro.LogError() method
>		*-- as shown below. If not, then override and do whatever magic you need or want to do to handle these calls.
>		
>		This.oBO.LogError(tcErrorMessage)
>	
>	Endproc
>
>	*---------------------------------------------------------------------------------------
>	Procedure lExe_Access
>		
>		Local lcApp, llExe
>
>		lcApp = Sys(16,1)
>		llExe = '.EXE' $ Upper(lcApp)
>		
>		Return llExe
>	
>	Endproc
>	
>	*---------------------------------------------------------------------------------------
>	Procedure lDevMode_Access
>	
>		Return !This.lExe		
>	
>	Endproc
>
>
>	*---------------------------------------------------------------------------------------
>	*- This handy method gives you a simple and common way to setup Classlibs and Procedure files
>	*-- into your app setup calls.
>	Procedure Require(tcAsset)
>	
>		DO CASE
>			CASE ".vcx" $ Lower(tcAsset)	
>				Set Classlib To (tcAsset) Additive
>				
>			Case ".fll" $ Lower(tcAsset)
>				Set Library To (tcAsset) Additive
>			*-- Assumes .prg or no extension
>			Otherwise 
>				Set Procedure To (tcAsset) Additive
>		ENDCASE
>
>	EndProc
>		
>	
>EndDefine
>
>
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform