473,785 Members | 2,297 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

General OOP Technique Question

I am designing a class to represent an item in a database (containing
model's of products). I need to display a listing of all of these items
in a listview to be displayed to the user (so they can select, edit, or
delete the item). To follow the right way cause I am new and learning
OOP should I create a function within the class to return all items or
in a module or in the calling form itself? I figured it shouldnt go in
the class itself because the object should represent one item not the
whole collection so I was a bit confused.

Any help is appreciated.

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
6 1214
Ivan... Seriously you have to get a book on all this. You'll save yourself
countless hours of wondering if you read about how people have solved these
exact problems for close to 20 years. This BTW, doesn't mean you have to
pick up the nearest VB.Net book. I recommend to anybody to read about
"object-orientation" as a concept and not as a bunch of syntax that has to
be memorized.

So to answer your question. You have a Product class (let's say) which you
can use to produce a product object. What you need now is a Products class
from which you can produce a collection of Product objects.

If you want, post the code from your Product class.

And a book will help... alternatively it's going to be a constant uphill
battle.
Tom

"Ivan Weiss" <iv*****@optonl ine.net> wrote...
I am designing a class to represent an item in a database (containing
model's of products). I need to display a listing of all of these items
in a listview to be displayed to the user (so they can select, edit, or
delete the item). To follow the right way cause I am new and learning
OOP should I create a function within the class to return all items or
in a module or in the calling form itself? I figured it shouldnt go in
the class itself because the object should represent one item not the
whole collection so I was a bit confused.

Nov 20 '05 #2
I do have a VB.NET book that kind of covers it all but I to be honest
have just been using it as a reference as it does not contain concepts
for object oriented design. You are right I do need to read up on it
but to be honest this app is being written on my spare time on my own
and I work a full time job and also am going to school so needless to
say I really dont have too much time to be reading any other books than
the textbooks from class. I do appreciate your help.

My items class right now is just a class listing all of the data
members:

Public Class Items

#Region " Data Members "

Private myID As Integer
Private myModel As String
Private myManufacturer As String
Private myDescription As String
Private mySpecification As String
Private myElectric_Info As Integer
Private myConnectionTyp e As String
Private myVolts As String
Private myPhase As String
Private myAmps As String
Private myKWs As String
Private myHP As String
Private myElectric_AFF As String
Private myElectric_Rema rks As String
Private myPlumbing_Info As Integer
Private mySteam As String
Private mySteam_AFF As String
Private myGas As String
Private myGas_AFF As String
Private myBTUs As String
Private myHW As String
Private myHW_AFF As String
Private myCW As String
Private myCW_AFF As String
Private myDrain As String
Private myDrain_AFF As String
Private myIDrain As String
Private myIDrain_AFF As String
Private myPlumbing_Rema rks As String

#End Region

End Class

However, I did start coding another class which I need to revise and
correct some OOP mistakes but here it is if you want to look it over:

Imports System.Data
Imports System.Data.Ole Db

Public Class Project

Private myProjectID As Integer
Private myCustomerID As Integer
Private myProjectStatus As String

Public Sub New(ByVal argCustomerID As Integer)
myCustomerID = argCustomerID
End Sub

Public ReadOnly Property ProjectID() As Integer
Get
Return (myProjectID)
End Get
End Property

Property CustomerID() As Integer
Get
Return (myCustomerID)
End Get
Set(ByVal Value As Integer)
myCustomerID = Value
End Set
End Property

Public ReadOnly Property ProjectStatus() As String
Get
Return (myProjectStatu s)
End Get
End Property

Public Function addProject() As Boolean
Dim myDatabase As New Database
Dim mySqlString As String

If myCustomerID = Nothing Then
MsgBox("You must select a customer first. Adding a project
failed!", MsgBoxStyle.Exc lamation, "Project Add Failed")
Return False
Else
mySqlString = "INSERT INTO Projects(Compan y_ID,Status)
VALUES ('" & myCustomerID & "','Closed' )"
myDatabase.Modi fy(mySqlString)
myDatabase.Disp ose()
Return True
End If
End Function

Public Function deleteProject(B yVal argProjectID As Integer) As
Boolean
Dim myDatabase As New Database
Dim mySqlString As String

If argProjectID = Nothing Then
MsgBox("You must select a project first. Deleting a project
failed!", MsgBoxStyle.Exc lamation, "Project Deletion Failed")
Return False
Else
mySqlString = "DELETE FROM Projects WHERE Project_ID = " &
argProjectID
myDatabase.Modi fy(mySqlString)
myDatabase.Disp ose()
Return True
End If
End Function

End Class

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Can you recommend any good easy to read OOP books? I find that most
reference/instructional books are easy to understand what the author is
saying but use in my own projects since I am basically a
novice/intermediate programmer.

Thanks,

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #4
I'll try to respond to both messages here... first as for a book... anything
that isn't language specific. Find an old SmallTalk book, perhaps "Inside
SmallTalk" by Wilf R. LaLonde. Or "Object-Oriented Analysis" by Coad and
Yourdon or "Object Oriented Design With Applications" by Grady Booch or
"Essays on Object-Oriented Software Engineering" by Edward Berard. They are
all probably out of print. So find essays or other books written by these
authors. Most of the books I've mentioned are from around 1990.

My point is (always) that this stuff wasn't invented with VB.Net so don't
limit yourself to this one implementation' s view of OOP.

"Ivan Weiss" <iv*****@optonl ine.net> wrote...
but to be honest this app is being written on my spare time on my own
and I work a full time job and also am going to school so needless to
say I really dont have too much time to be reading any other books than
the textbooks from class.
As the old joke goes... if you don't have the time to do it right how do you
find the time to do it all over again?
My items class right now is just a class listing all of the data
members:

Public Class Items

#Region " Data Members "

Private myID As Integer
Private myModel As String
Private myManufacturer As String .... electrical, steam, plumbing and gas properties snipped
#End Region

End Class
Recall we spoke about the "my" naming convention before? This is what I
mean... you could add a few names and addresses, the current date and time,
MyFavoriteMovie and a spot for FreeDiskSpace and you wouldn't need another
class defined again. :-)

A book would not only avoid suggesting you approach the solution this way it
would devote a chapter specifically to why you shouldn't. It's an
"everything and the kitchen sink" class... where would you build up from
here?
However, I did start coding another class which I need to revise and
correct some OOP mistakes but here it is if you want to look it over:


It's going to be tough... again you have to read something. In this case
you might want to find short examples in VB.Net. You won't find a single
one which pops a modal message box up in the middle of class method. At
least I'm betting you won't.

I think you know I'm not trying to cause you grief, I'm honestly trying to
save you hours of frustration. I can see it in your examples that 40
precious hours from now you will simply have to start over. In the long run
you are better off stopping now, reading a bunch more and if you'd like to
take my advice, writing a non-database application to start. Get the
concepts down without having to worry yourself about database access on top
of everything else. For now I leave you with the opening paragraphs of a
book I wrote on software application development...

<begin quote>
There is a big difference between computer programming and computer
application development. Programming consists primarily of controlling the
computer through computer language constructs. Programming is the process of
combining algorithms and data structures to perform a given task. This
relationship is, in fact, the title of a classic book by Niklaus Wirth
called Algorithms + Data Structures = Programs (Prentice-Hall, 1976).

As a result of college courses or through diligent self*study, you can
eventually learn what a variable is, how to write a FOR... NEXT loop, and
when to use stacks, queues and linked-lists. After some practice in BASIC,
Pascal, C, dBASE, FoxPro or Clipper, Ada, Lisp, Forth or any of a dozen
other computer languages, you will have harnessed the fundamentals and can
honestly claim that you program in that language.

However, designing and more importantly completing sophisticated
applications involves additional skills that are almost never taught in
school. Some programmers discover the secrets of developing computer
applications over time, but developing applications remains for many an
elusive challenge, a contest or even a battle between the programmer and the
language, with the computer in the role of referee.

Application development is computer programming and then some. This point
helps explain why I'm asked the following question more often than any
other: "Where do I begin?"
<end quote>

Nov 20 '05 #5
Cor
Hi Ivan,

Only one addition to Tom while I hope I am not killing all the good work Tom
has done for you.

OOP is not a goal, good performce, friendly for the client, reusability,
readability, cooperate working should be some of the goals.

One of the routes to reach that is today is using OOP.

I tell this because I have seen that for some people OOP goes for the result
and then all those things I told are sometimes worse than without OOP.

But for the rest, follow the avices from Tom,

Cor


"Ivan Weiss" <iv*****@optonl ine.net> schreef in bericht
news:uj******** ******@TK2MSFTN GP12.phx.gbl...
I am designing a class to represent an item in a database (containing
model's of products). I need to display a listing of all of these items
in a listview to be displayed to the user (so they can select, edit, or
delete the item). To follow the right way cause I am new and learning
OOP should I create a function within the class to return all items or
in a module or in the calling form itself? I figured it shouldnt go in
the class itself because the object should represent one item not the
whole collection so I was a bit confused.

Any help is appreciated.

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #6
You make a good point and are actually very right about the re-coding.
I have already several times re-written pieces of code completely to
follow closer to OOP techniques. I will look into a book and start from
there.

-Ivan

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #7

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

Similar topics

10
1427
by: Harlin Seritt | last post by:
Is there really a major performance difference between doing the following: import Tkinter as TK TK.Label(yada yada) OR from Tkinter import *
37
2879
by: middletree | last post by:
Yesterday, I posted a problem which, by the way, I haven't been able to solve yet. But in Aaron's reply, he questioned why I did several things the way I did. My short answer is that I have a lot to learn, but now I'd like to ask anyone who reads this, including Aaron, for some clarification. I imagine others might benefit, too. "Aaron Bertrand - MVP" <aaron@TRASHaspfaq.com> wrote > A few suggestions. > (3) why do you constantly set...
0
1412
by: deathyam | last post by:
Hi, I am writing an application in Excel 97 in which the users click a button and data is saved/read to and from an Access 97 database on the LAN. I am concerned about performance because there will be multiple users using it at the same time. Generally my technique for database reads is as follows: -I create parameter queries in the database. Doing so allows me to use a sort of 'function' paradigm. i.e. given x and y, query fn...
1
938
by: Vlad | last post by:
Hi all. I use ViewState on most of my pages. Sometimes heavily. Works great, I love it. But most of the asp.net sites I visit seem to ignore it. They don't even include form tag in html and use other ways to navigate/collect information. Or use form and regular buttons withour runat attribute to post info back to server. But they need and they do save the state of their pages and page elements. Is there any strong reason why they...
105
5355
by: Christoph Zwerschke | last post by:
Sometimes I find myself stumbling over Python issues which have to do with what I perceive as a lack of orthogonality. For instance, I just wanted to use the index() method on a tuple which does not work. It only works on lists and strings, for no obvious reason. Why not on all sequence types? Or, another example, the index() method has start and end parameters for lists and strings. The count() method also has start and end parameters...
2
1473
by: Niklas Norrthon | last post by:
I want to share a technique I recently have found to be useful to get around some obstacles that data protection can raise. Consider the following class: // foo.h #ifndef H_FOO #define H_FOO class Foo
3
4891
by: pragy | last post by:
Hey, can any one help me for writing a program of naive gauss elimintaion technique? It's a technique to solve system of simultaneous linear equations using matrix. thanks
2
1495
by: rhino | last post by:
I'm having a problem with the CSS on the website I am developing. A div that works perfectly fine in IE7, FF, and Opera doesn't appear at all in IE6. Now, I realize that I could simply post a link to the site and someone here will likely look at it for about 30 seconds and tell me what's wrong. However, I'd like to be as self-sufficient as I can be so I would _really_ appreciate some guidance on the best way to find this problem for...
1
368
by: Ben Bacarisse | last post by:
cri@tiac.net (Richard Harter) writes: <snip> I too was going to mention the technique until I saw Eric's reply because in your sketch you said: | we have definitions like | | struct bobble_s {...};
0
9647
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
10162
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 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...
1
10100
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
8988
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...
0
6744
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();...
0
5396
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...
0
5528
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4061
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
3665
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.