Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (497)
Games in Android Showcase (114)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Coding like its for other people  (Read 1576 times)
0 Members and 1 Guest are viewing this topic.
Offline lcass
« Posted 2014-04-19 18:03:01 »

Does anyone else program in a way thats not really just for you but you program so that its easy for other people to modify , sort of API style. Ive been doing this basically Im programming in a modular fashion for example when I call an interact function on a block it doesnt return specific information (multiple return methods) it instead returns a datapack.
Offline Drenius
« Reply #1 - Posted 2014-04-19 18:05:31 »

Explain further what you mean.
Offline Rayvolution

JGO Kernel


Medals: 199
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #2 - Posted 2014-04-19 18:19:59 »

Professionals code with the intent others down the line will need to modify their code when they're long quit/fired/retired.

As for us amateurs, it's not critical unless you're working as a group. But I still think it's good practice, even if just for yourself. I add tons of comments in my code explaining everything, and I try to keep all my code generally built the same way. Reason being when you get into larger projects, no matter how awesome you think you are, you WILL forget how your own code works if you don't touch an area of it for months. Tongue

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline lcass
« Reply #3 - Posted 2014-04-19 18:49:29 »

Hmm thats something I dont do , I generally dont add comments to the sections of code that I dont think need editing. I only really add them if its for say a Tile or graphics object definition , I also write them if its a class that will be updated in the future. For example to expand this, I have written a logger that I will only really use to debug small sections of code but it would prove very useful for someone new using the code. Therefore I am coding to aid someone else who I have no intent to work on the project.
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #4 - Posted 2014-04-19 23:51:37 »

If you are coding for someone else, commenting your functions and code is crucial. Also, having JavaDocs (if using Java) or something similar (like a good ReadMe section) does leagues for understanding code.

I think one of the biggest issues I've seen in a lot of indie projects (mine included) is the best way to set up folders for easy navigation. When trying to wrap your head around where to put certain code in folders, there is nothing that comes to me as natural. It seems like a bunch of trial and error, which really is harmful in any coding project with many people.

I never got the point of all that
com.blah.system.game
for folder decoration. As far as I know it usually makes a pretty deep one way tree with no real advantage. Maybe it was a left-over functionality from business applications...

Offline Cero
« Reply #5 - Posted 2014-04-20 02:32:31 »

I never got the point of all that
com.blah.system.game
fr folder decoration. As far as I know it usually makes a pretty deep one way tree with no real advantage. Maybe it was a left-over functionality from business applications...

Yeah.
 I recently wrote a SDK at work, and for 3rd party code it makes sense of course.
But for a game I will just call the packages "physics", "map", "game" ,"util", I dunno whatever makes sense

Offline lcass
« Reply #6 - Posted 2014-04-20 09:32:09 »

well the com.... is like a convention in java such as is using int i for unknown variables or using x and y for coordinates (not really just java but an example). The way java packages also does require some sort of main package otherwise code goes into wrong folders and is a bitch to try to access.
Offline Danny02
« Reply #7 - Posted 2014-04-20 09:53:12 »

It's called the Reverse domain name notation and is used to prevent naming collisions.
Offline princec

JGO Kernel


Medals: 378
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #8 - Posted 2014-04-20 10:24:46 »

Code for the future you.

Cas Smiley

Offline Roquen
« Reply #9 - Posted 2014-04-20 13:31:32 »

What cas said...and if you're putting more effort into then that...you're wasting your time.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline ags1

JGO Ninja


Medals: 62
Projects: 3
Exp: 5 years


Make code not war!


« Reply #10 - Posted 2014-04-20 15:39:45 »

Some things just take no extra effort anyway, like the reverse domain convention, or good style within classes. So why not follow the conventions? Dirty code hides a lot of bugs.

Offline Rayvolution

JGO Kernel


Medals: 199
Projects: 2
Exp: 1 year


Resident Crazyman


« Reply #11 - Posted 2014-04-20 16:05:20 »

Some things just take no extra effort anyway, like the reverse domain convention, or good style within classes. So why not follow the conventions? Dirty code hides a lot of bugs.

and when you learn new conventions you may not of been aware of previously, go back and fix your code! Tongue

For example, a long while back I was unaware that static variables SHOULD_BE_NAMED_LIKE_THIS instead of shouldBeNameLikeThis. So I went back and refactored all my code to match. Of course, I don't have many statics so that wasnt really a problem. But still; should keep as close to the industry standards as possible, even in your own code.

- Raymond "Rayvolution" Doerr.
Retro-Pixel Castles - Survival Sim/Builder/Roguelike!
LIVE-STREAMING DEVELOPMENT: http://www.twitch.tv/SG_Rayvolution
Offline Roquen
« Reply #12 - Posted 2014-04-20 16:05:51 »

