• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 09:26
CEST 15:26
KST 22:26
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
[ASL20] Ro24 Preview Pt1: Runway112v2 & SC: Evo Complete: Weekend Double Feature3Team Liquid Map Contest #21 - Presented by Monster Energy9uThermal's 2v2 Tour: $15,000 Main Event18Serral wins EWC 202549
Community News
Weekly Cups (Aug 11-17): MaxPax triples again!10Weekly Cups (Aug 4-10): MaxPax wins a triple6SC2's Safe House 2 - October 18 & 195Weekly Cups (Jul 28-Aug 3): herO doubles up6LiuLi Cup - August 2025 Tournaments7
StarCraft 2
General
RSL Revival patreon money discussion thread Is it ok to advertise SC EVO Mod streaming here? Maestros of the Game 2v2 & SC: Evo Complete: Weekend Double Feature Playing 1v1 for Cash? (Read before comment)
Tourneys
Master Swan Open (Global Bronze-Master 2) $5,100+ SEL Season 2 Championship (SC: Evo) Sparkling Tuna Cup - Weekly Open Tournament RSL: Revival, a new crowdfunded tournament series LiuLi Cup - August 2025 Tournaments
Strategy
Custom Maps
External Content
Mutation # 487 Think Fast Mutation # 486 Watch the Skies Mutation # 485 Death from Below Mutation # 484 Magnetic Pull
Brood War
General
BW General Discussion Flash Announces (and Retracts) Hiatus From ASL ASL 20 HYPE VIDEO! New season has just come in ladder [ASL20] Ro24 Preview Pt1: Runway
Tourneys
[ASL20] Ro24 Group C [ASL20] Ro24 Group B [Megathread] Daily Proleagues [ASL20] Ro24 Group A
Strategy
Simple Questions, Simple Answers Fighting Spirit mining rates [G] Mineral Boosting Muta micro map competition
Other Games
General Games
Beyond All Reason Stormgate/Frost Giant Megathread Nintendo Switch Thread Total Annihilation Server - TAForever [MMORPG] Tree of Savior (Successor of Ragnarok)
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
Heroes of StarCraft mini-set
TL Mafia
TL Mafia Community Thread Vanilla Mini Mafia
Community
General
Russo-Ukrainian War Thread US Politics Mega-thread Things Aren’t Peaceful in Palestine European Politico-economics QA Mega-thread The Games Industry And ATVI
Fan Clubs
INnoVation Fan Club SKT1 Classic Fan Club!
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece [\m/] Heavy Metal Thread
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion
World Cup 2022
Tech Support
Gtx660 graphics card replacement Installation of Windows 10 suck at "just a moment" Computer Build, Upgrade & Buying Resource Thread
TL Community
TeamLiquid Team Shirt On Sale The Automated Ban List
Blogs
The Biochemical Cost of Gami…
TrAiDoS
[Girl blog} My fema…
artosisisthebest
Sharpening the Filtration…
frozenclaw
ASL S20 English Commentary…
namkraft
StarCraft improvement
iopq
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1739 users

The Big Programming Thread - Page 347

Forum Index > General Forum
Post a Reply
Prev 1 345 346 347 348 349 1031 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 1031 Next
Please log in or register to reply.
Live Events Refresh
WardiTV Summer Champion…
11:00
Group Stage 2 - Group B
Clem vs goblin
ByuN vs SHIN
WardiTV910
Liquipedia
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
Harstem 336
Rex 148
ProTech34
trigger 12
EnDerr 9
StarCraft: Brood War
Britney 49518
Calm 11658
Bisu 3280
Jaedong 1103
firebathero 772
EffOrt 755
BeSt 475
ggaemo 335
Stork 311
ZerO 243
[ Show more ]
Light 207
Last 203
Soulkey 178
Hyun 123
Snow 114
Barracks 113
Mind 98
hero 92
Rush 70
Nal_rA 67
TY 57
Movie 43
Backho 26
Icarus 25
Sharp 25
Yoon 21
sorry 20
Sacsri 16
JYJ15
JulyZerg 14
scan(afreeca) 13
IntoTheRainbow 7
Terrorterran 6
ivOry 3
actioN 0
Dota 2
Gorgc7464
qojqva2096
XcaliburYe264
Fuzer 210
League of Legends
Dendi975
Counter-Strike
hiko590
edward57
Super Smash Bros
Mew2King79
Other Games
singsing2022
B2W.Neo1889
DeMusliM482
crisheroes463
XaKoH 155
ToD86
ArmadaUGS67
QueenE37
Trikslyr30
ZerO(Twitch)2
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 15 non-featured ]
StarCraft 2
• davetesta14
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• HerbMon 35
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• WagamamaTV526
League of Legends
• Nemesis3419
• Jankos1086
Upcoming Events
Online Event
10h 34m
The PondCast
20h 34m
WardiTV Summer Champion…
21h 34m
Zoun vs Bunny
herO vs Solar
Replay Cast
1d 10h
LiuLi Cup
1d 21h
BSL Team Wars
2 days
Team Hawk vs Team Dewalt
Korean StarCraft League
2 days
CranKy Ducklings
2 days
SC Evo League
2 days
WardiTV Summer Champion…
2 days
Classic vs Percival
Spirit vs NightMare
[ Show More ]
CSO Cup
3 days
[BSL 2025] Weekly
3 days
Sparkling Tuna Cup
3 days
SC Evo League
3 days
BSL Team Wars
4 days
Team Bonyth vs Team Sziky
Afreeca Starleague
4 days
Queen vs HyuN
EffOrt vs Calm
Wardi Open
4 days
Replay Cast
5 days
Afreeca Starleague
5 days
Rush vs TBD
Jaedong vs Mong
Afreeca Starleague
6 days
herO vs TBD
Royal vs Barracks
Liquipedia Results

Completed

Jiahua Invitational
uThermal 2v2 Main Event
HCC Europe

Ongoing

Copa Latinoamericana 4
BSL 20 Team Wars
KCM Race Survival 2025 Season 3
BSL 21 Qualifiers
ASL Season 20
CSL Season 18: Qualifier 1
SEL Season 2 Championship
WardiTV Summer 2025
Esports World Cup 2025
BLAST Bounty Fall 2025
BLAST Bounty Fall Qual
IEM Cologne 2025
FISSURE Playground #1
BLAST.tv Austin Major 2025

Upcoming

CSLAN 3
CSL 2025 AUTUMN (S18)
LASL Season 20
BSL Season 21
BSL 21 Team A
Chzzk MurlocKing SC1 vs SC2 Cup #2
RSL Revival: Season 2
Maestros of the Game
EC S1
PGL Masters Bucharest 2025
MESA Nomadic Masters Fall
Thunderpick World Champ.
CS Asia Championships 2025
Roobet Cup 2025
ESL Pro League S22
StarSeries Fall 2025
FISSURE Playground #2
BLAST Open Fall 2025
BLAST Open Fall Qual
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.