By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,302 Members | 3,621 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,302 IT Pros & Developers. It's quick & easy.

switching the usual order of things

P: n/a
Ever since I've been using objects with VB I've instantiated the
business object from the form; the business object then
creates/destroys data access layer objects as needed. The business
object also maintains state for the form variables. The form unload /
closing event destroys the business object.

For a small set of specialized forms in .NET, I want to try switching
the usual order of things. The business class will optionally
instantiate the form (modal), passing a reference of itself in the
form constructor as in:

from any code in the application...

Private cMy As MyClass
cMy = New MyClass(True)
or
Private cMy As MyClass = New MyClass(True)

If IsNothing(cMy) = False Then cMy = Nothing

------------------------------------------

If the parameter in the class constructor is True, the form will show
as in:

MyClass

Private cF As MyForm

Friend Sub New(ByVal bDisplayForm as Boolean)

If bDisplayForm Then DisplayForm

End Sub

Private Sub DisplayForm
cF = New MyForm(Me) ' pass reference to class
cF.ShowDialog()
End Sub

...various properties that tie to variables on the form

------------------------------------------

MyForm

Private cMy2 As MyClass

Friend Sub New(By Ref c As MyClass)
cMy2 = c
End Sub

' cMy2 and cMy should now point to the same object
' business class properties/methods are now visible at form
' level
QUESTION:

Both business and form objects will be in the same runtime location.
The class will destroy the form. Does anyone see any potential
problems with this methodology?

Thanks.

****** AllenL ************************************************** ******

In a nation ruled by swine, all pigs are upward-mobile...
Hunter S. Thompson (b. 1939), U.S. journalist.
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Allen,

The code will not cause serious problem. But it will make the code lack of
maintainability and readability.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
From: AllenL <c2***@bellsouth.net>
Newsgroups: microsoft.public.dotnet.languages.vb
Subject: switching the usual order of things
Reply-To: c2***@bellsouth.net (AllenL)
Message-ID: <n3********************************@4ax.com>
X-Newsreader: Forte Agent 1.91/32.564
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 69
Date: Sun, 31 Aug 2003 13:04:22 -0400
NNTP-Posting-Host: 66.20.186.28
X-Trace: bignews4.bellsouth.net 1062349440 66.20.186.28 (Sun, 31 Aug 2003 13:04:00 EDT)NNTP-Posting-Date: Sun, 31 Aug 2003 13:04:00 EDT
Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!news-out.cwix.com!newsfeed.cwix.co
m!newsengine.sol.net!news-out.visi.com!petbe.visi.com!newsfeeds-atl2!news.we
busenet.com!elnk-atl-nf1!newsfeed.earthlink.net!bigfeed2.bellsouth.net! bigfe
ed.bellsouth.net!bignumb.bellsouth.net!news.bellso uth.net!bignews4.bellsouth
.net.POSTED!not-for-mailXref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.vb:132922
X-Tomcat-NG: microsoft.public.dotnet.languages.vb

Ever since I've been using objects with VB I've instantiated the
business object from the form; the business object then
creates/destroys data access layer objects as needed. The business
object also maintains state for the form variables. The form unload /
closing event destroys the business object.

For a small set of specialized forms in .NET, I want to try switching
the usual order of things. The business class will optionally
instantiate the form (modal), passing a reference of itself in the
form constructor as in:

from any code in the application...

Private cMy As MyClass
cMy = New MyClass(True)
or
Private cMy As MyClass = New MyClass(True)

If IsNothing(cMy) = False Then cMy = Nothing

------------------------------------------

If the parameter in the class constructor is True, the form will show
as in:

MyClass

Private cF As MyForm

Friend Sub New(ByVal bDisplayForm as Boolean)

If bDisplayForm Then DisplayForm

End Sub

Private Sub DisplayForm
cF = New MyForm(Me) ' pass reference to class
cF.ShowDialog()
End Sub

...various properties that tie to variables on the form

------------------------------------------

MyForm

Private cMy2 As MyClass

Friend Sub New(By Ref c As MyClass)
cMy2 = c
End Sub

' cMy2 and cMy should now point to the same object
' business class properties/methods are now visible at form
' level
QUESTION:

Both business and form objects will be in the same runtime location.
The class will destroy the form. Does anyone see any potential
problems with this methodology?

Thanks.

****** AllenL ************************************************** ******

In a nation ruled by swine, all pigs are upward-mobile...
Hunter S. Thompson (b. 1939), U.S. journalist.


Nov 20 '05 #2

P: n/a
On Mon, 01 Sep 2003 07:18:28 GMT, v-******@online.microsoft.com (Peter
Huang [MSFT]) wrote:
Hi Allen,

The code will not cause serious problem. But it will make the code lack of
maintainability and readability.

Regards,
Peter Huang
Microsoft Online Partner Support


<snip>

Thanks for the reply.

One of these objects will be used as the sole source of crypto
functionality in the application (though possibly excluding encrypted
streams). As far as readability is concerned, the more obscure the
better.

The object will serve a dual purpose: handling encryption/decryption
for sensitive database columns (credit card numbers, social security
numbers, etc.) and, when the optional form is called, validating and
authenticating passwords and managing password changes.

This business layer will still consume data layer objects as required.
Its just that rather than the password form owning the business layer
object, the business layer object will own the form.

I've previously written a .NET crypto component consumed by a password
form -- where crypto is involved I would rather like to have all the
source in one component.

Regards,

Allen

****** AllenL ************************************************** ******

In a nation ruled by swine, all pigs are upward-mobile...
Hunter S. Thompson (b. 1939), U.S. journalist.
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.