reverse domain convention = more typing for no gain if you're not a public library (et al) so why bother?  Clean code doesn't need to be written for consumption by others.  These are different issues.
Offline tom_mai78101
« Reply #13 - Posted 2014-04-21 17:16:46 »

Question:

If you're creating a small game project, do you actually create a specifications first before coding it out?

For instance, I created my specifications for my project. Do you think this is a bit overkill, or this is perfect for my future me to code if I want to continue the project in the future?
Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #14 - Posted 2014-04-21 18:07:36 »

Erm, specifications are good but they can also change.

If you write too much you may feel attached and unwilling to change them. If a better way comes along, then you will not be able to easily change it. I guess what I'm saying is do everything in moderation. I like writing the specifications alongside or after the process just in case I want to change something, I'm not in too deep.

Offline Grunnt

JGO Wizard


Medals: 68
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #15 - Posted 2014-04-24 08:23:26 »

If you are coding for someone else, commenting your functions and code is crucial. Also, having JavaDocs (if using Java) or something similar (like a good ReadMe section) does leagues for understanding code.

By far the best approach is to use as few comments in your code as possible and make your code self-explanatory. Comments tend to "rot", in that most developers forget to update comments when they alter the code. So either comments cause a lot of double work, or they cause confusion. You can avoid this by using clear descriptive names for methods, variables etcetera, and by stucturing your code well (also KISS).

Here's a great article on how to be a great software dev:
http://peternixey.com/post/83510597580/how-to-be-a-great-software-developer

Offline ctomni231

JGO Wizard


Medals: 99
Projects: 1
Exp: 7 years


Not a glitch. Just have a lil' pixelexia...


« Reply #16 - Posted 2014-04-24 17:02:42 »

Here's a great article on how to be a great software dev:
http://peternixey.com/post/83510597580/how-to-be-a-great-software-developer

I actually enjoyed this article a lot. It touched on a lot of issues that plagues developers (even if they are too bold to admit it). The issues touched on are invaluable like knowing whether testing has a limit, having a feel on your contributions to the team, and knowing how to design good or bad code.

In my opinion, though, even variable verbosity can get to the point of where it is overboard. As a developer, it takes a lot more time to think about what makes for a good variable name, and some people have a varying sense to what makes it good.

 this_post_taking_too_long = true 
is great for knowing what it does, but then we end up having code that
 is_nightmare = true 
in loops and nested functions. Sometimes just using
i
instead of
index
is better and more elegant.

Programmers definitely are lazy though. They'd be just as unwilling to change a bad variable, function, or class name as they would the comments that accompany them. It is still up to the programmer to make sure they are following up on their work and being vigilant.

Offline Grunnt

JGO Wizard


Medals: 68
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #17 - Posted 2014-04-25 13:39:20 »

There's always another nuance to be made Wink Thats the real value of experience, and something that cannot be learned from books: nuance. Yeah, using undescriptive short variable names is bad. But using variable names like
1  
int thatVariableThatDoesHelpCountTheOtherThingCalledFoodBySomeButEdiblesByOthers = 0;

isn't really optimal either.

Being experienced means you know how to maintain a balance between short and long names, between too little and too much testing, between making a quick fix or a thorough solution. How the balance plays out can never be caught in simple rules that you read in tutorials or learn at school like "never use short variable names!" or "always test your code extensively!" It depends on your ability to instantly weigh a huge set of contextual parameters, which is only learned through experiencing many different contexts.

Offline Grunnt

JGO Wizard


Medals: 68
Projects: 8
Exp: 5 years


Complex != complicated


« Reply #18 - Posted 2014-04-25 13:41:12 »

Funny thing is, programming in this sense is very much communicating with people, and not just communicating with computers.

Offline Oskuro

JGO Knight


Medals: 39
Exp: 6 years


Coding in Style


« Reply #19 - Posted 2014-05-05 12:46:38 »

Code for the future you.

In my experience, coming back to my own code, specially in large projects, can be daunting. So I do code "for other people" if only so future me doesn't jump out the window when trying to understand old stuff.

Pages: [1]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

BurntPizza (22 views)
2014-09-19 03:14:18

Dwinin (37 views)
2014-09-12 09:08:26

Norakomi (65 views)
2014-09-10 13:57:51

TehJavaDev (91 views)
2014-09-10 06:39:09

Tekkerue (45 views)
2014-09-09 02:24:56

mitcheeb (66 views)
2014-09-08 06:06:29

BurntPizza (49 views)
2014-09-07 01:13:42

Longarmx (36 views)
2014-09-07 01:12:14

Longarmx (42 views)
2014-09-07 01:11:22

Longarmx (38 views)
2014-09-07 01:10:19
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!