473,790 Members | 2,437 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

function call & architecture recommendations

TS
From my presentation layer, I call a validation method in my business layer
that i pass a custom class to that holds all parameters. I am currently also
passing an error message by reference so that the calling code can have this
string set to an error message inside this method.

I'm wondering 2 things:
1. Should i put the errorMessage param as a property on args and pass the
whole thing as reference?

2. Is there a more elegant approach to handling validation that occurs on
this separate business layer?

thanks a lot!
public bool CanReg(RegValid ationArgs args, ref string errorMessage)
{
// Call method to validate isn't already registered if this is a new
record
if( this.IsNew )
{ // make sure isn't already registered
if( IsAlreadyRegist ered(this.Class Id, this.PartId) == true )
{
errorMessage = AlreadyRegister edMsg;
return false;
}
}

Funding faFunding= Funding.GetFund ing(args.AgentI d, args.SourceId ,
args.Date);
// If one isn't found, then the Funding can't be used
if( faFunding == null )
{
errorMessage = CannotUseFundin gSourceMsg;
return false;
}
}

}
Nov 17 '05 #1
5 1288
Create one class called Registration. Use it for storing the values,
validating their contents, and committing the transaction. That one class,
and its underlying database connections, is you business layer.

X = new Registration()
X.FundingSource = ???
X.LastName = ??
X.FirstName = ??
try
X.Commit();
catch ex ValidationExcep tion
//return ex.Message to the user
end try

***************

The point here is that your presentation and business layers don't have to
be physically separated. As long as you can look at the code and say, this
class holds my business rules and that form interacts with the user, you've
done your job.

--
Jonathan Allen
"TS" <ma**********@n ospam.nospam> wrote in message
news:Oj******** ******@TK2MSFTN GP09.phx.gbl...
From my presentation layer, I call a validation method in my business
layer
that i pass a custom class to that holds all parameters. I am currently
also
passing an error message by reference so that the calling code can have
this
string set to an error message inside this method.

I'm wondering 2 things:
1. Should i put the errorMessage param as a property on args and pass the
whole thing as reference?

2. Is there a more elegant approach to handling validation that occurs on
this separate business layer?

thanks a lot!
public bool CanReg(RegValid ationArgs args, ref string errorMessage)
{
// Call method to validate isn't already registered if this is a new
record
if( this.IsNew )
{ // make sure isn't already registered
if( IsAlreadyRegist ered(this.Class Id, this.PartId) == true )
{
errorMessage = AlreadyRegister edMsg;
return false;
}
}

Funding faFunding= Funding.GetFund ing(args.AgentI d, args.SourceId ,
args.Date);
// If one isn't found, then the Funding can't be used
if( faFunding == null )
{
errorMessage = CannotUseFundin gSourceMsg;
return false;
}
}

}

Nov 17 '05 #2
TS
this is how i have it. The method on my business layer i was referring to is
in my registration class. My main question is how to appropriately pass back
the error messages from the registration class to the UI for display. How i
have it is that i pass all needed params to the method in a class that hold
all of them, then i also send a parameter by reference so that the
registration class can set its value so the calling code in the UI now has
the error message.

I just don't like having all the parameters housed in the RegValidationAr gs
class and then have to add another parameter by reference. I don't know if
i should include the extra parameter inside the RegValidationAr gs class as
well, or to do a different approach alltogether.

thanks for your input
"Jonathan Allen" <x@x.x> wrote in message
news:Oe******** ******@TK2MSFTN GP14.phx.gbl...
Create one class called Registration. Use it for storing the values,
validating their contents, and committing the transaction. That one class,
and its underlying database connections, is you business layer.

X = new Registration()
X.FundingSource = ???
X.LastName = ??
X.FirstName = ??
try
X.Commit();
catch ex ValidationExcep tion
//return ex.Message to the user
end try

***************

The point here is that your presentation and business layers don't have to
be physically separated. As long as you can look at the code and say, this
class holds my business rules and that form interacts with the user, you've done your job.

