Wrox Programmer Forums
|
BOOK: ASP.NET Website Programming Problem-Design-Solution
This is the forum to discuss the Wrox book ASP.NET Website Programming: Problem - Design - Solution, Visual Basic .NET Edition by Marco Bellinaso, Kevin Hoffman; ISBN: 9780764543869
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET Website Programming Problem-Design-Solution section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 25th, 2005, 04:42 AM
Registered User
 
Join Date: May 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Why not shared function

I am using vb version. I feel quite strange that all the business layer delete method is not shared function, it means that we need to instanstiate an object before we use the delete method,
as instantiate an object in this project will in turn get the relevant objects details from the data layer and this step seems like redundant..
What is the reason not write it in shared function, that pass in the primary key of the table as argument?
 
Old June 27th, 2005, 08:28 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 917
Thanks: 0
Thanked 0 Times in 0 Posts
Default

For a simple function like Delete you can make it into a shared
(static in C#) function if you want.

Instance methods are helpful when you need to maintain state between several calls to an object.

It's not "right" or "wrong" to use an instance method in cases where you don't need to save state between multiple calls (like in this case). Some people prefer to use instance methods to make the code more consistant.

Shared (static) methods are more efficient at the CLR level, but that difference is slight when you consider the time it takes to hit the database.

Eric





Similar Threads
Thread Thread Starter Forum Replies Last Post
Shared EXE yves Beginning VB 6 6 February 7th, 2006 09:31 PM
Shared workbook. seasider Excel VBA 0 January 20th, 2006 12:02 PM
shared folder marino22 VBScript 1 December 21st, 2005 02:05 PM
Create a shared assembly kk_katepally General .NET 1 February 7th, 2005 02:58 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.