Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-

Coding style, the ultimate thread.

Name: Anonymous 2010-07-31 4:02

Language: C
Typedefs: foo_t
Functions: stuff_with_underscores()
Brackets: linux-style ('\n' before '{')

Language: C++
Typedefs for primtive types: foo_t
Class declarations: class FooBar ...
Functions: stuff_with_underscores()
Methods: stuff_with_underscores()
Brackets: linux-style ('\n' before '{')

Name: Anonymous 2010-07-31 4:12

So you opted to describe your style rather than post a short code snippet so that everything is clear. Are you perhaps related to the people that like to spell out the truth tables for logic gates?

Name: Anonymous 2010-07-31 5:36

namespace anus
{
    class explorer
    {
        explorer(explorer const&) = delete;
        explorer& operator=(explorer const&) = delete;

    protected:

        explorer();

        explicit explorer(shared_ptr<digging_tool> const& t);

    public:

        virtual ~explorer();

        virtual void discover_treasure() = 0;

        shared_ptr<digging_tool> const& tool() const;

        void tool(shared_ptr<digging_tool> const& t);

    private:

        shared_ptr<digging_tool> tool_;
    };

    inline explorer::explorer() {
    }

    inline explorer::explorer(shared_ptr<digging_tool> const& t)
    : tool_(t) {
    }

    inline shared_ptr<digging_tool> const& explorer::tool() const {
        return tool_;
    }

    inline void explorer::tool(shared_ptr<digging_tool> const& t) {
        tool_ = t;
    }
}

Name: Anonymous 2010-07-31 5:37

>>3
oh fuck, I forgot my code tags.... fuckkkkkkkkkkkkkkkkkk

Name: Anonymous 2010-07-31 8:10

foo_t
Get the fuck out. You're not a POSIX implementer and you never will be. Use the allowed type naming conventions.

Name: Anonymous 2010-07-31 8:43

>>5
But he needs it to avoid a nonexistent namespace conflict!

Name: Anonymous 2010-07-31 13:21

>>2
Actually I do that. Now go fuck yourself.

Name: Anonymous 2010-07-31 13:40

Language: C
Typedefs: foo_t
Functions: stuff_with_underscores()
Brackets: oneline

Name: Anonymous 2010-07-31 13:49

