Posted By: Klaus Enevoldsen | Mar 14th, 2008 @ 12:11 AM
page 2 of 2
Comments: 32 | Views: 3237
Massif
Massif
aim stupidly high, expect to fail often.
figuerres wrote:

Massif wrote: I've tended to consistently name any parameters which get altered by a function "victim".

e.g.

void MakeLowerCase(char* victim)
{
...
}

(except of course, I never ever wrote a MakeLowerCase function, that's just an example.)


well I try to *NOT* modify params...

but then I come from the old "C" style of

f()  is a FUNCTION   so something like that would be

string MakeLowerCase( string TextIn){
}

I only use out x in C# when .net has already asked for it like with

Int32.TryParse() for example.


Tongue Out

I've been exposed to the COM style of "return some code to say you worked, and return all data in parameters". I've also been exposed to the "let's try to use C as an OO language, without just adopting an OO language" model of basically replacing all functions with something of the form:

<ret_type> SomeFunction( <pointer to struct> this, <some params> )

Which is one of those: "Why are we doing this again?" moments.

Of course, ideally I try not to modify anything. But sometimes you just need to return two things from a function.
Tensor
Tensor
Im in yr house upgrading yr family
I honour of the quirky c9 language filter, I hereby pledge that in the future I will allways abbreviate Assembly to Arse.
W3bbo
W3bbo
The Master of Baiters
Massif wrote:
I've been exposed to the COM style of "return some code to say you worked, and return all data in parameters". I've also been exposed to the "let's try to use C as an OO language, without just adopting an OO language" model of basically replacing all functions with something of the form:

<ret_type> SomeFunction( <pointer to struct> this, <some params> )

Which is one of those: "Why are we doing this again?" moments.


In situations like that I'd just use C++ without anyone else noticing.
figuerres
figuerres
???
Massif wrote:

figuerres wrote: 
Massif wrote: I've tended to consistently name any parameters which get altered by a function "victim".

e.g.

void MakeLowerCase(char* victim)
{
...
}

(except of course, I never ever wrote a MakeLowerCase function, that's just an example.)


well I try to *NOT* modify params...

but then I come from the old "C" style of

f()  is a FUNCTION   so something like that would be

string MakeLowerCase( string TextIn){
}

I only use out x in C# when .net has already asked for it like with

Int32.TryParse() for example.




I've been exposed to the COM style of "return some code to say you worked, and return all data in parameters". I've also been exposed to the "let's try to use C as an OO language, without just adopting an OO language" model of basically replacing all functions with something of the form:

<ret_type> SomeFunction( <pointer to struct> this, <some params> )

Which is one of those: "Why are we doing this again?" moments.

Of course, ideally I try not to modify anything. But sometimes you just need to return two things from a function.


Not what I was trying to say...

I was talking about the "f()"  as in a FUNCTION
which takes params and returns a result.
where params and results can be of whatever type.

not to twist any use of the lang.

does that clear it up at bit?
blowdart
blowdart
Peek-a-boo
Massif wrote:


I've been exposed to the COM style of "return some code to say you worked, and return all data in parameters"..


Of course that's come back in web services; and WCF with data contracts.
Massif
Massif
aim stupidly high, expect to fail often.
W3bbo wrote:

Massif wrote: I've been exposed to the COM style of "return some code to say you worked, and return all data in parameters". I've also been exposed to the "let's try to use C as an OO language, without just adopting an OO language" model of basically replacing all functions with something of the form:

<ret_type> SomeFunction( <pointer to struct> this, <some params> )

Which is one of those: "Why are we doing this again?" moments.


In situations like that I'd just use C++ without anyone else noticing.


The compiler would have noticed.

To be fair, we had to use C, because we were writing device drivers and C++ is a poor choice for drivers because things like polymorphism (specifically virtual function pointers) aren't guaranteed to work. And when the documentation says "we don't guarantee this" you don't think to yourself: "what the heck, let's spend months doing it anyway".
Since someone mentioned language filters... please don't name any function to something that will be blocked by web content filters.

Been worked in a company that uses content filters, and blocks me from referencing MSDN web pages like ChangeDisplaySettingsEx() (notice the last 3 letters) Adds another level of annoyance to "working in web-access controlled environment".

evildictaitor
evildictaitor
if( !succeed( try() ) ) { while(true) try(); }
cheong wrote:
Since someone mentioned language filters... please don't name any function to something that will be blocked by web content filters.

Been worked in a company that uses content filters, and blocks me from referencing MSDN web pages like ChangeDisplaySettingsEx() (notice the last 3 letters) Adds another level of annoyance to "working in web-access controlled environment".



It's even worse when their dumb system fires off a complaint that you've repeatably been trying to access "restricted sites" to your boss. It's not so bad when they have a list of what actual sites you were visiting (oh my gosh! MSDN?) but I can imagine that some companies wouldn't and will just flag that you tried to go to 12 Bad SitesTM today.
page 2 of 2
Comments: 32 | Views: 3237
Microsoft Communities