Re: Still not clear about global functions
- From: "Juan T. Llibre" <nomailreplies@xxxxxxxxxxx>
- Date: Wed, 15 Jun 2005 19:48:14 -0400
Hi, Alan.
re:
> I suppose they can't be done from source files?
You could, but it's not good to publish source code.
One of the great advantages of assemblies ( DLLs ) is that they
give you a measure of protection against those who would simply
copy your source code.
re:
> As to the other question, is this a sensible approach altogether?
Sure it is...
Using classes is more efficient and helps you organize your code functions.
re:
> I can't see how you can get around having a global function here, but everyone seems to
> say that they are really against the idea of OOP.
Tell "everyone" that OOP *is* the standard,
and the most efficient, way to manage functionality.
Juan T. Llibre
ASP.NET MVP
http://asp.net.do/foros/
Foros de ASP.NET en Español
Ven, y hablemos de ASP.NET...
======================
"Alan Silver" <alan-silver@xxxxxxxxxxxx> wrote in message
news:VHiO03D6FKsCFwRl@xxxxxxxxxxxxxxxxxxxxxx
> Juan,
>
> Thanks for your answer. I suppose it's kinda obvious that they should be compiled into
> DLLs, but I wasn't sure and no-one seemed to specify.
>
> I suppose they can't be done from source files? DLLs aren't a huge problem (not like COM
> DLLs in Classic ASP), but one huge advantage of source files (like .aspx files) is that
> you can do quick changes on the fly.
>
> As to the other question, is this a sensible approach altogether? I can't see how you
> can get around having a global function here, but everyone seems to say that they are
> really against the idea of OOP.
>
> Thanks for the reply.
> a
>
>>re:
>>>1) OK, so I can create a file called MyStuff.cs, which contains a class and the static
>>>members. What do I do with it then?
>>
>>Just open a command window ( cmd.exe );
>>make sure that the .Net Framework directory is in your path
>>( the .Net dir is where the compilers are located (vbc.exe, csc.exe));
>>navigate to the directory where you have your .vb files,
>>and run the compile command :
>>
>>csc /t:library /out:MyStuff.dll MyStuff.cs
>>
>>If you need to import .Net classes, include them in your command line:
>>csc /t:library /r:system.dll /r:system.web.dll /out:MyStuff.dll MyStuff.cs
>>
>>MyStuff.dll will be created/compiled in the current directory.
>>
>>Move it to the /bin directory of your application and fire away.
>>If you want to have VS.NET use it, reference it in your project.
>>
>>You can now call the classes in MyStuff.dll using
>>YourClassName.yourmethod, as long as you import
>>the assembly into your aspx file :
>>
>><%@ Import Namespace="YourClassname" %>
>>
>>
>>
>>Juan T. Llibre
>>ASP.NET MVP
>>http://asp.net.do/foros/
>>Foros de ASP.NET en Español
>>Ven, y hablemos de ASP.NET...
>>======================
>>
>>"Alan Silver" <alan-silver@xxxxxxxxxxxx> wrote in message
>>news:C6YbbNDRcHsCFwhB@xxxxxxxxxxxxxxxxxxxxxx
>>> Hello,
>>>
>>> I have spent ages trawling through Google, looking for information about global
>>> functions in ASP.NET and I'm still not clear about the best way to go about this (or
>>> not).
>>>
>>> I am writing a site that will be for members only. They will have to log in to gain
>>> access to any of the pages. I am holding the user information in an XML file (there
>>> will
>>> probably never be a large number of user, so this is efficient enough).
>>>
>>> What I would like to do is have a global function that I can use to get user settings
>>> out of the XML file. For example, if I called ...
>>>
>>> UserSettings("accessLevel")
>>>
>>> then I would get the access level setting for the currently logged in user (where
>>> "accessLevel" is something I put in the XML file).
>>>
>>> After researching this, two main points seem to come up over and over again...
>>>
>>> 1) To use global functions, create a class and add the functions in there. If they are
>>> static, then you don't need to instantiate the class, you just call
>>> MyStuff.UserSettings("accessLevel").
>>>
>>> 2) Don't have global functions, it's not the OOP way.
>>>
>>> The problems I have are (in relation to these two points)...
>>>
>>> 1) OK, so I can create a file called MyStuff.cs, which contains a class and the static
>>> members. What do I do with it then? I guess if you are using VS, then that's all you
>>> need to do, but I'm using a text editor. What do I do with the .cs file when I've
>>> created it? No-one seems to mention that point.
>>>
>>> 2) What's a better (ie more OOP) way to do this? I'm very keen to learn the right way
>>> to
>>> do things, but I can't see one here.
>>>
>>> Any advice appreciated.
>>>
>>> --
>>> Alan Silver
>>> (anything added below this line is nothing to do with me)
>>
>>
>
> --
> Alan Silver
> (anything added below this line is nothing to do with me)
.
- Follow-Ups:
- Re: Still not clear about global functions
- From: Alan Silver
- Re: Still not clear about global functions
- References:
- Still not clear about global functions
- From: Alan Silver
- Re: Still not clear about global functions
- From: Juan T. Llibre
- Re: Still not clear about global functions
- From: Alan Silver
- Still not clear about global functions
- Prev by Date: Re: How to Resize an Image in ASP.NET?
- Next by Date: Re: Security Flaw in dll (or am I wrong?)
- Previous by thread: Re: Still not clear about global functions
- Next by thread: Re: Still not clear about global functions
- Index(es):
Relevant Pages
|
Loading