d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Make Me A Better Programmer - From Step 1
Prev1484950515256Next
Add Reply New Topic New Poll
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Nov 6 2014 01:26am
Personal question from an untrained hobbyist.

What rules do you set in order to maintain like typing for variables, classes, and function names?

As in do you camel case for everything (someVar, someFunction()) or do use some other method? I notice some of your functions have underscores in them while others do not. Also do you ever prefix variables with their type (iMyVar, sSomeString, cCharacters).

I find it difficult to maintain one naming convention. It seems like every other project I am changing it.

Basically which do you like/use and why.
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 6 2014 01:26am
When I took this course in uni I had a fucking blast. Our compiler was a group project. I wanted to write it in C, but no one else on my team knew C and they wanted to contribute to the coding. So we did it in Java, because that's the only language they knew -.-


And I ended up writing it by myself anyways...meh.
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Nov 6 2014 01:32am
Quote (AbDuCt @ Nov 6 2014 02:26am)
Personal question from an untrained hobbyist.

What rules do you set in order to maintain like typing for variables, classes, and function names?

As in do you camel case for everything (someVar, someFunction()) or do use some other method? I notice some of your functions have underscores in them while others do not. Also do you ever prefix variables with their type (iMyVar, sSomeString, cCharacters).

I find it difficult to maintain one naming convention. It seems like every other project I am changing it.

Basically which do you like/use and why.


I personally haven't thought too much about it. I have heard some people do as you say (using prefixes).

I have always just used names that generally strongly refer to what a variable is / what a function does

In the case of my parser, the function names were literally the productions of a BNF grammar from our teacher (stuff like <program>, <T>, <F> etc)

I appended the _NT (NON-TERMINAL) just as a way to make them unique.



I currently like the way I do it, but it is also true I have never tried prefixing variables.

For functions, I am a big fan of the camel case. I make exceptions for parser because tNT or TNt etc make ugly functions :o

Quote (Minkomonster @ Nov 6 2014 02:26am)
When I took this course in uni I had a fucking blast. Our compiler was a group project. I wanted to write it in C, but no one else on my team knew C and they wanted to contribute to the coding. So we did it in Java, because that's the only language they knew -.-


And I ended up writing it by myself anyways...meh.


Yeah, ours is a cumulative solo project. As a result, the language is pretty simple (I posted a shitty example program above).

Our language does not have case sensitivity, no functions, etc.

Also, it is a top-down parser, so it is already a bit constrained. Bottom-up is much better I hear.

This post was edited by Eep on Nov 6 2014 01:34am
Member
Posts: 1,995
Joined: Jun 28 2006
Gold: 7.41
Nov 6 2014 01:46am
Quote (Eep @ Nov 6 2014 02:32am)

Yeah, ours is a cumulative solo project. As a result, the language is pretty simple (I posted a shitty example program above).

Our language does not have case sensitivity, no functions, etc.

Also, it is a top-down parser, so it is already a bit constrained. Bottom-up is much better I hear.



Our language was PL/0. Pretty simple as well

EBNF:

Code
program = block "." .

block = [ "const" ident "=" number {"," ident "=" number} ";"]
[ "var" ident {"," ident} ";"]
{ "procedure" ident ";" block ";" } statement .

statement = [ ident ":=" expression | "call" ident
| "?" ident | "!" expression
| "begin" statement {";" statement } "end"
| "if" condition "then" statement
| "while" condition "do" statement ].

condition = "odd" expression |
expression ("="|"#"|"<"|"<="|">"|">=") expression .

expression = [ "+"|"-"] term { ("+"|"-") term}.

term = factor {("*"|"/") factor}.

factor = ident | number | "(" expression ")".



Member
Posts: 39,849
Joined: Apr 9 2009
Gold: 3,656.09
Nov 9 2014 01:17am
Why is it printing this? -_-
http://i.imgur.com/KgjDrHE.png
Member
Posts: 13,425
Joined: Sep 29 2007
Gold: 0.00
Warn: 20%
Nov 9 2014 01:26am
Quote (MelsonX @ Nov 9 2014 03:17am)
Why is it printing this? -_-
http://i.imgur.com/KgjDrHE.png


Because 1 is not equal to 2, duh.

Rethink your logic and google "python elif"
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Dec 17 2014 04:49pm
Last final = done

last project = turned in


*whew*

what a ride!
Member
Posts: 24,683
Joined: Sep 22 2007
Gold: 0.06
Dec 18 2014 06:14pm
Quote (Eep @ Dec 17 2014 10:49pm)
Last final = done

last project = turned in


*whew*

what a ride!


wait you've finished final project etc? when do u finish overall?
Member
Posts: 23,862
Joined: Aug 16 2006
Gold: 20.00
Dec 18 2014 08:29pm
Quote (JP99 @ Dec 18 2014 07:14pm)
wait you've finished final project etc? when do u finish overall?


I was technically finished overall on wednesday
Member
Posts: 24,683
Joined: Sep 22 2007
Gold: 0.06
Dec 20 2014 11:00am
Quote (Eep @ Dec 19 2014 02:29am)
I was technically finished overall on wednesday


Does university finish in winter in the US?

we finish just before summer in the UK like May/June
Go Back To Programming & Development Topic List
Prev1484950515256Next
Add Reply New Topic New Poll