473,657 Members | 2,456 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1502
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***@bellsout h.net>
Newsgroups: microsoft.publi c.dotnet.langua ges.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.bellso uth.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.ph x.gbl!TK2MSFTNG P08.phx.gbl!new s-out.cwix.com!ne wsfeed.cwix.co
m!newsengine.so l.net!news-out.visi.com!pe tbe.visi.com!ne wsfeeds-atl2!news.we
busenet.com!eln k-atl-nf1!newsfeed.ea rthlink.net!big feed2.bellsouth .net!bigfe
ed.bellsouth.ne t!bignumb.bells outh.net!news.b ellsouth.net!bi gnews4.bellsout h
.net.POSTED!not-for-mailXref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.vb:132922
X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.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.m icrosoft.com (Peter
Huang [MSFT]) wrote:
Hi Allen,

The code will not cause serious problem. But it will make the code lack of
maintainabilit y 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
3652
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. And i have things to offer, and to request. And a lot of ideas, but who needs them.... here's an example (from type_struct.py):
4
1883
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 are accessing the database simultaneously (literally at the same time), things slow down a little. No problem. The problem becomes if one user switches from one form to another from a customer's record (in this case, having the details open as...
32
2571
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 comp.lang.c. :-D When I redid my code into C++ recently, I saw some amazing bogosities. Such as member functions being called before the constructors ran, and member functions being called for NULL objects. Enough to make me switch back to C, where...
6
7563
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 full screen, but how to avoid user switching to other program or windows? And also, there are many hot keys, how to capture or disable these things? Thanks
5
2035
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 when I try and run another program, open a menu, or anything, I miss getting bytes. If I set the threads priority to above normal it works fine, but the rest of the program slows down dramatically. Is there any command or way to ensure that a block...
7
1345
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 clear the boundaries in between What alternatives do I have? Where Can I find a good documentation about using or switching between HTML
1
1575
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 and I need to switch to another (directx based) program already running as a task. The code I have so far works when only my program and the ProgramToSwitchTo are running , if I have something else running like notepad it first A) goes into...
1
5728
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 database - containing a list of addresses. Sequence of events is = (1) Excel template opens in its default XXX.xls filename. (2) Code runs to save the spreadsheet as XXX.xls. (3) User clicks a button to open an Access database containing an
15
2517
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 automatically switch python stuff over just kind of works. But it was a 90% solution, I could do the rest by hand. Of course, the problem is that then the code is still using the old numeric API, so it's not a long term solution. Unfortunately, to switch to...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8823
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8603
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7320
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6163
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4151
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1944
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.