473,756 Members | 3,211 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

OO business class vs data class..

Hi guys!!! Thanks for all your input on previous OO posts. I know it will
be all the same people responding again and I really appreciate your insight
etc.. as you all appear to know what you are doing - each having your own
flare but that is what makes us individuals right?? Anyway, here is a quick
question... (or maybe not so quick)

In my business "Contract" class I have many properties.
When I set these "contract" properties in the GUI layer front end (i.e
populating the Contract business class) when the 'Save' button is clicked, I
want to pass the values to the "data" class for update/insert etc...

Do I create the same "properties " on the data class as I have on the
business class and populate the data class from the properties of the
business class? OR should I pass all the variables as a parameter list
from teh business class to the method I am invoking on the data class to do
the update/insert etc .. ?

I guess the biggest question is should data classes use the same
properties - as in the associated business class(s)? What is the best way to
get the data from teh business class to the data class?

I have been doing the following... (used only 2 properties for demonstration
sake)

The front end would set and call the update method on the business class
"clsContrac t" as follows

public sub btmSave_click (bunch of aprameters)
' Save the Contract data
dim oCB as new clsContract
' Set class properites
oCB.ContractNo = me.txtContractN o.text
oCB.CustID = me.txtCustID.te xt
' Call update method to update/insert the data
oCB.Update(oCB. ContractNo)
' clean up
oCB = nothing
end sub

public class clsContract
private sContractNo as string
private iCustID as integer
public property ContractNo as string
get
return sContractNo
end get
set (byval value as string)
sContractNo = value
end set

public property CustID as integer
get
return iCustID
end get
set (byval value as integer)
iCustID = value
end set

public sub new
mybase.new
...some code
end sub

Public sub Update(byval sContractNo as string)
' Call dataclass update method
dim oCD as new clsContract_Dat a
' Set data class property then update
oCD.CustID = me.CustID
oCD.update(sCon tractNo)
' Clean up
oCD = nothing
end sub

public class clsContract_Dat a
private sContractNo as string
private iCustID as integer
public property ContractNo as string
get
return sContractNo
end get
set (byval value as string)
sContractNo = value
end set

public property CustID as integer
get
return iCustID
end get
set (byval value as integer)
iCustID = value
end set

public sub new(sContractNo as string)
mybase.new
me.ContractNo = sContractNo
end sub

Public sub Update(sContrac tNo as string)
' Call stored procedure to do updatemethod
dim bRet as boolean = false
' Call stored procedure with appropriate parameters
bRet is RunSP("spname", me.ContractNo, me.CustID)
if not bret then
msgbox("Error")
endif
return bret
end sub


Thanks, Brad


Jul 13 '07 #1
5 1782

Do I create the same "properties " on the data class as I have on the
business class and populate the data class from the properties of the
business class? OR should I pass all the variables as a parameter list
from teh business class to the method I am invoking on the data class to
do the update/insert etc .. ?
Here is where OO comes into play.

You have busContact and it should have all of its data accessor properties.

At the UI, you have busContract.Sav e (note: I don't know why you're trying
to pass the ContractNo in the Save, as it should have been already populated
in the
busContract (the object).

Then at busContract.Sav e(), you would do this.

Dim daoc as new daoContract

daoc.Save(busCo ntract)

Then at the daoc.Save() will actually be this within daoContract

Public sub Save(byval obj as busContract)

Then you have reference to obj.ContractNo or the properties in the
busContract (the object) you have passed to the DAL object so that DAL
Object can save the data from the Business Object.

You have reference to obj.ContractNo and all other properties in the
busContract, because the (object) was passed.

I hope you understand this and you need to read some books and see the
examples or code execution if you run a sample project from a book that was
mentioned. :)

You should throw everything out the door that you have learned previously
and start fresh.

I have been programming professionally since 1980 and started on the MS
platform in 1996. Something's I kept over the years and a lot of things I
tossed and started fresh, a blank sheet OO or OOp(s).

Jul 13 '07 #2
"Brad Pears" <br***@truenort hloghomes.comwr ote in
news:OC******** ******@TK2MSFTN GP04.phx.gbl:
I actually have a db table with one record in it that contains the
next contract number to be used among other system default values. I
have a small class
specifically set up to go get default values, increment the next
number etc... So on a new contract, I use this class to get the next
contract number and then I set it on the bus object...
Here's a question - how do you ensure that you won't have any concurrency
issues.

Just make sure that the code you're using to update the contract record is
wrapped in some sort of transaction. Or ensure that the your call is using
the proper synchronization mechanism - i.e. Mutexes to ensure multiple
threads won't be incrementing the same value under laod.
Jul 14 '07 #3
Yes, in the stored procedure that updates this single system 'row' I have it
inside a transaction which either commits or does a rollback. I then check
for the return value in my application and
display an error message if unsuccessful (among other things). In this
particular application, the
chances of multiple salespeople asking for the next contract number at the
exact same time hence causing a potential consistency issue are quite slim
(not that many contracts are really created) - but none the less possible.

