• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 07:59
CEST 13:59
KST 20:59
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL21] Ro16 Preview Pt2: All Star10Team Liquid Map Contest #22 - The Finalists14[ASL21] Ro16 Preview Pt1: Fresh Flow9[ASL21] Ro24 Preview Pt2: News Flash10[ASL21] Ro24 Preview Pt1: New Chaos0
Community News
2026 GSL Season 1 Qualifiers12Maestros of the Game 2 announced52026 GSL Tour plans announced14Weekly Cups (April 6-12): herO doubles, "Villains" prevail1MaNa leaves Team Liquid23
StarCraft 2
General
MaNa leaves Team Liquid Maestros of the Game 2 announced 2026 GSL Tour plans announced Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool Team Liquid Map Contest #22 - The Finalists
Tourneys
2026 GSL Season 1 Qualifiers GSL CK: More events planned pending crowdfunding RSL Revival: Season 5 - Qualifiers and Main Event Sparkling Tuna Cup - Weekly Open Tournament Master Swan Open (Global Bronze-Master 2)
Strategy
Custom Maps
[D]RTS in all its shapes and glory <3 [A] Nemrods 1/4 players [M] (2) Frigid Storage
External Content
Mutation # 522 Flip My Base The PondCast: SC2 News & Results Mutation # 521 Memorable Boss Mutation # 520 Moving Fees
Brood War
General
https://www.facebook.com/IonShieldAirPurifier/ ASL21 Strategy, Pimpest Plays Discussions [ASL21] Ro16 Preview Pt2: All Star Data needed BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[ASL21] Ro16 Group D [ASL21] Ro16 Group C [ASL21] Ro16 Group B [Megathread] Daily Proleagues
Strategy
Simple Questions, Simple Answers What's the deal with APM & what's its true value Any training maps people recommend? Fighting Spirit mining rates
Other Games
General Games
Dawn of War IV Starcraft Tabletop Miniature Game Nintendo Switch Thread General RTS Discussion Thread Battle Aces/David Kim RTS Megathread
Dota 2
The Story of Wings Gaming
League of Legends
G2 just beat GenG in First stand
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug Heroes of StarCraft mini-set
TL Mafia
Vanilla Mini Mafia Mafia Game Mode Feedback/Ideas TL Mafia Community Thread Five o'clock TL Mafia
Community
General
US Politics Mega-thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club
Media & Entertainment
Anime Discussion Thread [Manga] One Piece [Req][Books] Good Fantasy/SciFi books Movie Discussion!
Sports
Formula 1 Discussion 2024 - 2026 Football Thread McBoner: A hockey love story Cricket [SPORT]
World Cup 2022
Tech Support
[G] How to Block Livestream Ads
TL Community
The Automated Ban List
Blogs
Sexual Health Of Gamers
TrAiDoS
lurker extra damage testi…
StaticNine
Broowar part 2
qwaykee
Funny Nicknames
LUCKY_NOOB
Iranian anarchists: organize…
XenOsky
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1209 users

The Big Programming Thread - Page 627

