• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 17:10
CET 23:10
KST 07:10
  • 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 announced14[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
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband BGE Stara Zagora 2026 announced Information Request Regarding Chinese Ladder SC: Evo Complete - Ranked Ladder OPEN ALPHA
Tourneys
$5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle [Alpha Pro Series] Nice vs Cure
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 [ASL20] Ask the mapmakers — Drop your questions Which season is the best in ASL? FlaSh's Valkyrie Copium BGH Auto Balance -> http://bghmmr.eu/
Tourneys
[Megathread] Daily Proleagues [BSL21] RO16 Group B - Sunday 21:00 CET [BSL21] RO16 Group C - Saturday 21:00 CET Small VOD Thread 2.0
Strategy
Game Theory for Starcraft How to stay on top of macro? Current Meta PvZ map balance
Other Games
General Games
Stormgate/Frost Giant Megathread The Perfect Game Path of Exile Nintendo Switch Thread Should offensive tower rushing be viable in RTS games?
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 US Politics Mega-thread Russo-Ukrainian War 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: 1379 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
Next event in 2h 50m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
PiGStarcraft455
elazer 316
JuggernautJason109
SpeCial 55
DisKSc2 31
CosmosSc2 17
StarCraft: Brood War
Larva 457
ZZZero.O 134
Dota 2
capcasts149
Counter-Strike
Foxcn518
minikerr32
Heroes of the Storm
Liquid`Hasu487
Other Games
Grubby6568
tarik_tv3998
FrodaN3192
fl0m2055
ceh9500
shahzam495
Mew2King148
C9.Mang0141
ArmadaUGS130
NarutO 24
Organizations
Other Games
BasetradeTV65
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• musti20045 60
• davetesta20
• intothetv
• AfreecaTV YouTube
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Doublelift2952
• TFBlade1182
Other Games
• imaqtpie1481
• Shiphtur187
Upcoming Events
PiGosaur Monday
2h 50m
Wardi Open
13h 50m
StarCraft2.fi
18h 50m
Replay Cast
1d 1h
The PondCast
1d 11h
OSC
1d 17h
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
2 days
Korean StarCraft League
3 days
CranKy Ducklings
3 days
SC Evo League
3 days
[ Show More ]
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
4 days
OSC
4 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
5 days
Wardi Open
5 days
StarCraft2.fi
5 days
Replay Cast
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

Proleague 2025-11-28
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.