Language: C++
Typedefs for primtive types: foo_t
Class declarations: class FooBar ...
Functions: DoThing()
Methods: DoThing()
Brackets: int main() {

Name: Anonymous 2010-07-31 13:50

>>5
Why should they get to keep the best naming conventions all for themselves? Fuck them, who needs to include POSIX headers anyway?

Name: Anonymous 2010-07-31 13:55

anus.h:

#ifndef ANUS_H_
#define ANUS_H_
typedef struct Anus {
        int is_dilated;
        float relaxation_level;
        time_t time_inserted;
} Anus;

void anus_new(Anus *anus);
void anus_insert_buttplug(Anus *anus);
void anus_remove_buttplug(Anus *anus);
#endif


anus.c:

#include <time.h>
#include "anus.h"

// :TODO: If the buttplug is removed before the anus becomes dilated, the relaxation level should drop, taking into account the amount of time the buttplug was outside of the anus.

// The buttplug must remain inserted for 2 minutes for the anus to become dilated.
#define DILATION_TIME         120

void anus_new(Anus *anus) {
        anus->is_dilated = 0;
        anus->relaxation_level = 0.0f;
        anus->time_inserted = 0;
}


void anus_insert_buttplug(Anus *anus) {
        // :TODO: check to ensure that a buttplug has not already been inserted[i]![/i]
        anus->time_inserted = time(NULL);
}


void anus_remove_buttplug(Anus *anus) {
        time_t time_diff;
        if (anus->time_inserted) {
                time_diff = time(NULL) - anus->time_inserted;
                anus->relaxation_level += time_diff / DILATION_TIME;
                if (anus->relaxation_level >= 1.0) {
                        anus->is_dilated = 1;
                }
        } else {
                printf("There is no buttplug to remove!\n");
        }
}

Name: Anonymous 2010-07-31 14:29


/* typedefs, structs, classes */
struct FooBar bar;
public class ExtremelyVerboseJavaClass {
    /* ... */
}

/* constants, static finals */

#define COUNT 3;

/* variables */

float penisLength;
int *somePtr, noPtr;

/*functions, methods*/
int doSomething(int x, int *y) {
    if(x < 0)
        return x;

    y = malloc(x);
    return 42;
}

Name: Anonymous 2010-07-31 15:02

#include <curses.h>
#include <string.h>
#include <stdlib.h>

#define MAX_NAME_LENGTH 64

typedef struct
{
  int n;
  char name[MAX_NAME_LENGTH];
} codan;

codan **codans;

unsigned short init_codans(int n); // Prepare an empty array of n codans.
void clear_codans(int low, int high); // Clear faulty codans numbers low through high, inclusive.

/*
  [...] computer, so-called science,
  has a lot in common with magic.
*/

unsigned short init_codans(int n)
{
  codans = (codan **)malloc(n * sizeof(codan *));
  if(!codans)
    return 1;
  return 0;
}

void clear_codans(int low, int high)
{
  int i;
  for(i=low; i<high; i++)
  {
    if(!good_enough(codans[i]->name))
    {
      printf("JESUS FUCK WHAT\n");
      // Remove the codan?
      // TODO: Ask a beginner question at stackoverflow.
    }
  }
}

int main(void)
{
  return -1;
}

Name: Anonymous 2010-07-31 15:06

Language: BBCODE
EXPERT: biou

Name: Anonymous 2010-07-31 16:10

>>11
F, see me after class. A dedicated haxing interface was specifically required in the assignment.

Name: Anonymous 2010-07-31 17:13

>>11
Like this, but { on newlines for functions.

Name: Anonymous 2010-07-31 20:02

#ifndef ... header guards

Is there any point to using this when pragma once is so widely supported?

Name: Anonymous 2010-07-31 20:02

#ifndef ... header guards

Is there any point to using this when pragma once is so widely supported?

Name: Anonymous 2010-07-31 20:14

>>17-18
no

Language: C++
Typedefs: Remove the _t where possible without confusion (uint8, int32)
Pointers/References: int *x, *y;
Classes: GarbageCollector
Functions: thisGarbage()
Braces: if (anythingElseIsForFaggots) {

Language: C#
Classes: GarbageCollector
Functions: ThisGarbage(a => { return a.GetType(); });
Braces: if (anythingElseIsForFaggots) {

Name: Anonymous 2010-07-31 20:57

>>17
I'm old fashioned!

Name: Anonymous 2010-07-31 21:11

>>20
"It's nonstandard" is your get out of jail free card.

Name: Anonymous 2010-07-31 21:20

>>17-18
Why use #pragma when the normal way of doing it is both more common and guaranteed to work on all compilers?

Name: Anonymous 2010-07-31 21:42

>>22
Not to mention it lets you do neat tricks like conditional compilation based on the order of headers, and fucking everything up by using guards from standard headers.

Name: Anonymous 2010-07-31 21:47

>>22
Oh, I use it all the time in Python and Bash and never had any problems!

Name: Anonymous 2010-08-01 0:23

C:
GNU-Coding Standards


int
do_some_stuff(int this, int function_has, float way_too,
                  char many, char args[])
{
  /*Stuff here*/
}

int
main()
{
  int i = 0;

  if (!i)
      do_stuff();
  else
    {
      do_stuff();
      do_more_stuff();
    }
}

Name: Anonymous 2010-08-01 5:29

>>22
What you should do is use both.  #pragma for speed, and #ifndef for keeping the code from executing twice.

Name: Anonymous 2010-08-01 10:01

>>26
  else
    {

IHBT

Name: Anonymous 2010-08-03 20:57

My coding style is a mess. However I did right a little snippet of code to reformat everything nicely when I'm done.

The reason I keep it a mess is because of irl leechers.

Name: Anonymous 2010-08-03 22:45

>>28
Are you the author of indent? If so, I have a few complaints...

Name: Anonymous 2010-08-04 3:53

>>29

No. I wasn't even aware there was already an opensource solution available.

Name: Anonymous 2010-08-04 3:55

>>28
Perhaps you could just send me the wrong version and I'll see what I can do.

Name: ​​​​​​​​​​ 2010-10-25 10:47


Don't change these.
Name: Email:
Entire Thread Thread List