• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 21:51
CEST 03:51
KST 10:51
  • 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
[ASL20] Ro8 Preview Pt1: Mile High11Team TLMC #5 - Finalists & Open Tournaments2[ASL20] Ro16 Preview Pt2: Turbulence10Classic Games #3: Rogue vs Serral at BlizzCon10[ASL20] Ro16 Preview Pt1: Ascent10
Community News
StarCraft II 5.0.15 PTR Patch Notes192BSL 2025 Warsaw LAN + Legends Showmatch2Weekly Cups (Sept 8-14): herO & MaxPax split cups4WardiTV TL Team Map Contest #5 Tournaments1SC4ALL $6,000 Open LAN in Philadelphia8
StarCraft 2
General
StarCraft II 5.0.15 PTR Patch Notes Why Storm Should NOT Be Nerfed – A Core Part of Pr #1: Maru - Greatest Players of All Time SC4ALL: A North American StarCraft LAN Team TLMC #5 - Finalists & Open Tournaments
Tourneys
RSL: Revival, a new crowdfunded tournament series SC2's Safe House 2 - October 18 & 19 Stellar Fest KSL Week 80 StarCraft Evolution League (SC Evo Biweekly)
Strategy
Custom Maps
External Content
Mutation # 492 Get Out More Mutation # 491 Night Drive Mutation # 490 Masters of Midnight Mutation # 489 Bannable Offense
Brood War
General
BGH Auto Balance -> http://bghmmr.eu/ Old rep packs of BW legends ASL ro8 Upper Bracket HYPE VIDEO [ASL20] Ro8 Preview Pt1: Mile High BW General Discussion
Tourneys
[ASL20] Ro16 Group D SC4ALL $1,500 Open Bracket LAN BSL 2025 Warsaw LAN + Legends Showmatch [ASL20] Ro16 Group C
Strategy
Simple Questions, Simple Answers Muta micro map competition
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Path of Exile Borderlands 3 General RTS Discussion Thread
Dota 2
Official 'what is Dota anymore' discussion LiquidDota to reintegrate into TL.net
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread
Community
General
US Politics Mega-thread The Big Programming Thread Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread UK Politics Mega-thread
Fan Clubs
The Happy Fan Club!
Media & Entertainment
Movie Discussion! [Manga] One Piece Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion MLB/Baseball 2023
World Cup 2022
Tech Support
Linksys AE2500 USB WIFI keeps disconnecting Computer Build, Upgrade & Buying Resource Thread High temperatures on bridge(s)
TL Community
BarCraft in Tokyo Japan for ASL Season5 Final The Automated Ban List
Blogs
Why can't Americans stop ea…
Peanutsc
Too Many LANs? Tournament Ov…
TrAiDoS
I <=> 9
KrillinFromwales
A very expensive lesson on ma…
Garnet
hello world
radishsoup
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1677 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
Poland17352 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
Poland17352 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
Turkey779 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
Spain18055 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
Poland17352 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
Turkey779 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
Poland17352 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
Spain18055 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
Next event in 8h 10m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
NeuroSwarm 143
RuFF_SC2 109
StarCraft: Brood War
Artosis 849
Sharp 38
NaDa 16
Dota 2
capcasts372
League of Legends
Cuddl3bear4
Heroes of the Storm
Khaldor160
Other Games
summit1g10287
JimRising 544
C9.Mang0218
Maynarde136
Mew2King38
Organizations
Other Games
gamesdonequick694
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 12 non-featured ]
StarCraft 2
• Berry_CruncH237
• davetesta34
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Upcoming Events
Afreeca Starleague
8h 10m
Barracks vs Mini
Wardi Open
9h 10m
Monday Night Weeklies
14h 10m
Sparkling Tuna Cup
1d 8h
Afreeca Starleague
1d 8h
Snow vs EffOrt
PiGosaur Monday
1d 22h
LiuLi Cup
2 days
The PondCast
3 days
CranKy Ducklings
4 days
Maestros of the Game
5 days
Clem vs Reynor
[ Show More ]
[BSL 2025] Weekly
5 days
[BSL 2025] Weekly
5 days
BSL Team Wars
6 days
Liquipedia Results

Completed

2025 Chongqing Offline CUP
RSL Revival: Season 2
HCC Europe

Ongoing

BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Points
ASL Season 20
CSL 2025 AUTUMN (S18)
Maestros of the Game
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1

Upcoming

IPSL Winter 2025-26
SC4ALL: Brood War
BSL 21 Team A
BSL Season 21
Stellar Fest
SC4ALL: StarCraft II
EC S1
ESL Impact League Season 8
SL Budapest Major 2025
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
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 © 2025 TLnet. All Rights Reserved.