--
Jonathan Allen
"TS" <ma**********@n ospam.nospam> wrote in message
news:Oj******** ******@TK2MSFTN GP09.phx.gbl...
From my presentation layer, I call a validation method in my business
layer
that i pass a custom class to that holds all parameters. I am currently
also
passing an error message by reference so that the calling code can have
this
string set to an error message inside this method.

I'm wondering 2 things:
1. Should i put the errorMessage param as a property on args and pass the whole thing as reference?

2. Is there a more elegant approach to handling validation that occurs on this separate business layer?

thanks a lot!
public bool CanReg(RegValid ationArgs args, ref string errorMessage)
{
// Call method to validate isn't already registered if this is a new
record
if( this.IsNew )
{ // make sure isn't already registered
if( IsAlreadyRegist ered(this.Class Id, this.PartId) == true )
{
errorMessage = AlreadyRegister edMsg;
return false;
}
}

Funding faFunding= Funding.GetFund ing(args.AgentI d, args.SourceId ,
args.Date);
// If one isn't found, then the Funding can't be used
if( faFunding == null )
{
errorMessage = CannotUseFundin gSourceMsg;
return false;
}
}

}


Nov 17 '05 #3
I would suggest merging the RegValidationAr gs into the class that has CanReg
method. As fort passing the human-readable error message by ref, that sounds
good to me.

--
Jonathan Allen
"TS" <ma**********@n ospam.nospam> wrote in message
news:uX******** ******@TK2MSFTN GP14.phx.gbl...
this is how i have it. The method on my business layer i was referring to
is
in my registration class. My main question is how to appropriately pass
back
the error messages from the registration class to the UI for display. How
i
have it is that i pass all needed params to the method in a class that
hold
all of them, then i also send a parameter by reference so that the
registration class can set its value so the calling code in the UI now has
the error message.

I just don't like having all the parameters housed in the
RegValidationAr gs
class and then have to add another parameter by reference. I don't know
if
i should include the extra parameter inside the RegValidationAr gs class as
well, or to do a different approach alltogether.

thanks for your input
"Jonathan Allen" <x@x.x> wrote in message
news:Oe******** ******@TK2MSFTN GP14.phx.gbl...
Create one class called Registration. Use it for storing the values,
validating their contents, and committing the transaction. That one
class,
and its underlying database connections, is you business layer.

X = new Registration()
X.FundingSource = ???
X.LastName = ??
X.FirstName = ??
try
X.Commit();
catch ex ValidationExcep tion
//return ex.Message to the user
end try

***************

The point here is that your presentation and business layers don't have
to
be physically separated. As long as you can look at the code and say,
this
class holds my business rules and that form interacts with the user,

you've
done your job.

--
Jonathan Allen
"TS" <ma**********@n ospam.nospam> wrote in message
news:Oj******** ******@TK2MSFTN GP09.phx.gbl...
> From my presentation layer, I call a validation method in my business
> layer
> that i pass a custom class to that holds all parameters. I am currently
> also
> passing an error message by reference so that the calling code can have
> this
> string set to an error message inside this method.
>
> I'm wondering 2 things:
> 1. Should i put the errorMessage param as a property on args and pass the > whole thing as reference?
>
> 2. Is there a more elegant approach to handling validation that occurs on > this separate business layer?
>
> thanks a lot!
> public bool CanReg(RegValid ationArgs args, ref string errorMessage)
> {
> // Call method to validate isn't already registered if this is a new
> record
> if( this.IsNew )
> { // make sure isn't already registered
> if( IsAlreadyRegist ered(this.Class Id, this.PartId) == true )
> {
> errorMessage = AlreadyRegister edMsg;
> return false;
> }
> }
>
> Funding faFunding= Funding.GetFund ing(args.AgentI d, args.SourceId ,
> args.Date);
> // If one isn't found, then the Funding can't be used
> if( faFunding == null )
> {
> errorMessage = CannotUseFundin gSourceMsg;
> return false;
> }
> }
>
> }
>
>



