• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 22:16
CET 04:16
KST 12:16
  • 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
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
StarCraft Evolution League (SC Evo Biweekly) RSL Offline Finals Info - Dec 13 and 14! RSL Offline FInals Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship
Strategy
Custom Maps
Map Editor closed ?
External Content
Mutation # 502 Negative Reinforcement Mutation # 501 Price of Progress Mutation # 500 Fright night Mutation # 499 Chilling Adaptation
Brood War
General
BW General Discussion Which season is the best in ASL? Data analysis on 70 million replays BGH Auto Balance -> http://bghmmr.eu/ [ASL20] Ask the mapmakers — Drop your questions
Tourneys
[BSL21] RO16 Group D - Sunday 21:00 CET [BSL21] RO16 Group A - Saturday 21:00 CET [Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET
Strategy
Current Meta Game Theory for Starcraft How to stay on top of macro? PvZ map balance
Other Games
General Games
ZeroSpace Megathread Stormgate/Frost Giant Megathread Nintendo Switch Thread The Perfect Game Path of Exile
Dota 2
Official 'what is Dota anymore' discussion
League of Legends
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
Mafia Game Mode Feedback/Ideas TL Mafia Community Thread
Community
General
Things Aren’t Peaceful in Palestine Russo-Ukrainian War Thread US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1927 users

The Big Programming Thread - Page 492

Forum Index > General Forum
Post a Reply
Prev 1 490 491 492 493 494 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.
CorsairHero
Profile Joined December 2008
Canada9491 Posts
June 19 2014 07:50 GMT
#9821
Any recommendations for courses/sites to look at for project/product management for a software feature?
© Current year.
Ethenielle
Profile Blog Joined December 2005
Norway1006 Posts
Last Edited: 2014-06-19 18:06:28
June 19 2014 18:05 GMT
#9822
After reading about the observer pattern, I think that's pretty much what I'm doing now.

Anyway, for the class that I expose to the user it looks something like this:


class PointLight
{
int radius;
float pos[3];
[..] etc

vector<Callback> callbacks;

public:
void AddCallback(...);
void X(float x)
{
// set x
// trigger callbacks
}

};


Then whenever the user adds a light to the scene, the engine would create an internal PointLight class which stores additional information that only the engine needs to know about, and it would also register a callback with the exposed class. Something like this:


struct PointLight_Internal
{
PointLight* exposed;
DirectX::XMFLOAT4X4 viewTransform;
ShadowMapOmni smap;
[...]

void OnPropertyChanged(...); // This would recalculate dependent variables such as viewTransform when position changes
};

void Engine::AddLight(PointLight& pl)
{
PointLight_Internal pli;
pli.exposed = &pl;
pl.AddCallback(pli.OnPropertyChanged)

lights.push_back(pli);
}


And then the rendering would obviously only operate on the internal class. So then I get the benefit of hiding these engine-only relevant variables from the user, but in their stead there is this "mysterious" array of callbacks. Ideally, the class I expose to the user would just be a POD class. Maybe that's not possible without constantly polling/updating dependent variables, though. I hope that was maybe a bit clearer explanation of my problem...?
Theres a fine line between fishing and just standing on the shore like an idiot.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2014-06-19 22:12:56
June 19 2014 21:56 GMT
#9823
--- Nuked ---
mcc
Profile Joined October 2010
Czech Republic4646 Posts
June 20 2014 08:45 GMT
#9824
On June 20 2014 03:05 Ethenielle wrote:
After reading about the observer pattern, I think that's pretty much what I'm doing now.

Anyway, for the class that I expose to the user it looks something like this:


class PointLight
{
int radius;
float pos[3];
[..] etc

vector<Callback> callbacks;

public:
void AddCallback(...);
void X(float x)
{
// set x
// trigger callbacks
}

};


Then whenever the user adds a light to the scene, the engine would create an internal PointLight class which stores additional information that only the engine needs to know about, and it would also register a callback with the exposed class. Something like this:


struct PointLight_Internal
{
PointLight* exposed;
DirectX::XMFLOAT4X4 viewTransform;
ShadowMapOmni smap;
[...]

void OnPropertyChanged(...); // This would recalculate dependent variables such as viewTransform when position changes
};

void Engine::AddLight(PointLight& pl)
{
PointLight_Internal pli;
pli.exposed = &pl;
pl.AddCallback(pli.OnPropertyChanged)

lights.push_back(pli);
}


And then the rendering would obviously only operate on the internal class. So then I get the benefit of hiding these engine-only relevant variables from the user, but in their stead there is this "mysterious" array of callbacks. Ideally, the class I expose to the user would just be a POD class. Maybe that's not possible without constantly polling/updating dependent variables, though. I hope that was maybe a bit clearer explanation of my problem...?

I am very confused by this design. Why don't you have just one Light class and hide what you want to hide by making it private ? Plus ideally make that class immutable, or at least clone it on Engine:AddLight if you really need to.
Ethenielle
Profile Blog Joined December 2005
Norway1006 Posts
June 20 2014 15:24 GMT
#9825
Initially that's what I did. But the engine needs access to those private variables for rendering, so then I had to friend the engine. I didn't like that, so that's why I ended up splitting the class in two, and that leads to the whole callback messy situation, which isn't good either.

On June 20 2014 06:56 Nesserev wrote:
It might be a bit rude even though I mean no offense, and it's only based on a hunch, but do you even understand how a graphics engine is supposed to work?

EDIT: Now that I think about it, asking this question doesn't help in any way... from what you've described about your engine so far, it just seems that the design of your engine is rather flawed.


Great advice, thanks. You're the reason I ask for help.
Theres a fine line between fishing and just standing on the shore like an idiot.
mcc
Profile Joined October 2010
Czech Republic4646 Posts
Last Edited: 2014-06-20 17:56:00
June 20 2014 17:54 GMT
#9826
On June 21 2014 00:24 Ethenielle wrote:
Initially that's what I did. But the engine needs access to those private variables for rendering, so then I had to friend the engine. I didn't like that, so that's why I ended up splitting the class in two, and that leads to the whole callback messy situation, which isn't good either.

What I meant that maybe you should have the Light structure just as POD structure. The whole concept of reacting to changes that the user makes later seems flawed. User should just create the Light structure, call AddLight by passing the structure in and that is it. Your engine should not react to changes to that struct that happen after the call to AddLight. You can achieve it either by cloning or by making the struct immutable. Another way would be to just not expose any class at all and just expose AddLight and pass all necessary info in parameters.

If you want to allow user to change the Light structure later, you can just return from AddLight a handle that he can later use in SetLight_x(handle, value) or Setx(typedHandle, value). You avoid dealing with all kinds of nasty surprises by more strictly controlling change to those variables.
urboss
Profile Joined September 2013
Austria1223 Posts
June 20 2014 18:06 GMT
#9827
On June 19 2014 01:41 Ethenielle wrote:
That's what I'm doing, but the internal classes have to know whenever the user changes something in the public class, thus the callbacks. Which I don't like.. the user shouldn't know about that, either.

Why not use an abstract class and derive the public class from it?
nunez
Profile Blog Joined February 2011
Norway4003 Posts
Last Edited: 2014-06-20 21:41:34
June 20 2014 21:36 GMT
#9828
@ethenielle
if you want a good case study of an interface using callbacks you can peep boost asio! in f.ex async_read they take the callback functor as a templated argument with a pre-specced signature:

template<
typename AsyncReadStream,
typename Allocator,
typename CompletionCondition,
typename ReadHandler>
void-or-deduced async_read(
AsyncReadStream & s,
basic_streambuf< Allocator > & b,
CompletionCondition completion_condition,
ReadHandler handler
);

void handler(
const boost::system::error_code& error,
std::size_t bytes_transferred
);

that alleviates the need for the 'exposed class' and instead you ask the user to provide a functor satisfying your signature.
conspired against by a confederacy of dunces.
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
June 20 2014 23:29 GMT
#9829
--- Nuked ---
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
June 21 2014 01:43 GMT
#9830
Has anyone got any experience with Java 8? Is there anything that is 'must learn'? I've seen lambda expressions, but they seem weird to me; not verbose enough.
phar
Profile Joined August 2011
United States1080 Posts
Last Edited: 2014-06-21 01:52:12
June 21 2014 01:46 GMT
#9831
^

As a meta point in software development, it is good to develop a thick skin to questions that seem overly blunt. A lot of people aren't trying to be mean, they just might not present things in super nice ways. People are also often very willing to teach and explain things, because helping other people understand how things work is the only way any shit gets done in software. Modern software is way too big and complex for any one person to do alone.

Sometimes a question "do you know how X works?" is literally just that - a query to see how much knowledge/experience you have on a specific topic, so people can help you learn more.

(Of course sometimes people can take it too far)

On June 21 2014 10:43 darkness wrote:
Has anyone got any experience with Java 8? Is there anything that is 'must learn'? I've seen lambda expressions, but they seem weird to me; not verbose enough.

No direct experience yet, because my company has yet to bless java 8 for production environments, and I haven't had any time to dick around with experimental stuff.

That said, can't wait for lambda expressions. Gonna remove a lot of bullshit anonymous classes that you have to hack in to do stuff that shouldn't be super hard to write. Also interested to see what tooling I'm gonna have access to around type annotations, though my guess is it's gonna be years out for me


I was just joking with a co-worker today - "What if the powers that be directing java are secretly haskell fanatics, and by java 12 we suddenly get full blown functional goodness?" http://res.cloudinary.com/readnuts-com/image/upload/c_fit,h_350,w_350/jayr9ifjyl9ztmjflk32.jpg

:\
Who after all is today speaking about the destruction of the Armenians?
Ethenielle
Profile Blog Joined December 2005
Norway1006 Posts
June 21 2014 09:36 GMT
#9832
On June 21 2014 03:06 urboss wrote:
Show nested quote +
On June 19 2014 01:41 Ethenielle wrote:
That's what I'm doing, but the internal classes have to know whenever the user changes something in the public class, thus the callbacks. Which I don't like.. the user shouldn't know about that, either.

Why not use an abstract class and derive the public class from it?


I'm not sure how this would help...? The issue is that the engine needs to know about variables the user shouldn't know about.

On June 21 2014 08:29 Nesserev wrote:
Show nested quote +
On June 21 2014 00:24 Ethenielle wrote:
Initially that's what I did. But the engine needs access to those private variables for rendering, so then I had to friend the engine. I didn't like that, so that's why I ended up splitting the class in two, and that leads to the whole callback messy situation, which isn't good either.

On June 20 2014 06:56 Nesserev wrote:
It might be a bit rude even though I mean no offense, and it's only based on a hunch, but do you even understand how a graphics engine is supposed to work?

EDIT: Now that I think about it, asking this question doesn't help in any way... from what you've described about your engine so far, it just seems that the design of your engine is rather flawed.


Great advice, thanks. You're the reason I ask for help.

[...]


It's hard to answer because it's the 3846th time I get an unqualified "your code sucks" without any further help.

I have no previous experience with writing graphics engines, I spent a couple of months reading through Frank D Luna's Game Programming with DirectX 11, which was ok for getting started I suppose but it had so many holes I spent an equal amount of time just googling stuff. Anyway, that's that. If I knew exactly how to craft a graphics engine I probably wouldn't be asking.

Anyway, we went from my code sucks to callbacks and internal classes suck. Could you help me with how I am supposed to design the public interface for say a light or sprite?

mcc

Not sure I am a fan of having setters for every property directly in the engine, I mean from a user point of view it would be hard to find the relevant setters for a given class, and from a maintenance point of view you suddenly have a colossal class chock full of irrelevant setters/getters. And having looked around at various other engines, they all seem to use a Light/Sprite/whatever class which you can work with in an intuitive manner.

Maybe the "best" solution really is to put all relevant variables in their respective class and friend the engine...? Even though friend is anathema.

Anyway, I appreciate you guys taking the time to help me out. Thanks!
Theres a fine line between fishing and just standing on the shore like an idiot.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2014-06-21 09:46:37
June 21 2014 09:46 GMT
#9833
On June 21 2014 18:36 Ethenielle wrote:
Maybe the "best" solution really is to put all relevant variables in their respective class and friend the engine...? Even though friend is anathema.

Friend is one of the better options C++ has to offer in terms of encapsulation. You shouldn't overuse it and you should know damn well what you are doing, like with everything else C++. But there really is no reason to hate on friend.

Whether it's the right tool for you task, I don't know. Didn't do much work in that area.
If you have a good reason to disagree with the above, please tell me. Thank you.
Manit0u
Profile Blog Joined August 2004
Poland17496 Posts
June 21 2014 10:54 GMT
#9834
On June 21 2014 10:46 phar wrote:
^

As a meta point in software development, it is good to develop a thick skin to questions that seem overly blunt. A lot of people aren't trying to be mean, they just might not present things in super nice ways. People are also often very willing to teach and explain things, because helping other people understand how things work is the only way any shit gets done in software. Modern software is way too big and complex for any one person to do alone.

Sometimes a question "do you know how X works?" is literally just that - a query to see how much knowledge/experience you have on a specific topic, so people can help you learn more.

(Of course sometimes people can take it too far)

Show nested quote +
On June 21 2014 10:43 darkness wrote:
Has anyone got any experience with Java 8? Is there anything that is 'must learn'? I've seen lambda expressions, but they seem weird to me; not verbose enough.

No direct experience yet, because my company has yet to bless java 8 for production environments, and I haven't had any time to dick around with experimental stuff.

That said, can't wait for lambda expressions. Gonna remove a lot of bullshit anonymous classes that you have to hack in to do stuff that shouldn't be super hard to write. Also interested to see what tooling I'm gonna have access to around type annotations, though my guess is it's gonna be years out for me


I was just joking with a co-worker today - "What if the powers that be directing java are secretly haskell fanatics, and by java 12 we suddenly get full blown functional goodness?" http://res.cloudinary.com/readnuts-com/image/upload/c_fit,h_350,w_350/jayr9ifjyl9ztmjflk32.jpg

:\


Screw Haskell, LISP is where it's at
Time is precious. Waste it wisely.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-06-21 14:28:39
June 21 2014 14:23 GMT
#9835
What do you think of the idea to have a separate controller (listener) for each GUI component? Is it a good idea? On top of that, I've implemented a controller factory which just accepts a class, then responds by returning the appropriate listener.

So for example:


public ActionListener getRelevantController(Class<?> theClass) {
if (theClass == SomeClass.class)
return new SomeClassListener(arg1);
else if (theClass == SomeOtherClass.class)
return new SomeOtherClassListener(arg1, arg2);
else
throw new IllegalArgumentException(<error here>);
}


I'm just wondering if I'm not doing some major bullshit. It's my own project, so I have no constraints about what I code.

Edit: I know the classic Factory pattern usually involves a static method but I decided not to pass arg1 and arg2 every time, and not every listener needs both at the same time.
bangsholt
Profile Joined June 2011
Denmark138 Posts
June 22 2014 10:52 GMT
#9836
wat

Have you heard of MVC?

One view has one controller.

One controller can have more views.

Why would you have a controller per component? If it's because you have overlap in usage, you can always extend on a base class that provides the shared functionality.
billy5000
Profile Blog Joined December 2010
United States865 Posts
June 24 2014 01:56 GMT
#9837
Got a question about eclipse. We have a workspace that consists of many projects, and there's a bit of a delay. Ideally, I would like to load a single project on eclipse rather than loading all of them. So instead of the root being the workspace, it would be the project. Is there a way to do this?
Tiger got to hunt, bird got to fly; Man got to sit and wonder, 'Why, why, why?' Tiger got to sleep, bird got to land; Man got to tell himself he understand. Vonnegut
Nesserev
Profile Blog Joined January 2011
Belgium2760 Posts
Last Edited: 2014-06-24 03:14:25
June 24 2014 03:11 GMT
#9838
--- Nuked ---
berated-
Profile Blog Joined February 2007
United States1134 Posts
June 24 2014 11:32 GMT
#9839
On June 24 2014 10:56 billy5000 wrote:
Got a question about eclipse. We have a workspace that consists of many projects, and there's a bit of a delay. Ideally, I would like to load a single project on eclipse rather than loading all of them. So instead of the root being the workspace, it would be the project. Is there a way to do this?


Where is the "bit of delay" you are trying to get rid of?

Sorry if you have already tried this, or if this isn't where your delay is, but, have you tried closing the projects you aren't using? I've had 75+ projects in a workspace and if a lot of the projects were open it would bog it down, but if you just close the projects you aren't using then everything was fast.
billy5000
Profile Blog Joined December 2010
United States865 Posts
June 24 2014 22:34 GMT
#9840
On June 24 2014 20:32 berated- wrote:
Show nested quote +
On June 24 2014 10:56 billy5000 wrote:
Got a question about eclipse. We have a workspace that consists of many projects, and there's a bit of a delay. Ideally, I would like to load a single project on eclipse rather than loading all of them. So instead of the root being the workspace, it would be the project. Is there a way to do this?


Where is the "bit of delay" you are trying to get rid of?

Sorry if you have already tried this, or if this isn't where your delay is, but, have you tried closing the projects you aren't using? I've had 75+ projects in a workspace and if a lot of the projects were open it would bog it down, but if you just close the projects you aren't using then everything was fast.


I didn't know about closing projects, thanks!
Tiger got to hunt, bird got to fly; Man got to sit and wonder, 'Why, why, why?' Tiger got to sleep, bird got to land; Man got to tell himself he understand. Vonnegut
Prev 1 490 491 492 493 494 1032 Next
Please log in or register to reply.
Live Events Refresh
Replay Cast
00:00
WardiTV Mondays #62
CranKy Ducklings161
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Nathanias 179
RuFF_SC2 62
StarCraft: Brood War
Artosis 729
Bale 93
Tasteless 88
Shine 43
Icarus 5
Dota 2
monkeys_forever905
NeuroSwarm145
League of Legends
JimRising 583
C9.Mang0318
Counter-Strike
Coldzera 578
Fnx 193
Other Games
summit1g14178
tarik_tv5272
shahzam583
Mew2King98
ViBE87
CosmosSc2 29
ToD22
Organizations
Other Games
gamesdonequick1132
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 13 non-featured ]
StarCraft 2
• Hupsaiya 97
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• RayReign 23
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift4200
Upcoming Events
The PondCast
6h 44m
OSC
12h 44m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
20h 44m
Korean StarCraft League
1d 23h
CranKy Ducklings
2 days
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
2 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
2 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
3 days
[ Show More ]
WardiTV 2025
3 days
OSC
3 days
BSL 21
3 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
4 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
4 days
Replay Cast
4 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
5 days
StarCraft2.fi
6 days
Tenacious Turtle Tussle
6 days
Liquipedia Results

Completed

Proleague 2025-11-30
RSL Revival: Season 3
Light HT

Ongoing

C-Race Season 1
IPSL Winter 2025-26
KCM Race Survival 2025 Season 4
YSL S2
BSL Season 21
CSCL: Masked Kings S3
Slon Tour Season 2
Acropolis #4 - TS3
META Madness #9
SL Budapest Major 2025
ESL Impact League Season 8
BLAST Rivals Fall 2025
IEM Chengdu 2025
PGL Masters Bucharest 2025
Thunderpick World Champ.
CS Asia Championships 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2

Upcoming

BSL 21 Non-Korean Championship
Acropolis #4
IPSL Spring 2026
Bellum Gens Elite Stara Zagora 2026
HSC XXVIII
RSL Offline Finals
WardiTV 2025
Kuram Kup
PGL Cluj-Napoca 2026
IEM Kraków 2026
BLAST Bounty Winter 2026
BLAST Bounty Winter Qual
eXTREMESLAND 2025
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.