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

Class structure / VS.net question

Hi All,

I'm new to VS.net, coming from Delphi, and there is something that I'm
trying to clarify in my head about VS.net.

Suppose you had a class Employee (Name, Age, Title, etc).

Lets further assume that you are creating a web service, with a .net
windows application as a client to that web service. Given that you
wish to share the structure of the Employee class between client and
web service (which occurs with the auto generation of a proxy class),
all is fine.

Is there a way of structuring your code so that you can make use of
only one copy of the Employee class? Im not trying to get the method
itself over the web service, but rather allowing my already defined
class to be used in two places (the web service and the client
application).

For instance, can you call upon a method (say calculateSalary [which
perhaps adds 2 numbers together]) without going to the webservice and
hence back to the original class itself for the method (which is not
transferred over the web service)? So we would compile the class into
two separate assemblies?

Thanks, Rob
Nov 23 '05 #1
1 2099
The Proxy only replicates properties and Web Service methods.
Definition of what this means
[WebMethod]
public MyDatatype[] AMethod(int32 parameter)
{
return an array of MyDataType[]
}
class MyDataType
{ public property MyName
override ToString() { return MyName; }
}
If the web service is used in a reference and you add the object to a
listbox instead of seeing the value of MyName it will show
{MNameSpace.MyDataType}.

Sharing the same logic code such as the above example between a web
service and a client is extremely painful imho. Often times I have
logic that needs to be performed by the client but does not need to be
performed by the web service. When this happens i create a MyDataTypeEx
which has a constructor overload that accepts a MyDataType (this is
useful for arrays since you cannot convert MyDataType[] to
MyDataTypeEx. This approach may actually be usable in a scenario where
one needs logic to be usable by both sides. You could have your
Extended class which has all the shared logic in a separate satellite
assembly. You never publicly expose these methods via the web service.
The only real major issue I see here is that you have the overhead of
going back and forth between Object and ExtendedObject .

I think there is a reason why web services are still not a common sight
and this is one of the many reasons why. Currently web services are a
semi-decent means to communicate and from my experience you really
should not be attempting to communicate anything overly complex,
otherwise the limitations start weighing in heavily.

Nov 23 '05 #2

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

Similar topics

1
by: Victor Hannak | last post by:
I have two classes derived from a base class. The two derived classes each utilize a structure that is slightly different from one another. i.e. DerivedClass1: struct NodeStruct { float...
1
by: Sean W. Quinn | last post by:
Hey folks, I have a question regarding file handling, and the preservation of class structure. I have a class (and I will post snippets of code later in the post) with both primitive data...
21
by: Jon Slaughter | last post by:
I have a class that is basicaly duplicated throughout several files with only members names changing according to the class name yet with virtually the exact same coding going on. e.g. class...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
13
by: cgough | last post by:
My true programming language is C++. I am at best a VB6 hacker that is just getting into VB.NET. I have a quick question about when to new and when not to new. Consider the following 2 classes....
3
by: Ren | last post by:
Hi all, I'm still rather new to .NET so I hope you'll bear with me as I try and explain my question. I am writing an ASP.NET application using VB.NET. I am accessing a web method from a...
2
by: Warex | last post by:
Hello, I have 2 questions maybe someone can answer. 1. On a function class when you return an item is it possible to return more than one and how is that done? Currently I am using for one...
4
by: MikeJ | last post by:
make a While loop ofs = TextFileServer("somefile") string srow while (ofs=false) { srow=ofs.getRow(); Console.Writeline(srow); }
5
by: cbmeeks | last post by:
Hello all. I have a project that I am working on and I need some suggestions. First, I have a class that contains a value and a reference to a parent class. For example: public class Data
2
by: K Viltersten | last post by:
Suppose there is the following class structure. class S {...} class A : S {...} class B : S {...} class A1 : A {void m(){...}} class B1 : B {void m(){...}} class B2 : B {...} Just to clarify...
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:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
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,...
0
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...

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.