Welcome to Dream.In.Code
Getting Help is Easy!

Join 86,399 Programmers. There are 1,463 online right now! Ask your question and get quick answers from Dream.In.Code experts. Join the #1 programming help community on the internet! Registration is fast and FREE... Join Now!

Chat LIVE With a Expert
Powered by LivePerson.com

Register to Make This Box Go Away!

"Style"

 
Reply to this topicStart new topic

"Style", What is good coding style

jediokie
post 1 May, 2008 - 10:31 PM
Post #1


D.I.C Head

**
Joined: 7 Feb, 2008
Posts: 147



So I just finished Programming I at school (made 101% if you're intrested), and the biggest complaint my teacher had was about my coding 'style.' Nothing really specific got mentioned just overall. So that made me wonder what is good coding style?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post


no2pencil
post 1 May, 2008 - 10:47 PM
Post #2


DIC K-mart

Group Icon
Joined: 10 May, 2007
Posts: 3,324

I'm not sure if this is considered "style", but I prefer to indent correctly & comment whenever common sense says I should. It makes it easier for #2pencil (or anyone else) 2 years from now that might need to work on the code again, to actually be able to read the code.

If you have sloppy code, it makes reading your code much much harder.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

mikeblas
post 1 May, 2008 - 11:40 PM
Post #3


D.I.C Head

**
Joined: 8 Feb, 2008
Posts: 94

You should ask your instructor. They've actually seen your code, and can explain what they meant specifically.

For me, good coding style largely means fitting in with the team. You do things that help the team, you don't assert your way over the team's way, and so on. Sure, there's room to suggest things to help the team out, but by fitting in, you help others help the product.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

sam_benne
post 2 May, 2008 - 03:06 AM
Post #4


D.I.C Head

Group Icon
Joined: 16 Jan, 2008
Posts: 148

i just find indenting the code and giving each part a title (by comment) so that later on if i have to do anything to it, it is easy to find what i am looking for.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

baavgai
post 2 May, 2008 - 04:10 AM
Post #5


Dreaming Coder

Group Icon
Joined: 16 Oct, 2007
Posts: 1,078

Everyone has an opinion of which styles are best, but good programming style is universal: consistency. Everything must be consistent. If it's consistent you can tell whats happening from one point to the next, even if you don't like the style the programmer uses. Another element that's considered universally good; variable names that mean something.

As no2pencil noted, what's fresh and obvious today won't be in the passage of time. If you program so others can at least follow along it will help you greatly when you haven't looked at it for so long that you're the other.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

JasonMcAuley
post 3 May, 2008 - 07:44 AM
Post #6


D.I.C Head

**
Joined: 10 Apr, 2008
Posts: 123

Just keeping your code well organized; easy to follow; well documented/commented. What is considered good "style" can really depend on the person though.
User is online!Profile CardPM
Go to the top of the page
+Quote Post

mikeblas
post 3 May, 2008 - 09:37 AM
Post #7


D.I.C Head

**
Joined: 8 Feb, 2008
Posts: 94

QUOTE(JasonMcAuley @ 3 May, 2008 - 07:44 AM) *
What is considered good "style" can really depend on the person though.
Indeed, after a certain point, it's very much arbitrary. Most of the teams I've been on which have had long discussions about style have had much more serious problems that should have been attended to long before the matter of style came up.
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

polymath
post 4 May, 2008 - 02:23 PM
Post #8


D.I.C Head

Group Icon
Joined: 4 Apr, 2008
Posts: 78

I agree that style is arbitrary, though my interpretation of good style is code that is as concise as possible and as easy to follow as possible. This can include how you go about solving your problems presented, comments, structure, identifiers, indentation, anything.

Second on no2pencil, if i didn't comment and indent, i couldn't understand my code 2 hours from now (no joke).

BTW: My style sucks, kudos for you (not literally)

PS: for those of you who have seen any of my questions, you see my impossible to follow logic (w/o comments, i can't follow my own logic). Man i'm jealous.

This post has been edited by polymath: 4 May, 2008 - 02:24 PM
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

mikeblas
post 4 May, 2008 - 07:34 PM
Post #9


D.I.C Head

**
Joined: 8 Feb, 2008
Posts: 94

QUOTE(polymath @ 4 May, 2008 - 02:23 PM) *

I agree that style is arbitrary, though my interpretation of good style is code that is as concise as possible and as easy to follow as possible. This can include how you go about solving your problems presented, comments, structure, identifiers, indentation, anything.
I guess that's where I disagree. Style is not implementation; implementation includes how the problem is solved. Style involves formatting, naming, and so on. It's prefectly arbitrary.

Some teams try to enforce implementation requirements; using anonymous global namespaces instead of statics, for instance; or using exceptions or not. these vague admonitions generally have reasons based on some requirements of the architecture. For example, the memory manager can't handle exceptions, or an analysis tool gets sick when there are too many static variables.

Beyond that, I've never worked on a team that did any real enforcement for implementation rationale. It would be an interesting experiment--it would seem like it wouldn't result in any productivity gain, though, does it?
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 5/17/08 06:23AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month