Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I started teaching myself programming half a year ago, and I've noticed I keep using a few basic techniques over and over again, is this the onset of a style or just ignorance of variation?

share|improve this question
7  
Probably a little of each –  Paul R Aug 30 '11 at 19:19
2  
What are the 'few basic techniques' you are using? –  Gary Willoughby Aug 30 '11 at 19:24
1  
That's an interesting question (potentially). Could you please elaborate a little bit? What basic techniques you are talking about? –  Yann Trevin Aug 30 '11 at 19:27

6 Answers 6

It's a little of both. For example, some people swear by:

if () {
    // do something
}

whereas others only use:

if () 
{
    // do something
}

That's programming style. For a rookie coder, however, ignorance of variation is certainly a factor. You emulate the style you see, and you probably won't change it around unless you see another structure that you like.

share|improve this answer
4  
<flamewar>The first one is the only right way to write braces! (not really trying to start a flamewar) –  Malfist Aug 30 '11 at 19:54
    
It's funny 'cause I catch myself doing both ways, sometimes in the same source file. –  Jetti Aug 30 '11 at 20:15
8  
I disagree, I use the second. It makes sense to have all the braces match up. However, both are equally valid. –  AngryBird Aug 30 '11 at 20:25
    
Why do we even need braces at all? Let's just use whitespace! –  Ivan Aug 30 '11 at 22:47
4  
It is not a programming style, it is a code formatting style. IMHO programming style is when, for example, you tend to follow some of the SOLID principles as you write your code (as opposed to re-factoring to them later on). –  Den Aug 31 '11 at 9:10

Half a year is not a very long time. My advice would be to keep reading books on programming and software development. No matter what language you are using or what kind of programs you are writing, by reading books you are going to find out just how much you do not yet know. Oh, and you will also find out whether the techniques you are using are the onset of style or beginner's mistakes.

share|improve this answer

Yes, it means that you believe that the code you wrote needs nothing more. When you're going to develop something more complicated, you automatically search after better methods to solve your problem.

Also:

After a while you are going to be tired of writing the same over and over again and you are going to search new methods to do the same faster. When I started scripting in PHP I made everything myself. After a couple of years I was so tired of it that I searched for a solution. This is were frameworks came in.

After using my first framework I had the feeling I could speed up even more, and start searching again and found even a more complicated framework that does even more then the first one.

Moral of my story:

Now after all these years my style improved just by exploring new things and read a lot of books and tutorials and so I developed my "own" style. But this style is continuous changing, this keeps programming a challenge too.

PS: I set my brackets on a newline I think it's cleaner! :)

share|improve this answer
1  
Disagree on the 'your code needs nothing more'. I'd rephrase it to 'You /believe/ your code needs nothing more', but that may not be correct, or not correct in every case. –  Cthulhu Aug 30 '11 at 20:13
    
I set my brackets on the same line because my IDE likes it that way. –  Derek Aug 30 '11 at 20:13
    
@Cthulhu good comment! Going to edit it right away! –  Vince V. Aug 30 '11 at 20:15
    
@Deza My IDE did it, but I changed it ;) –  Vince V. Aug 30 '11 at 20:16
    
I've been in a place in which a person had to change all of the brackets to his preferred style before he could even think about reading the program. –  Derek Aug 30 '11 at 21:08

It depends. Have you tried different styles? Have you ever pondered about the advantages and disadvantages of these habits of yours? Have you read some articles about the techniques and styles you use (there should be quite a lot of them) for inspiration about those advantages and disadvantages?

Habits are only good or bad if you've given the habits actual thought, instead of just copying them from others and assuming they're good. Be critical and think things through, but don't be /too/ critical either and doubt yourself all the time.

share|improve this answer

When all you have ever used is a hammer, ever problem looks like a nail. Once you have been introduced to a screw driver, you see screws for what they are.

The same thing happens when programming. If all you are exposed to is a certain style of programming, you will naturally develop a tendency to work in that style. As you gain more experience, you will start to see more different styles, particularly ones suited to different problem sets and languages.

Over time, you will eventually start to derive your own style from your experience, but it usually takes a few years solving different problems in different languages.

Right now, I am going to guess you are still walking around with a hammer. In time, you will have a full set of tools and you will really start to have your own style in how you write code, design your software, and even do your work.

share|improve this answer

After doing anything for a prolonged period of time, one will eventually a style of his/her own. It is common in programming, it is common in poetry writing ... in anything really.

Were I you, I wouldn't worry about style at this point ... it's useless trying to work on something from which you've no use at all, and it will just seem unnatural, until you figure out for yourself the advantages and disadvantages of some of them. Worry about functionality and how to get things done, ... just write ... if your code is useful, nobody will argue about how it looks (well, maybe some will but don't listen to them ...) - if it's not, nobody will care anyway.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.