What Do You Guys Think of How I Programmed This?

Started by
13 comments, last by superman3275 11 years, 6 months ago
I have a whiteboard, well a few whiteboards! I will often draw out what I want my code to do before I even write a line. You can do the same on a piece of paper as well, or even in MS Paint with a tablet, or mouse.

Also you should start to use these:

//

/*
*/


Regardless of who reads your code, you need to make it a practice to comment code.

Example:

// Add two values and return the sum
int Add(int a, int b)
{
return (a + b);
}


Note: /* */ is for multiple lines, example:

/*
This
is
all
comment code!
*/


So you don't have to use // each line.
GameDev Journal: http://www.gamedev.n...-rooks-journal/

OpenChess - 1.0 done!

Classic RPG #1 - Task 9 -> January 1st 2013
Advertisement

AlexB.hpp, considering your new to the forum I'm not going to get mad at you, but who are you to be talking like you're an expert in C++? It doesn't matter if pointers are more flexible then references, I don't need pointers and I don't plan to use their harder to understand syntax. Also, you should probably realize I AM USING A LIBRARY CALLED SFML AND OMG I'M USING BOUNDING BOX COLLISION. That's why I can't "refactor" my code, and that's probably why you don't understand this:
LogicBall->GetCollision().Intersects(LogicBoard[index]->GetTop())

If you actually used SFML you would know what was going on. You also just signed up for the forum, so I suggest you stop telling people in the beginners
section that their code is:
this if is freaking terrible[/quote]

I'm in the beginners section, do you expect "your" quality code.(That's considering your an actual developer, which I doubt you are.)

I'm saying that if Collision(A bounding box rectangle) intersects one of my blocks I set that block to being hit. If you knew what you were talking about you might understand that.

BUT,

Your interface Manager idea is smart, and I might implement it later. Thank you for your input, just please be less harsh on people in the beginners section.
[/quote]

Wow, reading this response officially makes we never want to help you, ever.

Generally when asking for criticism, it is bad form to jump down someones throat for giving it. You came across as a world class d-bag there.

For the record, the Manager is a bad idea, it adds a layer of unneeded, and most probably, not fully understood abstraction to a design. You are in the learning phases, adhere to the KISS principle of Keep It Simple Stupid. That said, even after you move beyond the learning phase, any class named "Manager" should be a code smell of sorts, setting off your spidey-sense that you are creating a bad design. No, Manager!=Bad, at least, not always, but it very often is.

Also, references should pretty much always be preferred over pointers, until you have a very good reason to act otherwise.
Hello superman. I have read your code, here is my opinion.

Why not implement GameLogic, MainGame, and GameMain as normal functions? Assuming you are only going to have only one instance of each.

There are some magic numbers lying around, like these:

Board.resize(20);
for (int index = 0; index < 20; ++index)


What do those 20's mean? Do they mean the same thing? It would be good if you can assign them to constants, it will make life easier for you if you suddenly decide to change that number. It will also make the code easier to understand.

Also, more comments would be great, I think. Preferably a comment for every method/function and variable in the header file, and a comment for the very long expressions and statements. This will be help the people reading your code to understand them better, and also remind yourself what the functions/methods do if you forget in the future.


This code is officially dead, I'm going to try something simpler before attempting breakout again. My interface is awful (As the guy above pointed out), and I didn't plan my code at all. I'm going to try to become a better programmer by taking a smaller step, because I bit off more than I could chew.


I think you should continue with it. It is good way to get better at coding, as good as reading tuts and taking lessons. Start from coding the small objects, like Ball, and make them as close to bugfree as possible. Then work your way up to the logics and graphics stuff.

AlexB.hpp, considering your new to the forum I'm not going to get mad at you, but who are you to be talking like you're an expert in C++? It doesn't matter if pointers are more flexible then references, I don't need pointers and I don't plan to use their harder to understand syntax. Also, you should probably realize I AM USING A LIBRARY CALLED SFML AND OMG I'M USING BOUNDING BOX COLLISION. That's why I can't "refactor" my code, and that's probably why you don't understand this:
LogicBall->GetCollision().Intersects(LogicBoard[index]->GetTop())

