Re: Looking for real world examples to explain the difference between procedural (structured?) programming and OOP




"Daniel T." <daniel_t@xxxxxxxxxxxxx> wrote in message
news:94ca2caa-48bd-4bd3-8573-58d8343491a3@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
On May 21, 1:43 am, "cr88192" <cr88...@xxxxxxxxxxx> wrote:
"Daniel T." <danie...@xxxxxxxxxxxxx> wrote in message
On May 20, 12:40 pm, "cr88192" <cr88...@xxxxxxxxxxx> wrote:

[Things we agree on snipped.]

typically, I don't use contexts for functions which are essentially
stateless (and will always be stateless).
IMO, it just seems a little silly to put these as static methods in
some
particular class. similarly for types/objects which are conceptually
atomic
and pass-by-value. ...

yes, such things exist...

You mean a procedure that doesn?t return information nor change any
values in memory?

well, it can return stuff...

but, yes, all input is provided in arguments, and any return value depends
purely on the input...

this is typical of many mathematical functions, ...
traditionally, these would be things like sin, cos, tan, ...

but could include things like sinc, integrators, interpolators, ...
also typical is to implement custom math support, for example, vector and
quaternion support, ...

however, the typical "OO" mindset tends to ignore the existence of things
like this... (like, math is some kind of novelty no "real" programmers
use...).

but, yes, in these cases we don't need a context...

<
Hold on a second, obviously you do need a context because you are
passing in parameter(s)... they are your context.

Functions which require only one parameter fit nicely in the OO model
(e.g., sin, cos, and tan,) but I agree that there are many functions
which need more than one object[1] and there is no reason to give any
single object primacy.

[1]I'm using the definition of 'object' as it used in the C standard.



what I mean by context here is a context-struct...

I usually use context structs (as opposed to globals) for most things, as it
is common for me to want to be able to have multiple instances of many
things, and also because personally I feel using globals in too many places
is tacky and leads to maintainability issues...

however, a context struct is not necessary for functions which don't use or
modify any external state...
in these cases, a class would serve as little more than a scoping
mechanism...

however, it is an annoyance that both Java and C# don't support things like
functions outside of classes, so one is forced into using a class even in
cases where a global-function or namespace-scoped function would be
conceptually more appropriate...

technically, my compiler allows them as an 'unofficial' extension, along
with global variables, ... in large part due to the goal of C and C++
interop (and also because, in my framework, all of them are using most of
the same compiler machinery anyways...).



.



Relevant Pages

  • Re: Script for Hiding/Un-Hiding Text On Click
    ... After you complained about context you didn't even restore the full context. ... And it won't be encountered by trying to write that style element as NN4.xx series browsers will never execute the document.write statement. ... Look again and you will note that Netscape4.x series browsers will *never* execute the document.write in question since it is wrapped in an if{test and since NN4 doesn't support that feature it will *never* execute it and thus never trigger the NRLB. ... support scripting style properties on-load the document, ...
    (comp.lang.javascript)
  • Re: basic message!?
    ... >>> There are no passages that support universalism. ... There are some verses, ... >>> which if read out of context can be made to look as if they do. ...
    (uk.religion.christian)
  • Re: EDM: How to obtain the ObjectContext from an EntityObject
    ... I'll take your advice and include the context as a parameter. ... Thanks for using Microsoft Newsgroup Support Service, ... the objective is trying to get the ObjectContext from an ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: scope of static?
    ... when one declares some public method or variable ... A static exists within the scope of a class loader. ... instance field is global within the context of an instance". ... I have seen "globals" that exist within the context of a JVM; ...
    (comp.lang.java.help)
  • RE: Initial Position of Contextmenu
    ... I handle the Form's MouseClick event and in the event handler, ... the context menu strip pops up at the correct position. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.general)

Loading