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

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 1198
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*****@optonline.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 myConnectionType 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_Remarks 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_Remarks 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.OleDb

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 (myProjectStatus)
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.Exclamation, "Project Add Failed")
Return False
Else
mySqlString = "INSERT INTO Projects(Company_ID,Status)
VALUES ('" & myCustomerID & "','Closed')"
myDatabase.Modify(mySqlString)
myDatabase.Dispose()
Return True
End If
End Function

Public Function deleteProject(ByVal 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.Exclamation, "Project Deletion Failed")
Return False
Else
mySqlString = "DELETE FROM Projects WHERE Project_ID = " &
argProjectID
myDatabase.Modify(mySqlString)
myDatabase.Dispose()
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*****@optonline.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*****@optonline.net> schreef in bericht
news:uj**************@TK2MSFTNGP12.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
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
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...
0
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...
1
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...
105
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...
2
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...
3
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
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...
1
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...
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...
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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...

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.