If you actually used SFML you would know what was going on. You also just signed up for the forum, so I suggest you stop telling people in the beginners
section that their code is:
this if is freaking terrible[/quote]

I'm in the beginners section, do you expect "your" quality code.(That's considering your an actual developer, which I doubt you are.)

I'm saying that if Collision(A bounding box rectangle) intersects one of my blocks I set that block to being hit. If you knew what you were talking about you might understand that.

BUT,

Your interface Manager idea is smart, and I might implement it later. Thank you for your input, just please be less harsh on people in the beginners section.
[/quote]

Sozz dude, looks like I was a little bit mean.

I'm not an expert but I'm trying to get some experience too. So that's why I wanna give you a little review.
Would you agree if guys will give you some feedbacks on your code to improve it. Your code looks really difficult to understand.

Did you just begin or not, it doesn't matter, 'cause you HAVE to write good code.

Let me tell what I call good code. Good code - when you send it to another programmer with enough skill, he can understand and modify it after few hours of reading.
Sooo that's why I said that that some part of your code freak me out. But ofc your code can be OK.

My suggestion - keep dev it, 'cause you've got nice feedback on it.
C x 2 C x o C x C f nice C x C s C x C c

[quote name='superman3275' timestamp='1350264118' post='4990203']
AlexB.hpp, considering your new to the forum I'm not going to get mad at you, but who are you to be talking like you're an expert in C++? It doesn't matter if pointers are more flexible then references, I don't need pointers and I don't plan to use their harder to understand syntax. Also, you should probably realize I AM USING A LIBRARY CALLED SFML AND OMG I'M USING BOUNDING BOX COLLISION. That's why I can't "refactor" my code, and that's probably why you don't understand this:
LogicBall->GetCollision().Intersects(LogicBoard[index]->GetTop())

If you actually used SFML you would know what was going on. You also just signed up for the forum, so I suggest you stop telling people in the beginners
section that their code is:
this if is freaking terrible[/quote]

I'm in the beginners section, do you expect "your" quality code.(That's considering your an actual developer, which I doubt you are.)

I'm saying that if Collision(A bounding box rectangle) intersects one of my blocks I set that block to being hit. If you knew what you were talking about you might understand that.

BUT,

Your interface Manager idea is smart, and I might implement it later. Thank you for your input, just please be less harsh on people in the beginners section.
[/quote]

Sozz dude, looks like I was a little bit mean.

I'm not an expert but I'm trying to get some experience too. So that's why I wanna give you a little review.
Would you agree if guys will give you some feedbacks on your code to improve it. Your code looks really difficult to understand.

Did you just begin or not, it doesn't matter, 'cause you HAVE to write good code.

Let me tell what I call good code. Good code - when you send it to another programmer with enough skill, he can understand and modify it after few hours of reading.
Sooo that's why I said that that some part of your code freak me out. But ofc your code can be OK.

My suggestion - keep dev it, 'cause you've got nice feedback on it.
[/quote]
I'm sorry, it was late at night when I made that post. I guess I was annoyed because of all the time I had invested, and when you criticized me that harshly I just felt like all my work was for nothing.

I'm a game programmer and computer science ninja !

Here's my 2D RPG-Ish Platformer Programmed in Python + Pygame, with a Custom Level Editor and Rendering System!

Here's my Custom IDE / Debugger Programmed in Pure Python and Designed from the Ground Up for Programming Education!

Want to ask about Python, Flask, wxPython, Pygame, C++, HTML5, CSS3, Javascript, jQuery, C++, Vimscript, SFML 1.6 / 2.0, or anything else? Recruiting for a game development team and need a passionate programmer? Just want to talk about programming? Email me here:

hobohm.business@gmail.com

or Personal-Message me on here !

This topic is closed to new replies.

Advertisement