Jump to content
  • Advertisement
Sign in to follow this  
Nickie

Writing good code based on good architecture

This topic is 1881 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone.

I'm catching a bad tendency about my code. Short after the piece of software grow at 20-25+ files the code seems to be hard to follow and understand. But with proper comments I can remove the last statement "understand".

I'm trying to use some kind of patterns to achive better code however everything end up a big mess at the end.

So... I fail to hide the complexity in my code. However I don't know how to google about books on the subject. I'm not native english speaker and I canno find good keywords.

 

My question is: Can you recommend me a good book that can help me write good code?

Share this post


Link to post
Share on other sites
Advertisement

Wouldn't it be better to find a book on the subject in your native language?

 

not as easy as you think. Most books with very specific topics don't get translated at all.

 

To answer the question.. it's all a matter of experience, you try a way and sooner or later in the project it'll fall apart under the weight of the project... from that point it's hackage time.. you can't plan for the unknown. The good news is that your next project will be better, because you know more about what you'll eventually need and the level at which the structure will fall will get higher.

 

The best bet is to have a look at what others are doing.. I found Unity3D a very good inspiration point for what I wanted my engine to "look like" from the outside.

 

Some books I'd recommend are Game Coding Complete and Game Engine Architecture... plus, the usual good practices and pattern books from the usual suspects.

Share this post


Link to post
Share on other sites

Well, I my problem is that I cannot find a good book, because I don't know what keywords to use to the search engine, for example.

I don't have problem understanding english tech literature.

I've already read game coding complete. The guys seem to know what are they talking about. And still many of the stuff is not suitable for real world code.

Game Engine Architecture - Thats was my next choice after GCC. Well, I guess most of the stuff were already coverted in GCC and it was really easy book. The only thing that I didn't know about was the character animation.

Currently I'm reading a random book on design patterns hoping it will help me produce good code.

 

Khatharr - nope. There is only one or two books about programming(in general) in my native language. Even the student's books in school about programming related classes are in english.

 

P.S. If everything I need is experience then thats good. I already coded one engine(completely refactored/rewritten 3 times) and I guess I'm getting better and better. I was just looking for a way to speed up the process.

From my point of view: Code can always be better. Even after I have passed the stage "everything should be perfect" I still have the feeling I miss something.

Share this post


Link to post
Share on other sites

Ah, I had thought that programming books would be pretty widely available in other languages. Now that I think about it, even programming languages designed by people that speak other languages tend to be designed in English. I don't know any good books on architecture off the top of my head. I think it's something that you mostly have to learn the hard way, but I'd be happy if proven wrong.

Share this post


Link to post
Share on other sites

I agree with the "you'll get it through experience" opinion, but I have one piece of advice to share.

One thing that helps me a lot is paying attention to interfaces between parts of the software. If you write a library of some sort (especially one that other people will use), you'll have to provide a good interface for the user: It needs to be clean and consistent, and it needs to hide the messy parts of how things are implemented. Once you are used to this mindset, you can let it permeate your entire code, and then it will be understandable in smaller chunks.

More generally, you need to program with other people. You need to annoy them with your bad code and you need to be annoyed by theirs. That's the best way I know to learn that code needs to be clear, and what clear enough means.

I spent about 10 years taking care of a complicated production system for a financial firm, and sometimes I had to fix things quickly, or we would lose tons of money. A co-worker described "clear-enough code" this way: You need to be able to get up at 3am when it breaks, read it, fix it, and wake up in the morning without remembering anything. smile.png

Edited by Álvaro

Share this post


Link to post
Share on other sites

Keep writing code. Eventually you get to the point where you can restructure in a way that it will look much nicer than it was before. 

 

As a side note: avoid duplicated code which involves restructuring the code until you get to the point where you do not see the duplication.

 

Book are nice as references but programming is a skill that comes with experiencing it everyday. 

Edited by warnexus

Share this post


Link to post
Share on other sites

P.S. If everything I need is experience then thats good. I already coded one engine(completely refactored/rewritten 3 times) and I guess I'm getting better and better. I was just looking for a way to speed up the process.

http://www.mainewingchunkungfu.com/article6.htm A story that was passed on to me a long time ago, whose message I've never really forgotten.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!