Thanks,
Brad

"Spam Catcher" <sp**********@r ogers.comwrote in message
news:Xn******** *************** ***********@127 .0.0.1...
"Brad Pears" <br***@truenort hloghomes.comwr ote in
news:OC******** ******@TK2MSFTN GP04.phx.gbl:
>I actually have a db table with one record in it that contains the
next contract number to be used among other system default values. I
have a small class
specifically set up to go get default values, increment the next
number etc... So on a new contract, I use this class to get the next
contract number and then I set it on the bus object...

Here's a question - how do you ensure that you won't have any concurrency
issues.

Just make sure that the code you're using to update the contract record is
wrapped in some sort of transaction. Or ensure that the your call is using
the proper synchronization mechanism - i.e. Mutexes to ensure multiple
threads won't be incrementing the same value under laod.


Jul 16 '07 #4

"Brad Pears" <br***@truenort hloghomes.comwr ote in message
news:eK******** ******@TK2MSFTN GP05.phx.gbl...
Yes, in the stored procedure that updates this single system 'row' I have
it
inside a transaction which either commits or does a rollback. I then check
for the return value in my application and
display an error message if unsuccessful (among other things). In this
particular application, the
chances of multiple salespeople asking for the next contract number at the
exact same time hence causing a potential consistency issue are quite slim
(not that many contracts are really created) - but none the less possible.
Oracle works the same way in auto increment number to be used on a record as
a primary key. It's not a table with a field, but it's along the same
principles, where the next sequential number is gotten and applied to a
table's primary key.

I thought it was strange at first because of how MS SQL Server does it
normally with it's auto generate number for a table's record key, but it
works.
Jul 16 '07 #5
Hi

Don't know whether you're still looking for an OO intro type book but
I have heard very good reviews of a book called "Doing Objects in
Visual Basic 2005" - by Deborah Kurata - might be worth a look for you

Cheers
Martin

Jul 21 '07 #6

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

Similar topics

16
3036
by: D Witherspoon | last post by:
I am developing a Windows Forms application in VB.NET that will use .NET remoting to access the data tier classes. A very simple way I have come up with is by creating typed (.xsd) datasets. For example dsParts.xsd and including that in the data tier. I then will create a class that looks like this Public Class CPart Inherits dsParts
5
3139
by: Shibu | last post by:
Hi, I have a situation where I need to convert business objects to a flat table. The reverse is also required. I am using c# and Oracle ODP. I am looking for an easier method to do the below steps. Steps I follows for populating Business Objects is as follows (1) Get a list of records containing various tables joined together from DB using a single PL/SQL (This is a specific requirement, So cannot change the design)
9
6263
by: Hasan O. Zavalsiz | last post by:
Hi , i am trying to figure out which approach is better to use . let me explain the scenario. i am using the "Nortwind" database . in this database i have "Customers " table .The following is the two different ways to handle this table. CASE 1 : create a struct that encaplusates table "Customers" columns public struct structCustomers { public string CustomerID;
16
9034
by: MS newsgroup | last post by:
I don't have clear reasons why we need business logic layer and data logic layer instead of having only data logic layer. Are there any good reasons for that?
1
1883
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.
25
2779
by: Penelope Dramas | last post by:
Hello, I'm in a front of very serious .net redesign/rewrite of an old VB6 application. I had been asked to make it .NET 2.0 and would like to ask couple of questions regarding data access as this application is heavily data-centric around MSDE database. Would it be better to use custom business objects or extend
2
2642
by: grawsha2000 | last post by:
Greetings, I am developing this N-tier business app. The problem I'm facing is when I try to pass business objects (employees, dept..etc) from business tier to data tier,i.e., the add method in the data tier expects business object from the business tier, I get an error saying: Can not covert businesslayer.emp to businesslayer.emp
2
4059
by: Chris Zopers | last post by:
Hello, I would like to know what's the best way to implement a business logic layer between my user interface and my database. I would say I'd make a dll-project for the business logic layer and make classes that represent objects/tables. For example, if I have a table named 'tblPersons' I would make a class named 'clsPersons' and a class 'clsPerson' that represents one person/record. In class 'clsPersons' I can make some business...
9
2742
by: SAL | last post by:
Hello, I have a Dataset that I have table adapters in I designed using the designer (DataLayer). I have a business logic layer that immulates the DataLayer which may/may not have additional logic in. My business classes are, of course, decorated with the: <System.ComponentModel.DataObject() attribute. So, I drop a GridView on a webform and set its datasource to an ObjectDatasource which in turn is using one of my business logic...
0
9456
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
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
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...
0
9872
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...
0
9713
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
8713
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
7248
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
6534
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
5142
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 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.