Re: Still not clear about global functions



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)


.



Relevant Pages

  • Re: Still not clear about global functions
    ... DLLs aren't a huge problem, but one huge advantage of source files is that you can do quick changes on the fly. ... 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. ... I am writing a site that will be for members only. ...
    (microsoft.public.dotnet.framework.aspnet)
  • [Un] Unangband 0.6.0 final released
    ... is now available for download. ... The source files are available at ... time to the beta release as well as Andrew Sidwell for assisting with debugging ... source code available to help me finish the adoption of the 4GAI code. ...
    (rec.games.roguelike.angband)
  • Re: Debugging
    ... > I do a listing of available source code from within DDD none of these ... all that shows up is the top level source files containing the ... I manually added it with the directory command in gdb. ...
    (comp.lang.fortran)
  • Re: where is reports.vb class
    ... They should be in your client's source code. ... Search for files with those names in the source files you were supplied with. ... > whaka, whaka. ... >> Microsoft MVP ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: How Can I Define Global Classes In Web Application ?
    ... You can place source code in the App_Code directory. ... Any source files you place there will be compiled. ... You can compile them yourself and place the generated ... assembly/assemblies in the /bin directory. ...
    (microsoft.public.dotnet.framework.aspnet)

Loading