• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 12:36
CEST 18:36
KST 01:36
  • 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
[ASL22] Ro16 Preview: Holy Diver4[ASL22] Ro16 Preview: Rough Waters10[ASL22] Ro24 Preview: Siren's Call8[ASL22] Ro24 Preview: Summer's End9Serral wins HomeStory Cup 2915
Community News
Weekly Cups (Sep 7-12): SHIN, ByuN, MaxPax double down0StarCraft open world shooter announced at BlizzCon98Weekly Cups (Aug 30-Sep 7): herO thrives amid growing schism10Official StarCraft website teases new content ahead of BlizzCon?178Stellar Fest TWO the Moon (Dec 16-20)9
StarCraft 2
General
Blizzard Classic Cup @ BlizzCon 2026 - $100k prize pool How do you feel about the StarCraft shooter announcement at BlizzCon 2026? StarCraft open world shooter announced at BlizzCon Weekly Cups (Sep 7-12): SHIN, ByuN, MaxPax double down Balance hotfix patch 5.0.16b (July 16)
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event RSL goes to London! 2026 Offline Finals Nov 21-22 SC2 AI Tournament 2026 Fall Sparkling Tuna Cup - Weekly Open Tournament KSL Week #92
Strategy
[G] Having the right mentality to improve
Custom Maps
Nexus Wars 2021 GUIDE [M] (2) Industrial Park
External Content
Mutation # 543 Enhanced Defenses The PondCast: SC2 News & Results Mutation # 542 The Ascended Mutation # 541 Binary Choice
Brood War
General
Remastered crash fix suggestions BGH Auto Balance -> http://bghmmr.eu/ Official StarCraft website teases new content ahead of BlizzCon? New 3v3 BGH Ladder (and more) on ShieldBattery! [D] Brainstorming a balance patch for Brood war
Tourneys
[ASL22] Ro16 Group D [ASL22] Ro16 Group C [Megathread] Daily Proleagues [ASL22] Ro16 Group B
Strategy
Replay Review Process - What do you do? Simple Questions, Simple Answers Odyssey Mineral Stack Saturation Game Theory for Starcraft
Other Games
General Games
Warcraft III: The Frozen Throne Stormgate/Frost Giant Megathread Nintendo Switch Thread EVE Corporation Diablo IV
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread Artificial Intelligence Thread UK Politics Mega-thread Things Aren’t Peaceful in Palestine
Fan Clubs
MarineLorD Fan Club The Creator Fan Club The ShoWTimE Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Diablo Animated Series on Netflix
Sports
Football (Soccer) Thread TeamLiquid Health and Fitness Initiative For 2023 MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List Northern Ireland Global Starcraft
Blogs
Virtual Romance, Real-Life C…
TrAiDoS
Regacy Esports:Our Goa…
regacyesports
Dreaming of BW patches (mod…
c3rberUs
LOCKPICKING NOOB
LUCKY_NOOB
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8575 users

The Big Programming Thread - Page 667

Forum Index > General Forum
Post a Reply
Prev 1 665 666 667 668 669 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.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
October 03 2015 10:31 GMT
#13321
On October 03 2015 18:34 Itsmedudeman wrote:
Show nested quote +
On October 03 2015 18:21 Manit0u wrote:
On October 03 2015 18:07 Itsmedudeman wrote:
Quick question, might be a meaningless one and I might be overthinking it but I feel like I'm not since I've heard different things about coding practices. Anyways, I'm working in java and I have a class that stores different information like strings, integers, and also a list of arrays that's of size 2. The array is supposed to store a time range. So if 6 is the first value, and 7 is the second value then that represents 6 am to 7 am. So I was just wondering if it's correct to code this way or should I define a separate class for time range that holds a value for start and end? I feel like that would make the code more readable and easy to understand, but it might be a bit "out of the way" to code in such a fashion.


First thing you should do in any language is do some research, so you don't end up reinventing the wheel...

https://docs.oracle.com/javase/tutorial/datetime/iso/datetime.html
https://docs.oracle.com/javase/tutorial/datetime/iso/period.html
http://joda-time.sourceforge.net/api-release/org/joda/time/Period.html
http://joda-time.sourceforge.net/api-release/org/joda/time/Interval.html

It's cool there's an existing class for this and all, but it doesn't really solve my problem/answer my question. My point being that I feel it would be best for me to hold my times as a set of 2 to represent a beginning and an end, my interest is not with the duration between those two time periods. I would still have to create 2 localtime objects for each set of values. So the essence of my question is how should I structure this in my class? Even if I use these APIs?

To explain a bit further on what I'm working on, I want to hold multiple time sets for each person object. Later on I'm going to use these time sets in an algorithm which, as far as I know, isn't covered by existing APIs. Also, I feel that the localtime class is overly complex for what I want to store which doesn't involve minutes or seconds.

edit: I guess the interval class structures it the way I'm thinking of now that I look at it. It still has a lot of fields that I find unnecessary so I might make my own class.

You're optimizing prematurely. If you want to store a time, use an existing time class. If you want to store a range, use an existing range class. Only if you have actual performance or memory problems and used a profiler to determine that this algorithm is part of the problem, consider using a custom implementation.
If you have a good reason to disagree with the above, please tell me. Thank you.
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
October 03 2015 11:27 GMT
#13322
Hm, yeah. Also if I wanna add stuff in the future it would be good having the API already.
Acrofales
Profile Joined August 2010
Spain18438 Posts
October 03 2015 13:11 GMT
#13323
General rule of thumb. If there's a standard library that does what you want, use it.

Not only will it save you time programming, but standard libraries are usually debugged pretty thoroughly and optimized quite well. This is especially true for Java.
Manit0u
Profile Blog Joined August 2004
Poland17843 Posts
Last Edited: 2015-10-03 17:18:22
October 03 2015 17:14 GMT
#13324
On October 03 2015 22:11 Acrofales wrote:
General rule of thumb. If there's a standard library that does what you want, use it.

Not only will it save you time programming, but standard libraries are usually debugged pretty thoroughly and optimized quite well. This is especially true for Java.


Not to mention interoperability with other libraries (possibly written by someone else entirely) if you have to do it somewhere down the line.

And of course debugging/refactoring by someone else if such need arises. It's much easier to understand what someone else's code does (or even your own if you have to return to it after a while) if it's using standard libraries and built-in functionality for the most part.
Time is precious. Waste it wisely.
teamamerica
Profile Blog Joined July 2010
United States958 Posts
October 03 2015 20:57 GMT
#13325
On October 03 2015 17:03 SacredCoconut wrote:
I started internship 2 weeks ago, and using mainly python. I had no experience before, but it feels quit natural to use.

But i would be interested in reading some book/online guide on good practices. I have been reading python hitchhiker's guide little.

Commenting has been makeing me wonder for while already. Not only python, but in each lanquage i have no idea how, much should i comment. It feels like it would be stupid to comment on everything, but then again something clear to me might not be clear to the reader.


For signal/noise ratio I haven't found better Python guide then http://python.net/~goodger/projects/pycon/2007/idiomatic/handout.html.


On October 03 2015 18:07 Itsmedudeman wrote:
Quick question, might be a meaningless one and I might be overthinking it but I feel like I'm not since I've heard different things about coding practices. Anyways, I'm working in java and I have a class that stores different information like strings, integers, and also a list of arrays that's of size 2. The array is supposed to store a time range. So if 6 is the first value, and 7 is the second value then that represents 6 am to 7 am. So I was just wondering if it's correct to code this way or should I define a separate class for time range that holds a value for start and end? I feel like that would make the code more readable and easy to understand, but it might be a bit "out of the way" to code in such a fashion.


1) If you're determined not to use anything like Duration (java 8 date api basically Joda now I think), I'd go with a class with start/end LocalDate objects or something.



