473,414 Members | 1,618 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,414 software developers and data experts.

Proper OOP Use

I am using VB.net and have a question on how to handle one aspect of OOP
programming.

I have a class for Customers, Vendors, and Employees each of which
inherits a master class, Contacts

Now on my customer center screen I want to fill a list box with all of
my customers in my database on the left and on the right have their
individual account information shown when the user selects a customer.

What is the proper way to fill the database? in VB6 days I would just
directly access the database and create a list of customers and
everytime one was selected directly call their information for the right
from the database.

With OOP should there be a class that has all of the customers in them?
Should it be a collection? Not quite sure which direction to take this
in...

Of course when I select a user I will fill my appropriate Customer class
with the customer the user selected and populate the appropriate fields
that way...

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Jan 3 '07 #1
6 1774

>
With OOP should there be a class that has all of the customers in them?
Should it be a collection? Not quite sure which direction to take this
in...
Both will work. I'd prefer to have a collection of customers. But if
you will be frequently working with large lists of customers it might
actually make more sense to have a CustomerList class that inherits
from list and might add one or two other properties/procedures specific
to working with large lists of customers.

Jan 3 '07 #2
Well if I went the collection list, would you make a collection of all
of the customer objects or just pull their name or ID as a string?

If I made a collection of all customers it would use a lot more memory
for sure but at the same time a lot less database hits so it might help
performance....

I know collections are new and I have no idea how to use them... How
would I go about doing this?

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Jan 3 '07 #3
I have 3 projects in my solutions like this: one for Data Access,
one for Business Logic, and the UI.

The classes are in the BL layer. It calls the DAL and loads the
data into the class.

In this case, I would have a class for Customers, and I would
have another class called CustomerList. This would implement
BindingList(Of Customer) so I could bind it to a DataGridView
(or whatever) for display. I put all of the fields in it, and
use a method on the Customer class to populate the rows.

I use data binding to bind my classes to the fields on the
screen.

I can send you some sample code for the list stuff if you like;
I just posted it to the c# newsgroup, although the code is in VB.

Robin S.
----------------------------------
"Ivan Weiss" <iv********@elitefse.comwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I am using VB.net and have a question on how to handle one aspect of
OOP
programming.

I have a class for Customers, Vendors, and Employees each of which
inherits a master class, Contacts

Now on my customer center screen I want to fill a list box with all of
my customers in my database on the left and on the right have their
individual account information shown when the user selects a customer.

What is the proper way to fill the database? in VB6 days I would just
directly access the database and create a list of customers and
everytime one was selected directly call their information for the
right
from the database.

With OOP should there be a class that has all of the customers in
them?
Should it be a collection? Not quite sure which direction to take
this
in...

Of course when I select a user I will fill my appropriate Customer
class
with the customer the user selected and populate the appropriate
fields
that way...

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***

Jan 4 '07 #4
Ivan,

Often is thought that OOP is the same as OO. I am sorry for you it is not.

In my idea are you asking an OO questions, the way how to handle
databobjects.

VB.Net is passed that way and uses an Object Oriented Programming method
which is not only about data.

If you use the standard ADO.Net methods you can only use it in an OOP way.
That can by clumsy by using it still with every small objects (item) or
effective using a lot of binding. The latter is however not influencing your
OOP way. The OOP way is that you create as much as possible instancible and
destructable objects. (The latter done by the managed code). And try to
avoid things as Modules or as they are called in VB Shared Classes (In C#
static classes and singletons).

Cor

"Ivan Weiss" <iv********@elitefse.comschreef in bericht
news:%2****************@TK2MSFTNGP03.phx.gbl...
>I am using VB.net and have a question on how to handle one aspect of OOP
programming.

I have a class for Customers, Vendors, and Employees each of which
inherits a master class, Contacts

Now on my customer center screen I want to fill a list box with all of
my customers in my database on the left and on the right have their
individual account information shown when the user selects a customer.

What is the proper way to fill the database? in VB6 days I would just
directly access the database and create a list of customers and
everytime one was selected directly call their information for the right
from the database.

With OOP should there be a class that has all of the customers in them?
Should it be a collection? Not quite sure which direction to take this
in...

Of course when I select a user I will fill my appropriate Customer class
with the customer the user selected and populate the appropriate fields
that way...

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***

Jan 4 '07 #5
Robin, if you can send me some sample code that would be terrific. My
home email is iv*****@optonline.net

I see what you are saying and I know the proper way is to separate data
from business rules from ui but I have never done that so have no clue
how to so some sample code might help clear the way for me...

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Jan 4 '07 #6
I learned how to do this from Deborah Kurata's book, "Doing Objects
in VB2005". It's coming out in March. I sent you the code that I
posted in the other ng.

Good luck.
Robin S.
-------------------------------------
"Ivan Weiss" <iv********@elitefse.comwrote in message
news:%2****************@TK2MSFTNGP02.phx.gbl...
Robin, if you can send me some sample code that would be terrific. My
home email is iv*****@optonline.net

I see what you are saying and I know the proper way is to separate
data
from business rules from ui but I have never done that so have no clue
how to so some sample code might help clear the way for me...

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***

Jan 4 '07 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Bruce W...1 | last post by:
For include files I see both the file extensions .php and .inc used. Which one is proper? Does it matter? What's the diff? Thanks for your help.
0
by: T. Kaufmann | last post by:
Hi there, I have some lines of code in a Tkinter programm - I want to list every single file of a zip-archive in a Text widget: fp = os.popen("%s %s" % ('unzip -vl ', 'anyarchiv.zip', 'r')...
3
by: m.ramana | last post by:
Given a string it should convert it to a proper text. Example: if you passed a string 'Cat in the hat', I want 'Cat In The Hat' Curious about few things, Does sql have Instr OR Split(like VB)...
2
by: JTrigger | last post by:
I am rather new to the XML and XSD world and was wondering what the code would look like to write the following XSD items as classes in C# with all the proper XML attributes to make them...
2
by: Kevin | last post by:
I am currently importing data into Access 2002 from 3 Sybase ASA 7.0 databases over a network. At this time I am using a ODBC System DSN connection using the proper ASA 7 driver. I would like to...
1
by: RC | last post by:
I have an Access 2002 database with many tables and forms (but just to keep things simple, let's say the DB has one Table "Table1" and one Form "Form1"). I have managed to cobble together so much...
0
by: bj | last post by:
hello is there any chance to get proper char width for class derived from user control - im working over text editing control, so i need proper width of every character for currently selected...
0
by: yogarajan | last post by:
hi all i need proper alignment my treeview looks like <checkbox>Fruits(parent)-134 <checkbox>Mango(child)-45 <checkbox>Orange(child)-45 ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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,...
0
jinu1996
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...
0
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...
0
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...

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.