• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 05:00
CEST 11:00
KST 18:00
  • 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
Serral wins Maestros of the Game 236ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12TL.net Map Contest #22 - Voting & Ladder Map Selection7
Community News
BSL Season 22 Full Overview & Conclusion4BSL Season 22 Full Overview & Conclusion4Weekly Cups (June 29-July 5): Solar Doubles0MC vs IdrA, Boxer vs Nal_rA to be Legacy Matches @ BlizzCon445.0.16 Hotfix (June 30) - Balance + Bug Fixes40
StarCraft 2
General
Most successful SC2 players of Q2 2026 AquaTrail-(I've Tested) My 90 Day Honest Experienc https://www.facebook.com/Power.Pro.Genius.USD/ Serral wins Maestros of the Game 2 MC vs IdrA, Boxer vs Nal_rA to be Legacy Matches @ BlizzCon
Tourneys
GSL CK #5 Race War RSL Revival: Season 6 - Qualifiers and Main Event HomeStory Cup 29 Vespene Cup #1 — $300+ USD, July 10 Sea Duckling Open (Global, Bronze-Diamond)
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
Mutation # 533 Die Together The PondCast: SC2 News & Results Mutation # 532 Nuclear Family Mutation # 531 Experimental Artillery
Brood War
General
BSL Season 22 Full Overview & Conclusion BGH Auto Balance -> http://bghmmr.eu/ BW General Discussion ASL 22 Proposed Map Pool Starcraft vs Retro Category on Twitch
Tourneys
IPSL Spring 2026 Top 4! Escore Tournament StarCraft Season 2 Small VOD Thread 2.0 CSLAN 4 is Coming!
Strategy
Fighting Spirit mining rates Simple Questions, Simple Answers Creating a full chart of Zerg builds Relatively freeroll strategies
Other Games
General Games
Summer Games Done Quick 2026! Nintendo Switch Thread Stormgate/Frost Giant Megathread Dawn of War IV ZeroSpace at Steam NextFest - Last free demo
Dota 2
Looking for a Dota Mentor 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
TL Mafia
NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread TL Mafia Power Rank Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread UK Politics Mega-thread YouTube Thread Canadian Politics Mega-thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! Series you have seen recently... [Req][Books] Good Fantasy/SciFi books [TV/BOOK] *SPOILERS* Game of Thrones Discussion
Sports
2024 - 2026 Football Thread McBoner: A hockey love story Tennis[sport] Formula 1 Discussion TeamLiquid Health and Fitness Initiative For 2023
World Cup 2022
Tech Support
FPS when play League Of Legend on laptop How to clean a TTe Thermaltake keyboard? Computer Build, Upgrade & Buying Resource Thread
TL Community
The Automated Ban List
Blogs
Major Shifts in the Gaming I…
TrAiDoS
An Exploration of th…
waywardstrategy
Gauntlet SC2: A Retrospectiv…
Ctone23
ramps on octagon
StaticNine
Funny Nicknames
LUCKY_NOOB
Evil Gacha Games and the…
ffswowsucks
Customize Sidebar...

Website Feedback

Closed Threads



Active: 4527 users

The Big Programming Thread - Page 347

Forum Index > General Forum
Post a Reply
Prev 1 345 346 347 348 349 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.
Mordanis
Profile Blog Joined January 2011
United States893 Posts
Last Edited: 2013-08-23 20:49:22
August 23 2013 20:45 GMT
#6921
On August 24 2013 05:31 Yoshi- wrote:
That seems to be way too hard and is pretty much useless tbh, you should maybe focus on something that not that "impossible"

I was thinking of writing each line to a file (dummy file?) that looks like this on startup:
#include <stdio.h>
int main()
{
/* lines from scanf go here */
return 0;
}

and then after each line, I can have a decision on what to/ if to print something. Then run a shell script to compile and run the "dummy program", and run the output to the main program. Is it that much more difficult than it seems? BTW this would only be for linux.

EDIT: guess this was all basically said already...
But for the usability part, it seems to me to be a slightly easier way to learn operations and pointers. Would this be helpful for someone just starting or coming back to C? or would this be a waste of time :D
I love the smell of napalm in the morning... it smells like... victory. -_^ Favorite SC2 match ->Liquid`HerO vs. SlayerS CranK g.1 @MLG Summer Championship
Yoshi-
Profile Joined October 2008
Germany10227 Posts
August 23 2013 20:52 GMT
#6922
Well, normally how I would assume such an REPL system, is that it works like the one at codeacademy: www.codecademy.com

e.g. you write something like 5+5;(without print or something like that) and it would give you the result, so dunno if you can actually catch this properly
RoyGBiv_13
Profile Blog Joined August 2010
United States1275 Posts
Last Edited: 2013-08-23 20:54:50
August 23 2013 20:53 GMT
#6923
I did this for Java back when I was learning how to program, so its certainly not impossible, though still really difficult. You're effectively writing a virtual machine (which is great practice!).

Here's a short list of problems I had, and you would likely run into:

Variables are tough. I used a map, in Java, and you would have to make your own map or something similar using C, which isn't too tough. Figuring out the data structure was the easy part, the parsing and evaluating is the difficult part, as you have to decide something is a variable. Luckily, C is loosely typed, so that part is easy. Implementing structures is particularly a pain.

Allocation is really, really hard. You will have to manage your own heap.

Functions. Hard. You will have to manage your own stack as well.

Program control is nearly impossible without writing your own virtual machine to decide which line to run next. You're already effectively doing this if you implement your own heap and stack and I/O, so adding on PC control ain't so bad comparatively.

Plus, you have to be able to parse and evaluate calculations. <---- I would start with this step, then add variables, then add arrays, then add if()/else+while/for.

This is all assuming you want your REPL to have memory, etc...
Any sufficiently advanced technology is indistinguishable from magic
KainiT
Profile Joined July 2011
Austria392 Posts
August 26 2013 10:00 GMT
#6924
Hey, maybe you guys have a better solution for the following task than me:

Names in brackets are for explanatory reasons.
I have a cpp std::map that maps a struct containing a std::string("first1") and an unsigned int("first2") to another unsigned int("second"). Now I have to find out for every entry if there is another entry(and how many) that has the same "first2" and also the same "second".
Note that the map contains several thousand entries but only very few of them will share "first2" and "second", maybe even none.
My idea would be to iterate over the std::map and create another map while doing it. This map would map a struct containing "first2" and "second" to "first1".
I guess this is a fairly tolerable solution, but I already grumbled about the excessive use of std::maps(most of the code leading to this problem was not written by me) so using another one to solve the problem is a little problematic :D

Maybe one of you knows some awesome way to do this. Btw, everyting of the boost library can be used
With great power comes great responsibility.
gedatsu
Profile Joined December 2011
1286 Posts
August 26 2013 12:27 GMT
#6925
On August 26 2013 19:00 KainiT wrote:
Hey, maybe you guys have a better solution for the following task than me:

Names in brackets are for explanatory reasons.
I have a cpp std::map that maps a struct containing a std::string("first1") and an unsigned int("first2") to another unsigned int("second"). Now I have to find out for every entry if there is another entry(and how many) that has the same "first2" and also the same "second".
Note that the map contains several thousand entries but only very few of them will share "first2" and "second", maybe even none.
My idea would be to iterate over the std::map and create another map while doing it. This map would map a struct containing "first2" and "second" to "first1".
I guess this is a fairly tolerable solution, but I already grumbled about the excessive use of std::maps(most of the code leading to this problem was not written by me) so using another one to solve the problem is a little problematic :D

Maybe one of you knows some awesome way to do this. Btw, everyting of the boost library can be used

Since you want the answer for every string, you're going to need to use a dictionary of some sort. A map is good. You're only going to need two maps in total, and you're only going to need one iteration through the first map. A well implemented map will be able to do this in O(n) time. Insertion into your new map will require O(nlogn) if it's a BST which normal maps usually are, but O(n) if it's a hashmap.
Promises
Profile Joined February 2004
Netherlands1821 Posts
August 26 2013 15:01 GMT
#6926
Hey guys, I might be desperate for help =) I just received a programming assignment for Logical Programming, SWIPL Prolog. There is a LOT riding on this assignment for me, and I'm about to get started. Is there anyone here who happens to be familiar with Prolog? I understand that this is a fairly desperate bid, but I guess that's sort of what I am =)
I'm a man of my word, and that word is "unreliable".
Utini
Profile Joined July 2012
5 Posts
August 26 2013 15:20 GMT
#6927
Hello. Im trying to make program using C#, windows forms, ms server, entity framework. Here is a problem.. I have quite complicated data structure (List of dictionaries with another lists inside and so on..), user fills this structure by completing multiple forms and press submit in the end. At that time i need to take this structure and write it into database which spreads all this information into around 10 tables. If some errors happens (like foreign key problems) while inserting data, all previously written data must be deleted, in other words, all 10 tables must be filled correctly on none at all.

Currently i fill all data into entity model and call saveChanges() method ONCE, which puts data from model into DB afaik.
Problem is that this makes dubugging almost impossible, because all crashes comes from calling saveChanges() and it's hard to say which part of filling my entity model is responsible for this error.

How should i deal with this? Im thinking about remaking it, so it would call saveChanges() by inserting small chunks of data into single tables and if, lets say it crashes on 10th table (10th saveChanges() call), some other code whould delete inserted data from another 9 already filled tables. What do you think about this idea? Or maybe there is some better way?
bleda
Profile Joined January 2011
United States27 Posts
August 26 2013 15:29 GMT
#6928
On August 27 2013 00:20 Utini wrote:
Hello. Im trying to make program using C#, windows forms, ms server, entity framework. Here is a problem.. I have quite complicated data structure (List of dictionaries with another lists inside and so on..), user fills this structure by completing multiple forms and press submit in the end. At that time i need to take this structure and write it into database which spreads all this information into around 10 tables. If some errors happens (like foreign key problems) while inserting data, all previously written data must be deleted, in other words, all 10 tables must be filled correctly on none at all.

Currently i fill all data into entity model and call saveChanges() method ONCE, which puts data from model into DB afaik.
Problem is that this makes dubugging almost impossible, because all crashes comes from calling saveChanges() and it's hard to say which part of filling my entity model is responsible for this error.

How should i deal with this? Im thinking about remaking it, so it would call saveChanges() by inserting small chunks of data into single tables and if, lets say it crashes on 10th table (10th saveChanges() call), some other code whould delete inserted data from another 9 already filled tables. What do you think about this idea? Or maybe there is some better way?


That is one way of doing it, but I think an easier way is to call a stored procedure and let it do all of that work for you. Handling FK errors is a lot easier on the SQL side of things. Also, if there could potentially be an error when inserting, it really your job to handle the validation of the information before you try to insert. So have a call that validates, and if that is successful, then insert it into the DB.
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2013-08-26 15:45:24
August 26 2013 15:42 GMT
#6929
First of all, if you have a "quite complicated data structure" you might want to try and make it less complicated. This isn't really related to obtaining debugging information, but if you find your own code complicated, debugging will always be hard.

I'm currently working on a program with a somewhat similar setup (C#, WPF, SQLCE, ADO.NET). I too am inserting a large chunck of complex (but not all that complicated) data at once. The last time I worked on the database part of the program is a bit ago already though, and I'm not terribly experienced with databases yet.
Anyways, as far as I can remember, there usually was a decent hint in the stack trace whenever SaveChanges failed. It pretty much always was either a duplicate key or me failing to correctly update the data model after changing the database.
(my memory about that is a bit hazy already; I'm busy with finite state machines now)
If you have a good reason to disagree with the above, please tell me. Thank you.
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
Last Edited: 2013-08-26 16:07:49
August 26 2013 15:59 GMT
#6930
On August 27 2013 00:20 Utini wrote:
Hello. Im trying to make program using C#, windows forms, ms server, entity framework. Here is a problem.. I have quite complicated data structure (List of dictionaries with another lists inside and so on..), user fills this structure by completing multiple forms and press submit in the end. At that time i need to take this structure and write it into database which spreads all this information into around 10 tables. If some errors happens (like foreign key problems) while inserting data, all previously written data must be deleted, in other words, all 10 tables must be filled correctly on none at all.

Currently i fill all data into entity model and call saveChanges() method ONCE, which puts data from model into DB afaik.
Problem is that this makes dubugging almost impossible, because all crashes comes from calling saveChanges() and it's hard to say which part of filling my entity model is responsible for this error.

How should i deal with this? Im thinking about remaking it, so it would call saveChanges() by inserting small chunks of data into single tables and if, lets say it crashes on 10th table (10th saveChanges() call), some other code whould delete inserted data from another 9 already filled tables. What do you think about this idea? Or maybe there is some better way?

One way to make this easier would be to put in as much validation handling as you can. If you can predict when an error will happen before making any commits and inform the user, that will go a long way towards solving any problems caused by user error.

For debugging purposes, are you wrapping your entire data commit in a transaction? I would highly recommend it, as it will save you the effort of having to build code to go back and undo what was done. After all, what would happen when the undo code fails? A transaction will take care of that for you.

I'm guessing saveChanges() is one single function that performs all the save work. What I have done in the past in cases like this is create a status string that I change during the workload depending on what work I'm doing, and if there is an error, I return the status. Here's an example:
string updateMessage;

Try

// Workload One
updateMessage = "Workload One";
group of work

// Workload Two
updateMessage = "Workload Two";
group of work

// Workload Three
updateMessage = "Workload Three";
group of work

Catch ex as exception
Message.Show("An error occurred during " + updateMessage);

End Try

Obviously what you do with the error will be different, but hopefully you get the idea. The nice part about this is although you can't control what an error message looks like (a divide by zero error will always look the same no matter where in your code it happens), you can customize the updateMessage to look however you want at any stage during the work, so it will always be easy to know exactly where the error occurred (ctrl+f, baby!).

Of course, if you change it so that you are wrapping your entire data commit in one transaction, and the errors you anticipate will always be database errors, you'll have to approach it a bit differently. I would recommend logging the error along with the SQL that caused the error, and providing some means of getting that from the user to you so you can debug it.
Warri
Profile Joined May 2010
Germany3208 Posts
Last Edited: 2013-08-26 16:54:58
August 26 2013 16:54 GMT
#6931
for (Object o:oList) {
o.do();
if (!o.enabled)
oList.iterator().remove();
}

Why is this throwing an IllegalStateException?
tapuchi
Profile Joined November 2010
Greece7 Posts
August 26 2013 17:28 GMT
#6932
Hello , i'm currently re-writing an image processing program i created using vc++ and matlab in c# and trying to implement the object-oriented paradigms correctly . My previous implementation was my first real and big programming experience and after spending the summer reading Design Patterns , Code Complete and Object Roles and Responsibilites i realized how bad my code structure/design/implementation was and decided to go at it again whilst using what i hopefully learnt.

The thing is i just cant decide how to do things properly even after spending alot of time at stack overflow or just googling stuff.
For example , i got some algorithms doing the same work on the images and thought of implementing the strategy pattern but then again i figured why complicate it and not just make a static class with each algorithm as a different method ( System.Math style ) .

Another problem is how to pass each algorithms settings to it while at the same time avoiding a huge parameter list . A Parameter Object just moves the parameter list from the algorithm to the structure constructor , a builder pattern seems abit too much for it because the object needs to be bound to a control that changes the settings values .

How does a novice actually make these decisions ? Even the simple creation of the settings control is driving me mad , do i give the settings object a .ToControl() method ( is it its Responsibility to make a view of itself or not? ) or do i pass the object
as an argument to the SettingsControl constructor ( does the control need to know about the settings object implementation ? ).All in all i think i just mashed up all that knowledge without really understanding it im afraid . Thanks for any help/opinion/advice beforehand .
taguchi?
enigmaticcam
Profile Blog Joined October 2010
United States280 Posts
August 26 2013 17:35 GMT
#6933
On August 27 2013 01:54 Warri wrote:
for (Object o:oList) {
o.do();
if (!o.enabled)
oList.iterator().remove();
}

Why is this throwing an IllegalStateException?

I'm not quite familiar with this language, but it might be because you're removing an object from a collection as you're enumerating through the collection.
Warri
Profile Joined May 2010
Germany3208 Posts
August 26 2013 17:55 GMT
#6934
On August 27 2013 02:35 enigmaticcam wrote:
Show nested quote +
On August 27 2013 01:54 Warri wrote:
for (Object o:oList) {
o.do();
if (!o.enabled)
oList.iterator().remove();
}

Why is this throwing an IllegalStateException?

I'm not quite familiar with this language, but it might be because you're removing an object from a collection as you're enumerating through the collection.

If you try to remove the object direclty with oList.remove(o); you would get ConcurrentModificationException, which is exactly because of what you said. Removing by using the iterator is supposed to work apparently.
Zocat
Profile Joined April 2010
Germany2229 Posts
Last Edited: 2013-08-26 18:07:32
August 26 2013 18:05 GMT
#6935
remove:
Removes from the list the last element that was returned by next() or previous()
IllegalStateException - if neither next nor previous have been called, or remove or add have been called after the last call to next or previous

Dump the foreach loop and do a normal one with the iterator
gedatsu
Profile Joined December 2011
1286 Posts
August 26 2013 18:20 GMT
#6936
On August 27 2013 01:54 Warri wrote:
for (Object o:oList) {
o.do();
if (!o.enabled)
oList.iterator().remove();
}

Why is this throwing an IllegalStateException?

You need to call next() before you can do a remove(). But you will run into errors still: you're using two different iterators for the same collection (the for loop and the explicit iterator()) and the for loop will crash if you modify the collection. Instead use only the explicit iterator(), and loop using while(iterator.hasNext()).
spinesheath
Profile Blog Joined June 2009
Germany8679 Posts
Last Edited: 2013-08-26 18:25:12
August 26 2013 18:22 GMT
#6937
On August 27 2013 02:28 tapuchi wrote:
Hello , i'm currently re-writing an image processing program i created using vc++ and matlab in c# and trying to implement the object-oriented paradigms correctly . My previous implementation was my first real and big programming experience and after spending the summer reading Design Patterns , Code Complete and Object Roles and Responsibilites i realized how bad my code structure/design/implementation was and decided to go at it again whilst using what i hopefully learnt.

The thing is i just cant decide how to do things properly even after spending alot of time at stack overflow or just googling stuff.
For example , i got some algorithms doing the same work on the images and thought of implementing the strategy pattern but then again i figured why complicate it and not just make a static class with each algorithm as a different method ( System.Math style ) .

Another problem is how to pass each algorithms settings to it while at the same time avoiding a huge parameter list . A Parameter Object just moves the parameter list from the algorithm to the structure constructor , a builder pattern seems abit too much for it because the object needs to be bound to a control that changes the settings values .

How does a novice actually make these decisions ? Even the simple creation of the settings control is driving me mad , do i give the settings object a .ToControl() method ( is it its Responsibility to make a view of itself or not? ) or do i pass the object
as an argument to the SettingsControl constructor ( does the control need to know about the settings object implementation ? ).All in all i think i just mashed up all that knowledge without really understanding it im afraid . Thanks for any help/opinion/advice beforehand .

I am making a lot of assumptions, since your description of the problem isn't very specific.
It sounds like a situation where I would create an IAlgorithm interface which you can apply to the image (or the image can apply to itself) without knowing what it does or how it is done. Then each algorithm gets its own class. Since you seem to have a lot of settings for each algorithm (and those probably are different from algorithm to algorithm), I would probably use a fluent interface to apply those settings.
Implementation like this:
class Algo
{
Algo SettingA(value)
{
...
return this;
}
}

Usage like this:
algo.SettingA(value_a).SettingB(value_b);

Applying settings like is very readable and it's much harder to mix up different settings of the same type. Of course you can and likely should group several closely related values into the same settings method.

The "is it its Responsibility to make a view of itself or not?" and "does the control need to know about the settings object implementation ?" sound like things that should be answered with a straight up no.

You might want to read about test driven development. It deals mainly with good class design. You don't have to actually apply TDD, but it should provide some insight if you have trouble designing systems.

Also: Try to avoid static anything.


On August 27 2013 01:54 Warri wrote:
for (Object o:oList) {
o.do();
if (!o.enabled)
oList.iterator().remove();
}

Why is this throwing an IllegalStateException?

Usually you are not meant to make changes to the collection in a foreach loop, which this seems to be.
What language is this, anyways?
If you have a good reason to disagree with the above, please tell me. Thank you.
Kambing
Profile Joined May 2010
United States1176 Posts
August 26 2013 18:26 GMT
#6938
On August 24 2013 05:45 Mordanis wrote:
Show nested quote +
On August 24 2013 05:31 Yoshi- wrote:
That seems to be way too hard and is pretty much useless tbh, you should maybe focus on something that not that "impossible"

I was thinking of writing each line to a file (dummy file?) that looks like this on startup:
#include <stdio.h>
int main()
{
/* lines from scanf go here */
return 0;
}

and then after each line, I can have a decision on what to/ if to print something. Then run a shell script to compile and run the "dummy program", and run the output to the main program. Is it that much more difficult than it seems? BTW this would only be for linux.

EDIT: guess this was all basically said already...
But for the usability part, it seems to me to be a slightly easier way to learn operations and pointers. Would this be helpful for someone just starting or coming back to C? or would this be a waste of time :D


Scaling it down to a simple REPL for a command-line calculator, perhaps in reverse polish notation, i.e., something like:



$ ./rpn

> 3 4 +
7
> 1 2 + 3 *
9
> quit



Exercises most of the functionality you want without having to delve into the details of properly implementing an actual programming language (as RoyGBiv_13 describes).
Warri
Profile Joined May 2010
Germany3208 Posts
August 26 2013 18:42 GMT
#6939
On August 27 2013 03:20 gedatsu wrote:
Show nested quote +
On August 27 2013 01:54 Warri wrote:
for (Object o:oList) {
o.do();
if (!o.enabled)
oList.iterator().remove();
}

Why is this throwing an IllegalStateException?

You need to call next() before you can do a remove(). But you will run into errors still: you're using two different iterators for the same collection (the for loop and the explicit iterator()) and the for loop will crash if you modify the collection. Instead use only the explicit iterator(), and loop using while(iterator.hasNext()).

thanks, using the iterator for the loop works.
On August 27 2013 03:22 spinesheath wrote:
What language is this, anyways?

Java
Deleted User 101379
Profile Blog Joined August 2010
4849 Posts
August 26 2013 18:49 GMT
#6940
On August 27 2013 03:22 spinesheath wrote:
Show nested quote +
On August 27 2013 02:28 tapuchi wrote:
Hello , i'm currently re-writing an image processing program i created using vc++ and matlab in c# and trying to implement the object-oriented paradigms correctly . My previous implementation was my first real and big programming experience and after spending the summer reading Design Patterns , Code Complete and Object Roles and Responsibilites i realized how bad my code structure/design/implementation was and decided to go at it again whilst using what i hopefully learnt.

The thing is i just cant decide how to do things properly even after spending alot of time at stack overflow or just googling stuff.
For example , i got some algorithms doing the same work on the images and thought of implementing the strategy pattern but then again i figured why complicate it and not just make a static class with each algorithm as a different method ( System.Math style ) .

Another problem is how to pass each algorithms settings to it while at the same time avoiding a huge parameter list . A Parameter Object just moves the parameter list from the algorithm to the structure constructor , a builder pattern seems abit too much for it because the object needs to be bound to a control that changes the settings values .

How does a novice actually make these decisions ? Even the simple creation of the settings control is driving me mad , do i give the settings object a .ToControl() method ( is it its Responsibility to make a view of itself or not? ) or do i pass the object
as an argument to the SettingsControl constructor ( does the control need to know about the settings object implementation ? ).All in all i think i just mashed up all that knowledge without really understanding it im afraid . Thanks for any help/opinion/advice beforehand .

I am making a lot of assumptions, since your description of the problem isn't very specific.
It sounds like a situation where I would create an IAlgorithm interface which you can apply to the image (or the image can apply to itself) without knowing what it does or how it is done. Then each algorithm gets its own class. Since you seem to have a lot of settings for each algorithm (and those probably are different from algorithm to algorithm), I would probably use a fluent interface to apply those settings.
Implementation like this:
class Algo
{
Algo SettingA(value)
{
...
return this;
}
}

Usage like this:
algo.SettingA(value_a).SettingB(value_b);

Applying settings like is very readable and it's much harder to mix up different settings of the same type. Of course you can and likely should group several closely related values into the same settings method.

The "is it its Responsibility to make a view of itself or not?" and "does the control need to know about the settings object implementation ?" sound like things that should be answered with a straight up no.

You might want to read about test driven development. It deals mainly with good class design. You don't have to actually apply TDD, but it should provide some insight if you have trouble designing systems.

Also: Try to avoid static anything.
?


C# has initialization lists, so the .SettingA() thing is usually (arguably) less readable.


Class X
{
public String A {get;set;}
public Int32 B {get;set;}
public Double C {get;set;}
}

X x = new X()
{
A = "foo",
B = 42,
C = 3.1415926
}


I'm currently in the middle of a Planetside 2 platoon op so i don't have time to write a good solution for the problem in question but if noone else gives a satisfactory solution, i'll might remember to write it later.
Prev 1 345 346 347 348 349 1032 Next
Please log in or register to reply.
Live Events Refresh
RSL Revival
09:00
Season 6 - Group A
Serral vs Bunny
ByuN vs GgMaChine
RotterdaM144
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft576
Tasteless 168
RotterdaM 144
Rex 32
TKL 2
StarCraft: Brood War
firebathero 1316
Shuttle 270
Larva 257
Dewaltoss 94
sorry 45
Sharp 34
ZerO 22
ggaemo 20
ajuk12(nOOB) 10
IntoTheRainbow 8
Dota 2
XaKoH 484
League of Legends
Doublelift1739
JimRising 716
Other Games
RuFF_SC228
Mew2King25
Pyrionflax16
BEARDiaguz8
ZerO(Twitch)5
Organizations
Other Games
gamesdonequick23618
StarCraft 2
IntoTheiNu 86
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 13 non-featured ]
StarCraft 2
• StrangeGG 99
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• lizZardDota2164
League of Legends
• Jankos2312
Upcoming Events
CranKy Ducklings
1h
Afreeca Starleague
1h
Snow vs Jaedong
YSC vs hero
SC Evo League
3h
ByuN vs Classic
Cure vs Solar
IPSL
7h
Dragon vs Ret
Patches Events
7h
RSL Revival
1d
Solar vs Rogue
Maru vs NightMare
Sparkling Tuna Cup
1d 1h
IPSL
1d 7h
Bonyth vs Hawk
GSL
2 days
Replay Cast
2 days
[ Show More ]
WardiTV Weekly
3 days
The PondCast
4 days
Replay Cast
5 days
CrankTV Team League
5 days
Replay Cast
6 days
CrankTV Team League
6 days
Replay Cast
6 days
RSL Revival
7 days
Clem vs Lambo
Scarlett vs Cure
Liquipedia Results

Completed

Escore Tournament S3: W2
HSC XXIX
Eternal Conflict S2 E1

Ongoing

IPSL Spring 2026
Acropolis #4
YSL S3
CSL 2026 Summer (S21)
ASL Season 22: Wild Card Qualifier
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026
BLAST Rivals Spring 2026

Upcoming

CSLAN 4
Blizzard Classic Cup 2026
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
Eternal Conflict S2 E3
Eternal Conflict S2 E2
Logitech G Connect 2026
StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 2026
BLAST Bounty Summer Qual
Stake Ranked Episode 3
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.