Say I have a service that downloads something every 5 minutes. How to set it up so I can run multiple nodes but only one goes does download? Do I use zookeeper and have shared lock?


RIP GOMTV. RIP PROLEAGUE.
Manit0u
Profile Blog Joined August 2004
Poland17843 Posts
Last Edited: 2015-10-04 22:50:44
October 04 2015 22:46 GMT
#13326
On October 04 2015 05:57 teamamerica wrote:
Say I have a service that downloads something every 5 minutes. How to set it up so I can run multiple nodes but only one goes does download? Do I use zookeeper and have shared lock?


Only one can download at a time or only one can download ever?

In the first case, you may use the zookeeper with distributed lock, in the second case you should be fine with just a regular event listener.

Anyway, you may want to take a look at the Curator library for some ideas (or just use it).
Time is precious. Waste it wisely.
berated-
Profile Blog Joined February 2007
United States1134 Posts
Last Edited: 2015-10-05 00:18:53
October 05 2015 00:15 GMT
#13327
On October 04 2015 05:57 teamamerica wrote:

Say I have a service that downloads something every 5 minutes. How to set it up so I can run multiple nodes but only one goes does download? Do I use zookeeper and have shared lock?



Are you in java? You can also use quartz with a jdbc job store and DisallowConcurrentExecution.
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
October 05 2015 02:01 GMT
#13328
Why are so many java class objects immutable? Really annoying sometimes when I want to change fields later.
phantomfive
Profile Joined April 2010
Korea (South)404 Posts
October 05 2015 02:37 GMT
#13329
On October 05 2015 11:01 Itsmedudeman wrote:
Why are so many java class objects immutable? Really annoying sometimes when I want to change fields later.

There are some languages where every variable is immutable. The reason is to make it easier to avoid bugs.

When programmers become more advanced, they stop thinking, "how can I make this work?" and start thinking, "How can I avoid bugs?"
To ease another's heartache is to forget one's own - Lincoln
r3dox
Profile Blog Joined May 2003
Germany261 Posts
October 05 2015 17:54 GMT
#13330
On October 05 2015 11:01 Itsmedudeman wrote:
Why are so many java class objects immutable? Really annoying sometimes when I want to change fields later.


immutable is great.
do you want to change a field within an immutable object? then you probably didnt understand the API correctly.

if you have a class of your own with an immutable object in a field, just assign a new value to the field.
Itsmedudeman
Profile Blog Joined March 2011
United States19229 Posts
Last Edited: 2015-10-05 23:50:34
October 05 2015 23:44 GMT
#13331
On October 05 2015 11:37 phantomfive wrote:
Show nested quote +
On October 05 2015 11:01 Itsmedudeman wrote:
Why are so many java class objects immutable? Really annoying sometimes when I want to change fields later.

There are some languages where every variable is immutable. The reason is to make it easier to avoid bugs.

When programmers become more advanced, they stop thinking, "how can I make this work?" and start thinking, "How can I avoid bugs?"

So in the case of the Date class which is mutable and the DateTime class which is immutable is Date safe against changes that those who created DateTime wanted to prevent? Or is that just up to the programmer to take as a risk and hope that the user uses the library correctly? It just seems strange to me that there's no consistency in libraries and no concrete coding practice to make class objects mutable or immutable. For example, in the case of Strings, people clearly wanted a mutable variation for easier String manipulation so that's why StringBuffer exists. Does that mean String avoids bugs that StringBuffer doesn't?
Manit0u
Profile Blog Joined August 2004
Poland17843 Posts
Last Edited: 2015-10-07 07:39:06
October 06 2015 00:12 GMT
#13332
Are you talking about Joda or standard Java here? Because Date class has been deprecated ages ago in Java and is not present in Joda at all.

Edit: Come to think of it, Joda is being shelved for java.time too...
Time is precious. Waste it wisely.
obesechicken13
Profile Blog Joined July 2008
United States10467 Posts
Last Edited: 2015-10-09 15:31:33
October 09 2015 15:28 GMT
#13333
When writing integration tests for a web service (people will be hitting a REST endpoint) how many integration tests should there be?


I need to populate the database with data before running the integration tests.

Do I just proceed with pretending it's a black box and making all my business tests at the integration level? Like should I just test that the integration hooks are in place or should I test the logic of the service from end to end?

Concrete example:
Starcraft 2 releases an API giving you access to player data.
Do I test that given X parameters(tier,region) I get Y(winrate,game length) output for Z(20) test cases?
Or do I write one test for the endpoint just making sure it's connected all the way through?
I think in our modern age technology has evolved to become more addictive. The things that don't give us pleasure aren't used as much. Work was never meant to be fun, but doing it makes us happier in the long run.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2015-10-10 08:03:44
October 10 2015 07:56 GMT
#13334
On October 05 2015 11:01 Itsmedudeman wrote:
Why are so many java class objects immutable? Really annoying sometimes when I want to change fields later.

Above answers are good. For more detail, get a copy of this:

http://www.amazon.com/gp/product/0321356683/ (which you should do if you're going to be programming a significant amount of Java)

then read item 15


On October 10 2015 00:28 obesechicken13 wrote:
When writing integration tests for a web service (people will be hitting a REST endpoint) how many integration tests should there be?


I need to populate the database with data before running the integration tests.

Do I just proceed with pretending it's a black box and making all my business tests at the integration level? Like should I just test that the integration hooks are in place or should I test the logic of the service from end to end?

Concrete example:
Starcraft 2 releases an API giving you access to player data.
Do I test that given X parameters(tier,region) I get Y(winrate,game length) output for Z(20) test cases?
Or do I write one test for the endpoint just making sure it's connected all the way through?

There's no hard & fast rule here. end-to-end tests are always good to have. Separate tests for bits in the middle are good, especially if you can get them to run more quickly.

I'm not clear on what you're getting at, but these are two distinct types of tests to have, and both are good:

1) A test which hits a real, live endpoint, just to see if it's alive. This should be pretty low qps, and resilient to flakes - especially considering whatever the SLA of the endpoint is

2) Tests which stand up the whole stack inside the test, with fake test data, and verify that endpoints return expected results (populate a database with test data, clean up after you're done).

Both are good to have.
Who after all is today speaking about the destruction of the Armenians?
SpiZe
Profile Joined December 2010
Canada3640 Posts
October 10 2015 20:36 GMT
#13335
Hey guys, it's been a while since I've done C++ and I'm really confused about a problem I'm having.

I have a class ColonneCartes.h such as

#include <vector>
#include "Carte.h"
namespace solitaire
{
class ColonneCartes
{
...
public:
friend std::ostream operator<<(std::ostream& p_sortie, const ColonneCartes& p_colonneCartes);
...
}
}


and in ColonneCarte.cpp

#include "ColonneCarte.h"
using namespace std;
namespace solitaire
{
ostream& operator<<(ostream& p_sortie, const ColonneCartes& p_colonneCartes)
{
//some code
}
}


Now when attemping to compile I get "ambiguating new declaration of 'std::ostream& solitaire::operator<<(std::ostream&, const solitaire::ColonneCartes&)' on my implementation in my .cpp when I try to implement my operator<<.

Now I'm not sure what's going on here, I did not try to implement it twice, and I do not have another operator<< overload with the same parameters, although I do have another operator<< overload take a const Carte& as parameter in my namespace. I guess the problem stems from here but I have no idea why, or how to fix it ?

Is it wrong to include my operator overload in my namespace ?

Thanks
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2015-10-10 21:06:18
October 10 2015 20:47 GMT
#13336
--- Nuked ---
SpiZe
Profile Joined December 2010
Canada3640 Posts
October 10 2015 20:49 GMT
#13337
On October 11 2015 05:47 Nesserev wrote:
Show nested quote +
On October 11 2015 05:36 SpiZe wrote:
Hey guys, it's been a while since I've done C++ and I'm really confused about a problem I'm having.

I have a class ColonneCartes.h such as

#include <vector>
#include "Carte.h"
namespace solitaire
{
class ColonneCartes
{
...
public:
friend std::ostream operator<<(std::ostream& p_sortie, const ColonneCartes& p_colonneCartes);
...
}
}


and in ColonneCarte.cpp

#include "ColonneCarte.h"
using namespace std;
namespace solitaire
{
ostream& operator<<(ostream& p_sortie, const ColonneCartes& p_colonneCartes)
{
//some code
}
}


Now when attemping to compile I get "ambiguating new declaration of 'std::ostream& solitaire::operator<<(std::ostream&, const solitaire::ColonneCartes&)' on my implementation in my .cpp when I try to implement my operator<<.

Now I'm not sure what's going on here, I did not try to implement it twice, and I do not have another operator<< overload with the same parameters, although I do have another operator<< overload take a const Carte& as parameter in my namespace. I guess the problem stems from here but I have no idea why, or how to fix it ?

Is it wrong to include my operator overload in my namespace ?

Thanks

You return a std::ostream object in your function's friend declaration, but you return a reference to an std::ostream object in the function definition.


Oh well would you look at that I'm retarded, thanks a lot friend.
phar
Profile Joined August 2011
United States1080 Posts
October 10 2015 23:55 GMT
#13338
Don't sweat it. The number of hours you spend on single character mistakes during your career will keep on increasing roughly linearly.
Who after all is today speaking about the destruction of the Armenians?
teamamerica
Profile Blog Joined July 2010
United States958 Posts
October 12 2015 04:33 GMT
#13339
Hey can anyone point me toward some resources into learning why it's not possible (or is it?) to save state of a warmed up JVM? I've seen stuff about lowing JIT compilation threshold but that isn't quite what I don't want everything compiled, just what was compiled after running my program through normal workload.

From my understanding, there are lisps where you can basically save image of application state and run it later?
RIP GOMTV. RIP PROLEAGUE.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
October 12 2015 05:47 GMT
#13340
--- Nuked ---
Prev 1 665 666 667 668 669 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 7h 24m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech143
BRAT_OK 71
SHIN 68
StarCraft: Brood War
Britney 26811
Bisu 2232
Jaedong 1766
Soulkey 814
BeSt 400
Horang2 369
Mini 329
Soma 299
Rush 248
Stork 219
[ Show more ]
Larva 204
ggaemo 197
HiyA 163
firebathero 139
Shine 136
hero 97
Barracks 63
Zeus 58
Killer 42
soO 38
Dewaltoss 34
Terrorterran 29
PianO 27
sorry 27
Sexy 23
ToSsGirL 22
Trap 20
sSak 18
ajuk12(nOOB) 13
scan(afreeca) 12
Noble 10
zelot 8
Sacsri 3
Dota 2
420jenkins415
Counter-Strike
fl0m986
ceh9370
Super Smash Bros
Mew2King93
C9.Mang044
Other Games
Grubby11000
singsing2228
Liquid`RaSZi1265
hiko953
Beastyqt545
FrodaN526
DeMusliM187
ArmadaUGS124
TKL 94
XaKoH 54
QueenE39
Organizations
Other Games
gamesdonequick1328
WardiTV187
BasetradeTV52
[ Show 15 non-featured ]
StarCraft 2
• StrangeGG 55
• mYiSmile145
• Hinosc 22
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV1
League of Legends
• Nemesis2303
• TFBlade981
Other Games
• Shiphtur154
Upcoming Events
PiGosaur Cup
7h 24m
The PondCast
17h 24m
Kung Fu Cup
18h 24m
Replay Cast
1d 7h
KCM Race Survival
1d 17h
IntoTheTV X SOOP
1d 18h
OSC
2 days
Replay Cast
2 days
IntoTheTV X SOOP
2 days
Replay Cast
3 days
[ Show More ]
GSL
3 days
Replay Cast
4 days
GSL
4 days
Shopify Rebellion Sundays
4 days
Spirit vs Mixu
Replay Cast
5 days
WardiTV Weekly
5 days
Monday Night Weeklies
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Proleague 2026-09-14
Blizzard Classic Cup 2026
Big Dog Cup 2026 Div 1

Ongoing

KCM Race Survival 2026 Season 3
K-JUNGMAN
ASL Season 22
Super Anchor Qualifying S3
CSL 2026 AUTUMN (S22)
Acropolis #5
Calamity Invitational
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026

Upcoming

Acropolis #5 - GSA
Acropolis #5 - GSB
Acropolis #5 - GSC
SC4ALL II: Brood War
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
Copium Cup
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
Stake Ranked Episode 5
PGL Masters Bucharest 2026
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 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...

Disclosure: This page contains affiliate marketing links that support TLnet.

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.