This has been bothering me for a long time, and I'm curious about everyone's
opinion or a "Microsoft Best Practices" method of doing this. I have a
"Member" business object which contains information about an individual
member. For instance, it contains the following properties:
member.name = "SteveS"
member.LoginNam e = "SteveS"
member.Phone = '555-555-1234'
member.Office = ...object of office information such as (office.address 1,
office.name, office.mailtype , etc...)
member.Committe es = ....contains a collection of the Committee objects
(Committee.Name , Committee.Type, Committee.Meeti ngPlace, etc...)
So, every time I instantiate the member object, I populate the .Office and
..Committes objects. Basically, in this example, the database would take 3
hits - one to read the member record, one to read the office record, and
one to read the committee records.
THE PROBLEM: This works fine, except there are 2 extra database hits when
I only need the LoginName property. ***I hate to call the database again if
I don't have to****
THE SOLUTION: ???? What do you think is the best answer???? Once answer
is to read all the data in a sql statement, then use that to populate each
object. That doesn't seem to be the cleanest way to me. (but I could be
wrong). Here's what I did:
Public Class Member
private _name as string
private _MemberNumber as Long
private _LoginName as string
private _Phone as string
private_Office as Business.Office
private _Committees as Business.Commit teCollection()
Public Property Name as String
....
End Property
Public Property LoginName as String
....
End Property
Public ReadOnly Property as Business.Office
Get
If IsNothing(_offi ce) then '<======= populate the office object
if not already
_Office = New Office(_OfficeN umber)
End If
End Get
End Property
Public ReadOnly Committees Property as Business as
Business.Commit teeCollection()
Get
If IsNothing(_Comm ittees) Then '<=======popula te the
CommitteCollect ion if not already
...code to populate the CommitteCollect ion.....
End If
return _Committees
End Get
End Property
.....
.....
End Class
Thanks for taking the time to think about this :-)
SteveS 1 1362
I've used this approach in the past as well - i.e. load collections as they
are requested.
One variation I have also used on this approach is to include some type of
optional "level" parameter in the constructor. So, if I know I plan on
using various collections, I can pass in a level of, say "1", when I
instantiate the object and it will know to go ahead and load some of the
collections (rather than wait until I access them) since I know they will be
accessed.
--
Thanks, Jeff This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: SteveS |
last post by:
I'm not sure if this is the right forum, but here it goes :-)
This has been bothering me for a long time, and I'm curious about everyone's
opinion or a "Microsoft Best Practices" method of doing this. I have a
"Member" business object which contains information about an individual
member. For instance, it contains the following properties:
member.name = "SteveS"
member.LoginName = "SteveS"
member.Phone = '555-555-1234'
|
by: SteveS |
last post by:
This has been bothering me for a long time, and I'm curious about everyone's
opinion or a "Microsoft Best Practices" method of doing this. I have a
"Member" business object which contains information about an individual
member. For instance, it contains the following properties:
member.name = "SteveS"
member.LoginName = "SteveS"
member.Phone = '555-555-1234'
member.Office = ...object of office information such as (office.address1,...
|
by: josh.kuo |
last post by:
Sorry about the subject, I can't think of a better one.
I recently wrote some PHP classes that I think might be of interest to
this group. Since I have been reaping the benefits of reading news
groups for years, I figure it's time for me to contribute a little bit
back, maybe some people out there will find this useful.
* Introduction
This is a "how-to" style article, showing by example how to dynamically
|
by: Nemisis |
last post by:
hi guys,
Currently converting an old classic asp system to a OOP asp.net
application. We are building the new application using a 3 tier
arcitecture and i was wondering about the following.
I have a parent class, that when inserted, inserts a few child classes
into the database, based on other classes. In the old system, this is
wrote as one big SQL script, with many inserts and updates because the
system was not wrote as OOP.
|
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...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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...
|
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...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |