• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 08:59
CET 13:59
KST 21: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
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (October 19-25): Clem triples first in 5.0.172Evil Geniuses - shutting down17ISSL (IntoTheTV x SOOP SC2 League): Premier5Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League88
StarCraft 2
General
REPORT: StarCraft 2: Remastered In Development No more SC2 streamers on team liquid? Weekly Cups (October 19-25): Clem triples first in 5.0.17 Evil Geniuses - shutting down How do you feel about the mass reverts in the 5.0.17 PTR?
Tourneys
2026 KungFu Cup Announcement RSL goes to London! 2026 Offline Finals Nov 21-22 ScienceCraft (October 24-25) - Live Event Sparkling Tuna Cup - Weekly Open Tournament ISSL (IntoTheTV x SOOP SC2 League): Premier
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
Simple Questions/Answers [G] How to playtest arcade maps [A] Nemrods 1/4 players
External Content
Mutation # 549 Endless Sparkles The PondCast: SC2 News & Results Mutation # 548 Shining Bright Mutation # 547 Temple Of Terror
Brood War
General
BW General Discussion [BW] Looking for Clan Thread! [ASL22] Finals Preview: Sweet Victory! Recent recommended BW games [Megathread] Daily Funny Videos
Tourneys
[$1250] International ShieldBattery League KCM Race Survival 2026 Season 4 [Megathread] Daily Proleagues [BSL23] RO24 Group D - Sunday 21:00 CET
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Mobile Legends: Bang Bang Armies of Exigo - YesYes? General RTS Discussion Thread
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
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
European Politico-economics QA Mega-thread Things Aren’t Peaceful in Palestine Canadian Politics Mega-thread US Politics Mega-thread Russo-Ukrainian War Thread
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
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
Recent Gifted Posts
Blogs
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 9237 users

The Big Programming Thread - Page 827

Forum Index > General Forum
Post a Reply
Prev 1 825 826 827 828 829 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.
Manit0u
Profile Blog Joined August 2004
Poland17865 Posts
January 11 2017 11:09 GMT
#16521
On January 11 2017 18:55 Acrofales wrote:
Show nested quote +
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

Looks like you created a deadlock situation. Change the restrictions on your DB, or accept that there will be undeletable entries. Your only other option is a hack where you add a C called "tobedeleted" or something, and change A to belong to that first, then cascade your delete.


Yeah, figured as much. I'm now trying to change the structure to accommodate my needs.
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
Last Edited: 2017-01-11 11:57:57
January 11 2017 11:57 GMT
#16522
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B
***has one or more A***


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

FTFY.

So, each C belongs to a single B. It's not an m to n relationship, at least I hope so (for your sake) and each B can have one or more Cs. Each A has exactly one B.

What if we merge A and B into AB:

If the C has exactly one A and that A is the one that the B belongs, you can have a 1 to n relationship:

AB:
has relationship to C

C:
has relationship to AB

How does this sound?
"windows bash is a steaming heap of shit" tofucake
Manit0u
Profile Blog Joined August 2004
Poland17865 Posts
January 11 2017 12:49 GMT
#16523
On January 11 2017 20:57 Djagulingu wrote:
Show nested quote +
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B
***has one or more A***


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

FTFY.

So, each C belongs to a single B. It's not an m to n relationship, at least I hope so (for your sake) and each B can have one or more Cs. Each A has exactly one B.

What if we merge A and B into AB:

If the C has exactly one A and that A is the one that the B belongs, you can have a 1 to n relationship:

AB:
has relationship to C

C:
has relationship to AB

How does this sound?


If life were so simple I also have D and E, which belong to C
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
January 11 2017 14:33 GMT
#16524
On January 11 2017 21:49 Manit0u wrote:
Show nested quote +
On January 11 2017 20:57 Djagulingu wrote:
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B
***has one or more A***


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

FTFY.

So, each C belongs to a single B. It's not an m to n relationship, at least I hope so (for your sake) and each B can have one or more Cs. Each A has exactly one B.

What if we merge A and B into AB:

If the C has exactly one A and that A is the one that the B belongs, you can have a 1 to n relationship:

AB:
has relationship to C

C:
has relationship to AB

How does this sound?


If life were so simple I also have D and E, which belong to C


AB:
has relationship to C

C:
has relationship to AB
has one or more D
has one or more E

D:
belongs to C

E:
belongs to C

Unless there is another dependency between AB, C, D or E (or C has more than one As), you can just cascade your deletes into:

delete AB:
-> delete the associated C

delete C:
-> delete the associated D
-> delete the associated E

delete D:
nothing

delete E:
nothing
"windows bash is a steaming heap of shit" tofucake
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
January 12 2017 07:54 GMT
#16525
Would I bei legally safe if I murdered the person that created CSS like that?

@media (...) { .someclass > .col-md-3 { width: 50% } }
(Standard bootstrap)
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
January 12 2017 10:57 GMT
#16526
On January 12 2017 16:54 Morfildur wrote:
Would I bei legally safe if I murdered the person that created CSS like that?

@media (...) { .someclass > .col-md-3 { width: 50% } }
(Standard bootstrap)

How much experience does this guy have?
"windows bash is a steaming heap of shit" tofucake
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
January 12 2017 12:39 GMT
#16527
--- Nuked ---
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
January 12 2017 13:14 GMT
#16528
why bluetooth sucks so much

I have 4 devices (2 android, 1 windows phone, 1 arduino) that has bluetooth. Not any two of them are able to connect each other :/ testing an android app that uses bluetooth
Age of Mythology forever!
Acrofales
Profile Joined August 2010
Spain18486 Posts
January 12 2017 13:42 GMT
#16529
Weird. My bluetooth devices are a bit finicky, but once I figure out the settings I can always connect, and the connection is quite stable once set up.
Manit0u
Profile Blog Joined August 2004
Poland17865 Posts
January 12 2017 16:40 GMT
#16530
On January 11 2017 23:33 Djagulingu wrote:
Show nested quote +
On January 11 2017 21:49 Manit0u wrote:
On January 11 2017 20:57 Djagulingu wrote:
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B
***has one or more A***


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

FTFY.

So, each C belongs to a single B. It's not an m to n relationship, at least I hope so (for your sake) and each B can have one or more Cs. Each A has exactly one B.

What if we merge A and B into AB:

If the C has exactly one A and that A is the one that the B belongs, you can have a 1 to n relationship:

AB:
has relationship to C

C:
has relationship to AB

How does this sound?


If life were so simple I also have D and E, which belong to C


AB:
has relationship to C

C:
has relationship to AB
has one or more D
has one or more E

D:
belongs to C

E:
belongs to C

Unless there is another dependency between AB, C, D or E (or C has more than one As), you can just cascade your deletes into:

delete AB:
-> delete the associated C

delete C:
-> delete the associated D
-> delete the associated E

delete D:
nothing

delete E:
nothing


Solved the problem by doing "on delete: set null" without changing anything in the db
Time is precious. Waste it wisely.
Djagulingu
Profile Blog Joined December 2010
Germany3605 Posts
January 13 2017 07:06 GMT
#16531
On January 13 2017 01:40 Manit0u wrote:
Show nested quote +
On January 11 2017 23:33 Djagulingu wrote:
On January 11 2017 21:49 Manit0u wrote:
On January 11 2017 20:57 Djagulingu wrote:
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B
***has one or more A***


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

FTFY.

So, each C belongs to a single B. It's not an m to n relationship, at least I hope so (for your sake) and each B can have one or more Cs. Each A has exactly one B.

What if we merge A and B into AB:

If the C has exactly one A and that A is the one that the B belongs, you can have a 1 to n relationship:

AB:
has relationship to C

C:
has relationship to AB

How does this sound?


If life were so simple I also have D and E, which belong to C


AB:
has relationship to C

C:
has relationship to AB
has one or more D
has one or more E

D:
belongs to C

E:
belongs to C

Unless there is another dependency between AB, C, D or E (or C has more than one As), you can just cascade your deletes into:

delete AB:
-> delete the associated C

delete C:
-> delete the associated D
-> delete the associated E

delete D:
nothing

delete E:
nothing


Solved the problem by doing "on delete: set null" without changing anything in the db

Of course, soft deleting is always a solution
"windows bash is a steaming heap of shit" tofucake
mantequilla
Profile Blog Joined June 2012
Turkey781 Posts
Last Edited: 2017-01-13 08:59:02
January 13 2017 08:56 GMT
#16532
I wanna share my 2 cents of experience about deletion just to maybe add value to the thread

I never saw things getting really deleted in business oriented apps, dunno what kind of app you are working on though, it maybe a requirement.

in those apps db records all had a disabled flag instead of deletion, which makes querying cumbersome because you have to add disabled=false everywhere

reason is all data somehow sometime becomes useful and removing is not worth the space or performance you would gain.

plus oop+orm makes it little easier, which entry point to your object graph will be deleted and how it should cascade to the connected entities. it can also handle logical interactions between entities, while not relying on database features, ie cascading or triggers.

oop+orm is not fancy though I imagine it is not liked outside of enterprise environment.
Age of Mythology forever!
Manit0u
Profile Blog Joined August 2004
Poland17865 Posts
Last Edited: 2017-01-13 12:44:11
January 13 2017 12:40 GMT
#16533
On January 13 2017 16:06 Djagulingu wrote:
Show nested quote +
On January 13 2017 01:40 Manit0u wrote:
On January 11 2017 23:33 Djagulingu wrote:
On January 11 2017 21:49 Manit0u wrote:
On January 11 2017 20:57 Djagulingu wrote:
On January 11 2017 18:46 Manit0u wrote:
I have a bit of a problem with the DB:


A:
has one B
belongs to C

B:
belongs to A
has many C

C:
belongs to B
***has one or more A***


How do I set my cascades properly so that when I delete A all of B and C are also removed? Right now I'm getting an error that C can't be deleted because it's still referenced by A...

FTFY.

So, each C belongs to a single B. It's not an m to n relationship, at least I hope so (for your sake) and each B can have one or more Cs. Each A has exactly one B.

What if we merge A and B into AB:

If the C has exactly one A and that A is the one that the B belongs, you can have a 1 to n relationship:

AB:
has relationship to C

C:
has relationship to AB

How does this sound?


If life were so simple I also have D and E, which belong to C


AB:
has relationship to C

C:
has relationship to AB
has one or more D
has one or more E

D:
belongs to C

E:
belongs to C

Unless there is another dependency between AB, C, D or E (or C has more than one As), you can just cascade your deletes into:

delete AB:
-> delete the associated C

delete C:
-> delete the associated D
-> delete the associated E

delete D:
nothing

delete E:
nothing


Solved the problem by doing "on delete: set null" without changing anything in the db

Of course, soft deleting is always a solution


No, no. It still hard-deletes everything. It just sets c_id to null in A while deleting C, thus avoiding the foreign key reference error and everything works just fine (deleting A now deletes B and all C).

On January 13 2017 17:56 mantequilla wrote:
I wanna share my 2 cents of experience about deletion just to maybe add value to the thread

I never saw things getting really deleted in business oriented apps, dunno what kind of app you are working on though, it maybe a requirement.

in those apps db records all had a disabled flag instead of deletion, which makes querying cumbersome because you have to add disabled=false everywhere

reason is all data somehow sometime becomes useful and removing is not worth the space or performance you would gain.

plus oop+orm makes it little easier, which entry point to your object graph will be deleted and how it should cascade to the connected entities. it can also handle logical interactions between entities, while not relying on database features, ie cascading or triggers.

oop+orm is not fancy though I imagine it is not liked outside of enterprise environment.


I'm using OOP+ORM (Rails). No soft-deletable on my models yet since it's not a requirement at the moment (might become a requirement later on and then I'll add it). I also didn't set any cascades in the DB because that would disable the ORM callbacks and I don't want that.
Time is precious. Waste it wisely.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-01-13 19:30:54
January 13 2017 19:27 GMT
#16534
need help debugging a java problem
my understanding is failing me somewhere

At class level I have:


public static int card1Spent;
private static Label card1Label = new Label(card1Spent + "/X (1)", skin);
private static TextButton card1Button = new TextButton("add point", skin);


(some of this stuff is from libgdx but it shouldn't matter


inside my constructor I have


card1Spent=1
card1Button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
card1Spent++;
card1Label.setText(card1Label.getText().toString());

}
});


changelistener is a libgdx thing. it works like you think it would

so when I run my program I have a button that says "add point" and a label that shows "0/X (1)"
I don't know why it shows 0/X instead of 1/X

And when I click the button, it stays at 0. It never looks at the updated value, it only looks at the original declaration.

If I make the changelistener:


card1Button.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
card1Spent++;
card1Label.setText(Integer.toString(card1Spent));

}
});


then it originally shows my button and 0/X (1) for the label
but then if I press the button it shows "2" for the label, then "3" if i press it again etc etc

so wtf?



It's like when I do "card1Label.setText(card1Label.getText().toString());", it doesn't even see the original variable as ever having been a variable. Is this a bug?
Acrofales
Profile Joined August 2010
Spain18486 Posts
January 13 2017 19:30 GMT
#16535

public static int card1Spent;


YEUCH. We taught you better than that!
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
Last Edited: 2017-01-13 19:38:10
January 13 2017 19:32 GMT
#16536
Well what's the reason I am not supposed to do this again? Because I do want there to be only one of them and I do want to be able to access it from other classes (geesh I don't want to write a thousand getters).