Forum Index > General Forum
Post a Reply
Prev 1 625 626 627 628 629 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Propelled
Profile Joined October 2010
Denmark184 Posts
May 02 2015 21:41 GMT
#12521
Thanks for the suggestions, I'll be trying them out.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
May 02 2015 23:08 GMT
#12522
--- Nuked ---
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
May 02 2015 23:20 GMT
#12523
From my experience, should be documenting code while you write it before you have and before you complete code reviews. Code + technical design documents should be enough to explain why the code exists the way that it does. Never really saw the point in excessive documentation except for very important files (because that way when I see a file with a couple long paragraphs at the top I know that it's important).

What are you documenting that takes so long?
There is no one like you in the universe.
Nausea
Profile Joined October 2010
Sweden807 Posts
May 03 2015 02:25 GMT
#12524
I'm a noob and thinking of trying to put together a bejeweled game to learn from. (In c++)
I just thought I might ask here what container i may want to use for the jewels, since I guess I will have to remove and move and add stuff very often.

Set it ablaze!
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-05-03 03:02:04
May 03 2015 02:58 GMT
#12525
If you can do it in something better than a 2D array of pointers I'd be very surprised.
There is no one like you in the universe.
meatpudding
Profile Joined March 2011
Australia520 Posts
May 03 2015 03:03 GMT
#12526
On May 03 2015 11:25 Nausea wrote:
I'm a noob and thinking of trying to put together a bejeweled game to learn from. (In c++)
I just thought I might ask here what container i may want to use for the jewels, since I guess I will have to remove and move and add stuff very often.



I don't know the game, but....

An array, or if you like a std::vector.

Both can be set up with the size that you need, in this case the size never changes. If you have a blank spot, just fill it with a blank element.

You can access both types of containers in constant time. The trick is whether you decide to use 2d co-ordinates or 1d. Even though 2d would seem natural, 1d works just as well or better.

For example:

JewelType* myArray = new JewelType[height * width];
JewelType* aJewelInTheArray = myArray[x + y * width];
Be excellent to each other.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2015-05-03 03:32:05
May 03 2015 03:08 GMT
#12527
--- Nuked ---
Millitron
Profile Blog Joined August 2010
United States2611 Posts
May 03 2015 04:00 GMT
#12528
On May 03 2015 12:08 Nesserev wrote:
Show nested quote +
On May 03 2015 11:25 Nausea wrote:
I'm a noob and thinking of trying to put together a bejeweled game to learn from. (In c++)
I just thought I might ask here what container i may want to use for the jewels, since I guess I will have to remove and move and add stuff very often.


I think most people tend to go for a 2-dimensional std::vector/array, or perhaps even a map with pairs as keys.

Personally, after having dealt with 'quadrants'(?) far too many times, I think the best option (clean, flexible, most optimal) would be writing your own class that provides all your needs, around a one dimensional std::vector< ... >. It makes iterating rows/columns very easy and clean, and you can just use pointer/iterator arithmetics.

Note that the only case that it's not very good at, is expanding the quadrant in both dimensions. (EDIT: Then you should prefer a 2D vector.)

Show nested quote +
On May 03 2015 08:20 Blisse wrote:
From my experience, should be documenting code while you write it before you have and before you complete code reviews. Code + technical design documents should be enough to explain why the code exists the way that it does. Never really saw the point in excessive documentation except for very important files (because that way when I see a file with a couple long paragraphs at the top I know that it's important).

What are you documenting that takes so long?

I never skip the inline comments, which help a lot during the coding process itself, or organizing/chaptering the code, but when I just want to continue coding, I postpone writing the class and method descriptions, code examples, etc. until later.

I guess I might be a little bit guilty of excessive documentation. It's not like I document the most menial of details, but I tend to write documentation for the user of the classes, and developer/maintenance separately; and when I do, I pretend that the other person is a 5 year old.

I don't think that it's a lot of documentation, it's just that I tend to get annoyed with it really fast. If only documentation was as fun as coding, or well... you could say it's part of coding, just the boring part :S

There's nothing wrong with assuming the next dev is a 5 year old. While getting my CS degree, I came in on so many already-in-progress projects written mostly be people who documented next to nothing. I was somewhat traumatized after spending the better part of a week trying to understand how the UI to our department's robot was implemented. It was seriously a clusterfuck; it had two sentences of documentation, for about 10 pages of code. And was written using a version of XWindows that was obsolete over a decade before, meaning even finding documentation for that was difficult. By the time I understood it, and made the change I wanted to, we had managed to install Java on the robot and the whole project was made pointless. They made a better version of the UI in Java in one afternoon.

So long story short, fuck XWindows and fuck people who don't document.
Please continue assuming the next dev is 5. I'd rather have too much documentation than too little.
Who called in the fleet?
Craton
Profile Blog Joined December 2009
United States17281 Posts
May 03 2015 05:09 GMT
#12529
Workplace code is usually better than school code, though.

Yeah there are bad companies out there, but people in school are consistently bad because most haven't had exposure to why it's important and what's needed for it to be it's useful. At that point, most devs have rarely, if ever, worked on code involving more than themselves. Those that have usually just had a few disparate parts with minimal or no overlap.

You don't need to treat the dev as an idiot, you just need to be clear and descriptive. Write documentation with the thought in mind that you're the one reading it with only a vague idea of what's going on. In practice, there's a pretty good chance a year down the road you will be the one reading it again trying to figure out what's going on.
twitch.tv/cratonz
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
May 03 2015 06:21 GMT
#12530
On May 03 2015 12:08 Nesserev wrote:
I never skip the inline comments, which help a lot during the coding process itself, or organizing/chaptering the code, but when I just want to continue coding, I postpone writing the class and method descriptions, code examples, etc. until later.

I guess I might be a little bit guilty of excessive documentation. It's not like I document the most menial of details, but I tend to write documentation for the user of the classes, and developer/maintenance separately; and when I do, I pretend that the other person is a 5 year old.

I don't think that it's a lot of documentation, it's just that I tend to get annoyed with it really fast. If only documentation was as fun as coding, or well... you could say it's part of coding, just the boring part :S

I try to avoid all inline comments and turn parts that need explanation into separate methods instead. Most of the time that results in many methods that are short, simple and have a descriptive name, so commenting those is kinda redundant, but that also makes it simple to comment.
If you have a good reason to disagree with the above, please tell me. Thank you.
BByte
Profile Joined August 2011
Finland49 Posts
May 03 2015 10:04 GMT
#12531
On May 03 2015 15:21 spinesheath wrote:
I try to avoid all inline comments and turn parts that need explanation into separate methods instead. Most of the time that results in many methods that are short, simple and have a descriptive name, so commenting those is kinda redundant, but that also makes it simple to comment.


I agree with this, breaking methods up often makes for better code anyway and easier documentation is a nice bonus. I also leave redundant comments out.

When reading object oriented code I typically find class level comments much more useful than the method comments. The name should be enough to tell what a method does, and reading the code is usually the best way to figure out the how. With classes the exact purpose is not always clear from the name and unlike good method naming conventions, class naming conventions seem to vary a lot. It's also a lot more work to find out how a class works just by reading the code compared to a method.

In functional code I feel like I need to use even inline comments. I don't see it as a big problem though, the code is often succinct enough that I can spend a few characters and add a line comment.
ZenithM
Profile Joined February 2011
France15952 Posts
May 03 2015 10:19 GMT
#12532
On May 03 2015 12:03 meatpudding wrote:
Show nested quote +
On May 03 2015 11:25 Nausea wrote:
I'm a noob and thinking of trying to put together a bejeweled game to learn from. (In c++)
I just thought I might ask here what container i may want to use for the jewels, since I guess I will have to remove and move and add stuff very often.



I don't know the game, but....

An array, or if you like a std::vector.

Both can be set up with the size that you need, in this case the size never changes. If you have a blank spot, just fill it with a blank element.

You can access both types of containers in constant time. The trick is whether you decide to use 2d co-ordinates or 1d. Even though 2d would seem natural, 1d works just as well or better.

For example:

JewelType* myArray = new JewelType[height * width];
JewelType* aJewelInTheArray = myArray[x + y * width];

Huh, why is it better with 1d? With simple arrays, it's faster to follow 2 pointers rather than compute 1 multiplication and follow a pointer. The 2d array is obviously clearer, AND it's faster. I don't know why you would use a 1d array. C++ is not Java, with reference and boundary checking overheads everywhere :D
netherh
Profile Blog Joined November 2011
United Kingdom333 Posts
Last Edited: 2015-05-03 13:04:14
May 03 2015 12:46 GMT
#12533
On May 03 2015 19:19 ZenithM wrote:
Huh, why is it better with 1d? With simple arrays, it's faster to follow 2 pointers rather than compute 1 multiplication and follow a pointer. The 2d array is obviously clearer, AND it's faster. I don't know why you would use a 1d array. C++ is not Java, with reference and boundary checking overheads everywhere :D


I'd be pretty surprised if the 2d array was faster. And the 1d array is more flexible as you can iterate the whole thing in one loop. It's also much easier to resize, and much less wasteful of memory.

EDIT: Read the answer to this question: http://stackoverflow.com/questions/17259877/1d-or-2d-array-whats-faster

Given that you should want to wrap the thing in a class with a proper interface anyway, there's absolutely no difference in clearness outside the class itself. (And I think it's actually clearer anyway. You just have a GetIndex(x, y) function... all the other different code is shorter and clearer with a 1d array.)
ZenithM
Profile Joined February 2011
France15952 Posts
Last Edited: 2015-05-03 13:22:42
May 03 2015 13:18 GMT
#12534
I don't think the best answer applies to the bejewel case at all, but fine :D
First, static 2D arrays are contiguous in memory, they're not more wasteful, it's actually the same exact amount. I don't think a Bejewel board needs to be resized in-game, so that point is pretty much moot. And plus, even in the case of dynamic arrays, as per the guy's tests, 2D arrays ARE faster at random access (even if just slightly so).

But you're also right that you'll probably want to wrap whatever implementation you end up using in something clean and generic.

To be perfectly clear, it's natural to think that the 1D array-like structures would be faster, but it's really not that obvious that it is. It depends on what actual structure you use, on whether you use static or dynamic arrays, on whether there are boundary checking going on at runtime (like on a JVM), on the amount of optimizations you enable in your compiler and all that. One advantage of 1D structures is that it's much easier to parallelize too.
Zocat
Profile Joined April 2010
Germany2229 Posts
Last Edited: 2015-05-03 16:27:19
May 03 2015 16:26 GMT
#12535
Question: CMake

I have a Cmake file which (should) generates a Visual Studio project file.

Is it possible (if yes, how?) to add a post build event to the generated VS project through the Cmake?
I have found add_custom_command, but I'm not sure if it is what I want (or if it just adds a cmake post build option).

+ Show Spoiler [The stuff I currently have] +


PROJECT (DICOM)

add_custom_command(TARGET DICOM
POST_BUILD
COMMAND xcopy "sourceDir" "targetDir" "/d" "/Y"
)

sourceDir and targetDir are of course other values.

The error I receive is:
"(stuff about policies)
The target name "DICOM" is unknown in this context."
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2015-05-03 18:05:26
May 03 2015 18:03 GMT
#12536
On May 03 2015 12:03 meatpudding wrote:
Show nested quote +
On May 03 2015 11:25 Nausea wrote:
I'm a noob and thinking of trying to put together a bejeweled game to learn from. (In c++)
I just thought I might ask here what container i may want to use for the jewels, since I guess I will have to remove and move and add stuff very often.



I don't know the game, but....

An array, or if you like a std::vector.

Both can be set up with the size that you need, in this case the size never changes. If you have a blank spot, just fill it with a blank element.

You can access both types of containers in constant time. The trick is whether you decide to use 2d co-ordinates or 1d. Even though 2d would seem natural, 1d works just as well or better.

For example:

JewelType* myArray = new JewelType[height * width];
JewelType* aJewelInTheArray = myArray[x + y * width];


Do you expect height * width to be huge to use 'new'? If yes, I still think it's a bad example and that bit should be moved to a RAII class.

Edit: Or use a smart pointer.
Mstring
Profile Joined September 2011
Australia510 Posts
May 04 2015 11:04 GMT
#12537

enum grid_element
{
EMPTY,
SQUARE,
DIAMOND,
//...
}:

grid_element GameGrid[GRID_HEIGHT][GRID_WIDTH];


Keep it simple.
sabas123
Profile Blog Joined December 2010
Netherlands3122 Posts
May 04 2015 12:27 GMT
#12538
After reading/listinging alot to uncle bob im almost getting paraniod about my class structure. And not knowing how to implement my ideas is even worse lol.
The harder it becomes, the more you should focus on the basics.
Blisse
Profile Blog Joined July 2010
Canada3710 Posts
Last Edited: 2015-05-04 15:45:37
May 04 2015 15:27 GMT
#12539
Eh it's much more important to make stuff than it is to make code pretty and structured.
There is no one like you in the universe.
Artesimo
Profile Joined February 2015
Germany571 Posts
May 04 2015 16:32 GMT
#12540
When using list/multilinked lists, should I rather make a class that holds the beginning of the list or should I rather keep the first element of the list as an empty element onyl to find the list? I found both ways used, but the last one seemed odd, but maybe there is some performance-benefit.

Also, when it is practical to group the list elements in some sort (like a dictionary with A,B...), should I create a list for each group, or should I rather use one big list, and have pointer to certain elements stored elsewehere, that simly point to certain locations(like "words with C start here"->)? If I want to use one big list, it seem like having a class that holds this information is best.
Prev 1 625 626 627 628 629 1032 Next
Please log in or register to reply.
Live Events Refresh
Afreeca Starleague
10:00
Ro16 Group D
Barracks vs Leta
Royal vs Light
Afreeca ASL 17266
StarCastTV_EN386
Liquipedia
GSL
08:00
2026 Season 1: Qualifiers
herO vs Rogue
Maru vs SHINLIVE!
Solar vs Zoun
Cure vs TriGGeR
IntoTheiNu 426
CranKy Ducklings SOOP205
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Lowko247
TKL 151
Rex 29
StarCraft: Brood War
Britney 26143
Calm 14343
Jaedong 6379
Sea 5808
BeSt 1595
Rush 1149
Horang2 829
Pusan 497
Mind 340
Zeus 263
[ Show more ]
Hyuk 239
JYJ 180
Larva 157
ToSsGirL 119
Sharp 117
ggaemo 86
Sexy 56
[sc1f]eonzerg 53
Sea.KH 52
Killer 29
Bale 27
Noble 25
Shine 22
Icarus 18
SilentControl 18
GoRush 12
Sacsri 11
JulyZerg 10
Movie 9
Terrorterran 6
eros_byul 1
Dota 2
Gorgc4312
League of Legends
Reynor57
Counter-Strike
zeus1190
x6flipin515
shoxiejesuss423
edward302
markeloff134
Super Smash Bros
Mew2King123
Heroes of the Storm
Trikslyr122
Other Games
singsing2057
B2W.Neo375
Happy287
crisheroes253
XaKoH 216
QueenE51
Organizations
Dota 2
PGL Dota 2 - Main Stream6667
PGL Dota 2 - Secondary Stream6276
StarCraft: Brood War
UltimateBattle 316
StarCraft 2
WardiTV54
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• StrangeGG 3
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• TFBlade1518
Upcoming Events
WardiTV Map Contest Tou…
31m
herO vs Classic
SHIN vs Cure
Solar vs Percival
RSL Revival
22h 1m
Replay Cast
1d 12h
The PondCast
1d 22h
KCM Race Survival
1d 22h
WardiTV Map Contest Tou…
1d 23h
Gerald vs TBD
Clem vs TBD
ByuN vs TBD
Rogue vs MaxPax
ShoWTimE vs TBD
CranKy Ducklings
2 days
Escore
2 days
RSL Revival
3 days
WardiTV Map Contest Tou…
3 days
[ Show More ]
Universe Titan Cup
3 days
Rogue vs Percival
Ladder Legends
4 days
uThermal 2v2 Circuit
4 days
BSL
4 days
Sparkling Tuna Cup
4 days
WardiTV Map Contest Tou…
4 days
Ladder Legends
5 days
BSL
5 days
Replay Cast
5 days
Replay Cast
5 days
Wardi Open
5 days
Monday Night Weeklies
6 days
Replay Cast
6 days
Liquipedia Results

Completed

Proleague 2026-04-20
RSL Revival: Season 4
NationLESS Cup

Ongoing

BSL Season 22
ASL Season 21
CSL 2026 SPRING (S20)
IPSL Spring 2026
KCM Race Survival 2026 Season 2
StarCraft2 Community Team League 2026 Spring
WardiTV TLMC #16
Nations Cup 2026
IEM Rio 2026
PGL Bucharest 2026
Stake Ranked Episode 1
BLAST Open Spring 2026
ESL Pro League S23 Finals
ESL Pro League S23 Stage 1&2
PGL Cluj-Napoca 2026
IEM Kraków 2026

Upcoming

Escore Tournament S2: W4
Acropolis #4
BSL 22 Non-Korean Championship
CSLAN 4
Kung Fu Cup 2026 Grand Finals
HSC XXIX
uThermal 2v2 2026 Main Event
Maestros of the Game 2
2026 GSL S2
RSL Revival: Season 5
2026 GSL S1
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
IEM Atlanta 2026
Asian Champions League 2026
PGL Astana 2026
BLAST Rivals Spring 2026
TLPD

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Advertising | Privacy Policy | Terms Of Use | Contact Us

Original banner artwork: Jim Warren
The contents of this webpage are copyright © 2026 TLnet. All Rights Reserved.