473,327 Members | 2,055 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

switching the usual order of things

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
2 1488
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
4
by: Baz'noid | last post by:
Hi all, As the size of my database and the number of users grows, i've found a horrible bug in the system with a very simple solution (but i don't know how to implement it)... If two people...
32
by: Kamilche | last post by:
I'm looking at other languages. Some of them fool me into thinking they're useful, and I change my home page to them... 'comp.lang.c++' for instance. But I always end up switching it back to...
6
by: Nicky | last post by:
hi,all We are going to develop a program and when it is running, we need it full screen and also, user can not switch to other place before exit our program. I am thinking, we can make a window...
5
by: JRB | last post by:
Hi, I'm creating a small C#program that communicates through the serial port. I have a separate thread that continuously takes in data from an external device in a while loop. The problem is that...
7
by: Kenny M. | last post by:
Hi I want to write de content of a variable from my asp net code into the Title Bar of the Browser each time I need to switch between those world (HTML-ASPNET) I suffer cause I don’t have...
1
by: KeyboardSurfer | last post by:
I am still having problems with switching thru tasks in such a way that it will work properly for me ... here is the basic information and a code snippet follows below .. My program is running...
1
by: garry.oxnard | last post by:
Can anyone help me to solve a problem which involves switching from Access to Excel (then back to Access) programatically please? I have an Excel template which, on open, also opens an Access...
15
by: greg.landrum | last post by:
After using numeric for almost ten years, I decided to attempt to switch a large codebase (python and C++) to using numpy. Here's are some comments about how that went. - The code to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.