I guess I can make everything non static, but then none of my GUI can be static either. changes my whole design a lot
Blitzkrieg0
Profile Blog Joined August 2010
United States13132 Posts
Last Edited: 2017-01-13 19:39:29
January 13 2017 19:38 GMT
#16537
On January 14 2017 04:32 travis wrote:
Well what's the reason I am not supposed to do this again? Because I do want there to be only one of them and I do want to be able to access it from other classes (geesh I don't want to write a thousand getters).

I guess I can make everything non static, but then none of my GUI can be static either. changes my whole design a lot


Your IDE will write getters and setters for you for a reason.
I'll always be your shadow and veil your eyes from states of ain soph aur.
RoomOfMush
Profile Joined March 2015
1296 Posts
January 13 2017 20:11 GMT
#16538
On January 14 2017 04:32 travis wrote:
Well what's the reason I am not supposed to do this again? Because I do want there to be only one of them and I do want to be able to access it from other classes (geesh I don't want to write a thousand getters).

I guess I can make everything non static, but then none of my GUI can be static either. changes my whole design a lot

You will be hurting very bad if you continue with the static fields some day. Perhaps its better to experience this yourself because then you will understand for the rest of your life. Either that or you just trust in the judgement and experience of virtually every somewhat skilled programmer out there.

But to answer your question: Your label shows a "0" for card1Spent because thats the value of card1Spent at the moment you initialize your label. Just because you change the value of your variable later doesnt mean your label will automatically update. You have two solutions: Initialize your variable card1Spent to the correct value before initializing your label or update the label after initializing your variable.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
January 13 2017 20:13 GMT
#16539
If something can be modified, better think twice about making it static. And then think again. Repeat until you don't want to make it static anymore.
If you have a good reason to disagree with the above, please tell me. Thank you.
Deleted User 3420
Profile Blog Joined May 2003
24492 Posts
January 13 2017 20:26 GMT
#16540
alright im taking all the advice, my design has been changed


in an unrelated thought, it seems really stupid that java can't cast int to string, I have to use Integer.toString() or some other method, and yet I can simply say that (the string = the int + ""). I'd love to have that one explained to me.
Prev 1 825 826 827 828 829 1032 Next
Please log in or register to reply.
Live Events Refresh
Kung Fu Cup
20:00
2026 Week 29
IntoTheiNu 1061
WardiTV572
RotterdaM377
TKL 225
IndyStarCraft 175
SteadfastSC136
Rex127
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RotterdaM 377
Lowko374
TKL 225
IndyStarCraft 175
SteadfastSC 136
Rex 127
elazer 65
StarCraft: Brood War
Bisu 3015
Shuttle 1774
Jaedong 631
Mini 567
BeSt 562
Soma 392
Leta 376
FanTaSy 356
Hyuk 289
Light 245
[ Show more ]
actioN 238
Larva 227
Mong 210
Last 156
Snow 151
hero 86
Hyun 84
Sharp 75
Pusan 59
Sea.KH 57
ToSsGirL 39
Sexy 28
HiyA 22
Sacsri 21
JYJ 20
Shine 19
soO 18
ajuk12(nOOB) 16
zelot 13
yabsab 12
Noble 11
Terrorterran 11
Free 9
Icarus 5
Dota 2
Gorgc18029
XaKoH 453
XcaliburYe126
Counter-Strike
olofmeister1289
x6flipin281
Other Games
singsing1520
B2W.Neo988
hiko561
dupreeh481
crisheroes387
DeMusliM237
Pyrionflax209
ArmadaUGS187
Organizations
Counter-Strike
PGL22663
[ Show 10 non-featured ]
StarCraft 2
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• HerbMon 3
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• WagamamaTV200
Upcoming Events
KCM Race Survival
21h 1m
IntoTheTV X SOOP
22h 1m
SHIN vs GuMiho
Clem vs Classic
OSC
1d 9h
WardiTV Invitational
1d 23h
GSL
1d 23h
Epic.LAN
2 days
Replay Cast
2 days
Sparkling Tuna Cup
2 days
Epic.LAN
3 days
AI Arena Tournament
3 days
[ Show More ]
Yamato Cup
4 days
Map Test Tournament
4 days
WardiTV Weekly
4 days
Replay Cast
5 days
Rogue vs Classic
Patches Events
6 days
PiGosaur Cup
6 days
Kung Fu Cup
6 days
Liquipedia Results

Completed

Proleague 2026-10-27
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
PGL Masters Bucharest 2026
Stake Ranked Episode 5
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
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

IPSL Winter 2026-27
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 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.