Home icon Back to TheU.ca
FAQ FAQ
Search Search
Memberlist Memberlist
Banned Users List Banned Users List
Usergroups Usergroups
RSS Feeds RSS Feeds
Register Register
Profile Profile
Log in to check your private messages Log in to check your private messages
Log in Log in
 
 

Reply to topic

 
 
View previous topic
View next topic


 
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
 
 

 
 
 
Web theu.ca
xtalk.theu.ca
 
 
 
 
phpBB © 2001, 2002 phpBB Group
phpBBlite template version 1015 by Jupix
 

TheU.ca Forum Index - General Discussion - If I may be so spiteful... - Reply to topic

Goto page Previous  1, 2

 
Senther

Xtalk Drifter


Joined: 29 Jun 2006
Posts: 2296
Location: The Deadlights
Reputation: 131.9
votes: 42
View user's profile

Post Thu Oct 15, 2009 9:26 am   Reply with quote           Send private message    



Personally, I usually would put the (assuming defined type sexuality and gay is defined):

Code:
int arson(sexuality arsonist)
{
  if(arsonist == gay)
    return 0;
  else
    return 1;
}


Unless my code was getting terribly long, then I'd reduce the inside to two lines. The exception is that I almost always keep looped single statements on one line, even if nested.

However, I'm a strong believer in global variables. Mostly because I'm lazy when it comes to passing arrays, but also because of the limited stack inside main (or whatever CSci people call that).



_________________
To avoid complications, she never kept the same address
In conversation, she spoke just like a baroness
 
 
enmand

Some guy


Joined: 30 Aug 2006
Posts: 257

Reputation: 100.6
View user's profile

Post Thu Oct 15, 2009 10:39 am   Reply with quote           Send private message    



Senther wrote:
Personally, I usually would put the (assuming defined type sexuality and gay is defined):

Code:
int arson(sexuality arsonist)
{
  if(arsonist == gay)
    return 0;
  else
    return 1;
}


Unless my code was getting terribly long, then I'd reduce the inside to two lines. The exception is that I almost always keep looped single statements on one line, even if nested.

However, I'm a strong believer in global variables. Mostly because I'm lazy when it comes to passing arrays, but also because of the limited stack inside main (or whatever CSci people call that).


In that case, you would have to
Code:

typdef sexuality

to something meaninful, and "gay" would be a static instance of a sexuality-typed variable. I'm a stong believer in non-global variables, as there are more sensible ways to do things (eg. stateful objects?). Global variables mess up all the scopes, and make the code confusing.



 
 
Apocalypse

The Director


Joined: 22 Nov 2007
Posts: 693
Location: [CLASSIFIED]
Reputation: 5Reputation: 5Reputation: 5Reputation: 5Reputation: 5
votes: 4
View user's profile

Post Thu Oct 15, 2009 10:49 am   Reply with quote           Send private message    



enmand wrote:
Code:
typdef sexuality


or, even better..

Code:
typedef enum { gay, straight } sexuality;


I love how a gay parade thread was turned into a programming practices discussion



_________________
Man is the lowest-cost, 150-pound, nonlinear, all-purpose computer system which can be mass-produced by unskilled labor.
 
 
Jimmy Big Ears

X-talk mobster


Joined: 13 Sep 2006
Posts: 3256
Location: St. Francis Xavier University
Reputation: -217.8
votes: 38
View user's profile

Post Thu Oct 15, 2009 12:14 pm   Reply with quote           Send private message    



This is probably the greatest triumph of computers over relevance. I am going to bring this up the next time anyone here insists they care about issues.



_________________
"Ah, sleek vigilant puma. Principal of the mountains." -Seymour Skinner.
 
 
pedal2000




Joined: 11 Mar 2007
Posts: 2689

Reputation: 105.8
votes: 11
View user's profile

Post Thu Oct 15, 2009 12:21 pm   Reply with quote           Send private message    



pedal2000 wrote:
Cheers it appears to start after one this year


/\ Thread's purpose ended. It's pretty open field after that



 
 
Senther

Xtalk Drifter


Joined: 29 Jun 2006
Posts: 2296
Location: The Deadlights
Reputation: 131.9
votes: 42
View user's profile

Post Thu Oct 15, 2009 12:45 pm   Reply with quote           Send private message    



Apocalypse wrote:

Code:
typedef enum { gay, straight } sexuality;


This is what I was thinking of.

My preference for global variables is probably due to the differences in why we code. Some days, I might throw half a dozen or more quick programs together for parsing data, or what have you. In that case, throwing something above main is not only easier, but avoids a lot of pitfalls with big arrays. I'm also terrible for using system calls in place of longer (but more efficient) routines.

Only when I'm working on something intended for others (or modding existing code, like Q3 source) do I try for elegance.


Oh, and Jimmy, feel free to post in a different topic you don't understand. There's lots to choose from.



_________________
To avoid complications, she never kept the same address
In conversation, she spoke just like a baroness
 
 
Jimmy Big Ears

X-talk mobster


Joined: 13 Sep 2006
Posts: 3256
Location: St. Francis Xavier University
Reputation: -217.8
votes: 38
View user's profile

Post Thu Oct 15, 2009 3:45 pm   Reply with quote           Send private message    



Oh squawk squawk squawk.
pedal2000 wrote:
pedal2000 wrote:
Cheers it appears to start after one this year


/\ Thread's purpose ended. It's pretty open field after that
Excellent.

I am going to talk about the possibility of another Star Trek movie. I hope no one drops out of the cast but they could use a slightly better storyline than the one they had.

Leonard Nimoy ought to get involved - he directed two of the good ones.



_________________
"Ah, sleek vigilant puma. Principal of the mountains." -Seymour Skinner.
 

Goto page Previous  1, 2

TheU.ca Forum Index - General Discussion - If I may be so spiteful... - Reply to topic