Nov 17 '05 #4
Thanks fro Jonathan's quick response!

Hi TS,

I think it's fine to pass a string back to the caller by reference.
However, there are also some other ways. For example, you can thrown an
exception if the validation fails and include the error message in the
exception message. In the call code, you just catch this exception and
display it. HTH.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 17 '05 #5
TS
Thank you all!
"TS" <ma**********@n ospam.nospam> wrote in message
news:Oj******** ******@TK2MSFTN GP09.phx.gbl...
From my presentation layer, I call a validation method in my business layer that i pass a custom class to that holds all parameters. I am currently also passing an error message by reference so that the calling code can have this string set to an error message inside this method.

I'm wondering 2 things:
1. Should i put the errorMessage param as a property on args and pass the
whole thing as reference?

2. Is there a more elegant approach to handling validation that occurs on
this separate business layer?

thanks a lot!
public bool CanReg(RegValid ationArgs args, ref string errorMessage)
{
// Call method to validate isn't already registered if this is a new
record
if( this.IsNew )
{ // make sure isn't already registered
if( IsAlreadyRegist ered(this.Class Id, this.PartId) == true )
{
errorMessage = AlreadyRegister edMsg;
return false;
}
}

Funding faFunding= Funding.GetFund ing(args.AgentI d, args.SourceId ,
args.Date);
// If one isn't found, then the Funding can't be used
if( faFunding == null )
{
errorMessage = CannotUseFundin gSourceMsg;
return false;
}
}

}

Nov 17 '05 #6

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

Similar topics

4
3630
by: anonymous | last post by:
Thanks your reply. The article I read is from www.hakin9.org/en/attachments/stackoverflow_en.pdf. And you're right. I don't know it very clearly. And that's why I want to understand it; for it's useful to help me to solve some basic problem which I may not perceive before. I appreciate your help, sincerely.
10
2187
by: Nitin | last post by:
Ppl , Want to have ur opinions on having function calls like the one stated below: function funcA ( struct A *st_A , struct B *st_B ) { st_A->a = st_B->a
1
4475
by: benmorganpowell | last post by:
I have a small windows service which connects to a POP3 server at defined intervals, scans the available messages, extracts the required information and inserts the data into a SQL database. I am assuming that this is not an uncommon piece of software. I want to get an architecture that conforms as closely as possible with the recommendations from Microsoft on developing Windows Services, but to be honest I have found difficultly in...
15
4995
by: marydeepthy | last post by:
Hi, I would like to know what happens internally when a c programme is executed. LIke, when we call a function, all the previous values will be pushed on to stack and the local variables of that particular function will be pushed in to the stack. when the function returns, all the local variables will be poped out.. like this, what happens when we call a strcpy function. what happens in
2
2053
by: freegnu | last post by:
how to declare a friend function that can access two class it will look like the following class A { private: int i; public: A(){} ~A(){} friend void call(A &a, B &b);
7
3176
by: Samuel | last post by:
Hi, I am looking for some recommendations for client/server technologies and for the communication involved. I am currently planning to port a Perl application that has grown out of proportion to another language and architecture. For this purpose, I am investigating technologies that best fit the requirements. The current plan for the architecture of the ported software includes:
5
3654
by: Immortal Nephi | last post by:
I would like to design an object using class. How can this class contain 10 member functions. Put 10 member functions into member function pointer array. One member function uses switch to call 10 member functions. Can switch be replaced to member function pointer array? Please provide me an example of source code to show smart pointer inside class. Thanks....
1
1379
by: Cirene | last post by:
Do you have any good book recommendations for learning Entity Framework, DAAB, and/or Tiered Architecture (business objects, etc)? I am a VB.net developer, but C# would be ok I guess.... Thanks
0
9666
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
9512
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
10413
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
10200
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
9986
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
6769
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
5422
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
5551
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2909
bsmnconsultancy
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...

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.