Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Writing Good Code  (Read 9839 times)

0 Members and 2 Guests are viewing this topic.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Writing Good Code
« Reply #15 on: July 17, 2013, 09:55:28 pm »
I was wondering about this but is this why in the code that the book provides they've made seperate headers/files for all the main functions? I was wondering why that was, it does look a lot neater but I still think it's a bit disorganised somehow but I guess that's because I don't know the full thing yet.
What book are you referring to? SFML Game Dev?
It's a common and good practice to separate declarations and definitions and keep the code files as small as needed. Functions shouldn't contain hundreds of lines, but should be kept minimal, that way you'll get a very clean code base. You might get a few more files etc, but if you need to find a specific section it's much easier to locate.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Lethn

  • Full Member
  • ***
  • Posts: 133
    • View Profile
Re: Writing Good Code
« Reply #16 on: July 17, 2013, 10:06:36 pm »
Yes the SFML game dev book, I've been looking at the source code occasionally as well as reading through the chapters :D I can understand the reasoning behind how it's set up now looking at the example code that was posted here.
« Last Edit: July 17, 2013, 11:26:45 pm by Lethn »

joshua1984

  • Newbie
  • *
  • Posts: 13
    • View Profile
Re: Writing Good Code
« Reply #17 on: July 18, 2013, 11:32:18 pm »


I love bucky! His videos got me started in programming after I quit c++ for a while(because I had spent days and days trying everything in my power to understand pointers, but alas at the time nothing would click) and decided to learn java. After I started joining some professional communities like stackoverflow and started talking to people who actually knew what they were doing I realized that thenewboston really didn't understand java, and a lot of things weren't clicking to me because he skipped the difficult pieces without telling me why he wrote certain methods, also some of his java is fairly outdated and outright incorrect for example: He often overrode paint in top level containers, which is a BIG nono in java. Also I hope you weren't trying to learn c++ from cplusplus.com, there are some fairly outdated and overcomplicated examples on that site, mostly when it comes to pointers and dynamic allocation.

I think you should pick up a good book on the Basics of C++, after you've got the basics down and have a good understanding of the basic things to do and not to do start using the internet. You can learn how to do pretty much anything coding related through google. Let me ask you a question though:
Why are you wanting to learn C++? From the context of your questions it doesn't sound like you are a CS or CE major(perhaps I am incorrect). I'm going to give you a common list of reasons people want to learn programming and some things you can do that will keep you interested in the language. I've always hated reading, but loved the knowledge gained from reading, I'm slightly ADHD so focusing long enough to read books has always been a struggle for me, but I am self disciplined so when it comes to school I force myself.


1)A lot of people just want to learn how computers work.
Try learning some general Windows API(If you're running on windows) and than after you've got some of that stuff down try learning assembly, through learning assembly you really gain a deep insight on how things work.

2)Game Development
You're pretty much in the right place for that. Look through the tutorials, come up with your own ideas, learn how to use this library, also still consider learning how SFML operates as it could be valuable if you ever decide to write your own game engine or work with other libraries/languages. Also if you want to learn how to hack online games(Hacking as in gaining an unfair advantage, not as in Cracking passwords and such) learning some assembly/disassembly and WinApi would definitely help(Consider Reading up on Dll injection).

Let me note: Learning Windows Application Programming Interface is not practical for leisure programming in most cases. It's rewarding to learn but with all the libraries like SFML  and such one could argue that its unnecessary for writing general purpose applications.

3) Artificial Intelligence
Consider watching some College lectures on youtube when it comes to this. These people know what theyre talking about 80% of the time and you can really learn a lot(I know its not the most exciting way to learn something so amazing)

MSDN is pretty much the documentation for winapi most questions you have can be answered by reading the documentation.

 

anything