• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EST 11:08
CET 17:08
KST 01:08
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
RSL Season 3 - Playoffs Preview0RSL Season 3 - RO16 Groups C & D Preview0RSL Season 3 - RO16 Groups A & B Preview2TL.net Map Contest #21: Winners12Intel X Team Liquid Seoul event: Showmatches and Meet the Pros10
Community News
Weekly Cups (Nov 24-30): MaxPax, Clem, herO win2BGE Stara Zagora 2026 announced15[BSL21] Ro.16 Group Stage (C->B->A->D)4Weekly Cups (Nov 17-23): Solar, MaxPax, Clem win3RSL Season 3: RO16 results & RO8 bracket13
StarCraft 2
General
Chinese SC2 server to reopen; live all-star event in Hangzhou Maestros of the Game: Live Finals Preview (RO4) BGE Stara Zagora 2026 announced Weekly Cups (Nov 24-30): MaxPax, Clem, herO win SC2 Proleague Discontinued; SKT, KT, SGK, CJ disband
Tourneys
Sea Duckling Open (Global, Bronze-Diamond) $5,000+ WardiTV 2025 Championship Constellation Cup - Main Event - Stellar Fest RSL Revival: Season 3 Tenacious Turtle Tussle
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
BGH Auto Balance -> http://bghmmr.eu/ Data analysis on 70 million replays Which season is the best in ASL? [ASL20] Ask the mapmakers — Drop your questions BW General Discussion
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 Nintendo Switch Thread The Perfect Game Path of Exile 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
Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine US Politics Mega-thread The Big Programming Thread Artificial Intelligence Thread
Fan Clubs
White-Ra Fan Club
Media & Entertainment
[Manga] One Piece Movie Discussion! Anime Discussion Thread
Sports
2024 - 2026 Football Thread Formula 1 Discussion NBA General Discussion
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Where to ask questions and add stream? The Automated Ban List
Blogs
James Bond movies ranking - pa…
Topin
Esports Earnings: Bigger Pri…
TrAiDoS
Thanks for the RSL
Hildegard
Saturation point
Uldridge
Customize Sidebar...

Website Feedback

Closed Threads



Active: 1385 users

The Big Programming Thread - Page 446

Forum Index > General Forum
Post a Reply
Prev 1 444 445 446 447 448 1032 Next
Thread Rules
1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution.
2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20)
3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible.
4. Use [code] tags to format code blocks.
Manit0u
Profile Blog Joined August 2004
Poland17493 Posts
February 19 2014 17:33 GMT
#8901
Just wanted to use this thread for a moment to vent my frustration at jquery galleries and trying to make them stay where you want them on the page...
Time is precious. Waste it wisely.
mantequilla
Profile Blog Joined June 2012
Turkey780 Posts
February 19 2014 18:19 GMT
#8902
On February 20 2014 02:29 supereddie wrote:
Show nested quote +
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).
Age of Mythology forever!
norlock
Profile Joined March 2010
Netherlands918 Posts
Last Edited: 2014-02-19 18:25:02
February 19 2014 18:24 GMT
#8903
I have a null pointer exception crash at eclipse. Meaning not the code, but eclipse in general crashes for no particular reason or event. Anyone knows what that can mean? I use openSUSE 13.11 kde 4.11, with adt bundle.
Are you human?
one-one-one
Profile Joined November 2011
Sweden551 Posts
February 19 2014 18:30 GMT
#8904
On February 20 2014 03:24 norlock wrote:
I have a null pointer exception crash at eclipse. Meaning not the code, but eclipse in general crashes for no particular reason or event. Anyone knows what that can mean? I use openSUSE 13.11 kde 4.11, with adt bundle.


Eclipse is a clusterfuck of giant proportions. Do yourself a favor and uninstall it as quickly as possible.
http://www.youtube.com/watch?feature=player_embedded&v=1BFY4R7IIP4#t=1710s
nunez
Profile Blog Joined February 2011
Norway4003 Posts
February 19 2014 18:40 GMT
#8905
haha norlock, that's a stab in the dark if i ever saw one.
conspired against by a confederacy of dunces.
Manit0u
Profile Blog Joined August 2004
Poland17493 Posts
February 19 2014 18:41 GMT
#8906
On February 20 2014 03:24 norlock wrote:
I have a null pointer exception crash at eclipse. Meaning not the code, but eclipse in general crashes for no particular reason or event. Anyone knows what that can mean? I use openSUSE 13.11 kde 4.11, with adt bundle.


It probably means that you should switch over to Kdevelop or NetBeans.
Time is precious. Waste it wisely.
supereddie
Profile Joined March 2011
Netherlands151 Posts
February 19 2014 18:52 GMT
#8907
On February 20 2014 03:19 mantequilla wrote:
Show nested quote +
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Well it all depends on the technology you're using. Most good languages support data binding for use in the UI. Then all you have to do is create a 'data class' (very simple class with only properties) and use data binding to bind the property of that class to a textbox on your UI.
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
teamamerica
Profile Blog Joined July 2010
United States958 Posts
February 20 2014 02:11 GMT
#8908
On February 20 2014 02:02 Badboyrune wrote:
Show nested quote +
On February 19 2014 23:52 teamamerica wrote:
On February 19 2014 07:01 Badboyrune wrote:
Ok so the up button functionality in android is continuing to make no sense to me. Sometimes (and I don't really know when) the up button brings you to the main activity, despite the current activity having a specified parent activity that is not the main activity and the home button supposedly calling NavUtils.navigateUpTo(), with an intent that specifies the parent activity.

The biggest issue however is that one activities up button seems to behave differently depending on what activity you navigated there from. If I'm using the up button after having navigated to the activity from the parent activity the parent activity does not get the intent that's supposed to be delivered. If however I navigate to the activity from an activity that is not the parent activity when I use the up button the intent is received as it should be.

The method handles the option items looks like this if it helps

+ Show Spoiler +

	@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Log.i(TAG, "Navigating up from ShopList");
String idname = getIntent().getStringExtra(MainActivity.EXTRA_MESSAGE);
Log.i(TAG, "idname: " + idname);
Intent upIntent = NavUtils.getParentActivityIntent(this);
upIntent.putExtra(MainActivity.EXTRA_MESSAGE, idname);
String testid = upIntent.getStringExtra(MainActivity.EXTRA_MESSAGE);
Log.i(TAG, "idname in upIntent: " + testid);
NavUtils.navigateUpTo(this, upIntent);
}
return super.onOptionsItemSelected(item);
}
}



For your 2nd problem of the intent not being received - in the parent Activity in what lifecycle callback are you checking for the intent? The line in the NavUtil documentation "This method should be used when performing up navigation from within the same task as the destination." seems to pertain to your case.

For the first problem, are you seeing all the log messages you expect? Returning home makes me think that somehow control is reaching the super.onOptionsItemSelected call...


I managed to work around the second problem by just not using intents at all and using a shared preference key-value pair which I think ended up working better for my application.

For the first issue I think I've narrowed it down to that it seems to navigate home to the main activity when I press the back button in an activity after having navigated to that activity from an activity that is not the parent activity. So the navigation goes: parent activity -> activity -> activity:up button -> parent activity in normal cases and: some activity -> activity -> activity:up button -> main activity in other cases.

It's not a big deal for my purposes since my app is small enough that it's only a very minor inconvenience when it happens, it just annoys med that I don't understand why it happens


For your 2nd problem I was asking about the lifecycle callback, because I think that in the case you're hitting back and the parent activity is not on the back stack, it will create the parent activity (so things worked out for you). But if the parent activity IS on the back stack, it will just finish() everything up to that activity. So I don't think it should trigger onCreate and it might not even trigger onStart(), which means I don't think it'll update the intent you get form getIntent().


RIP GOMTV. RIP PROLEAGUE.
phar
Profile Joined August 2011
United States1080 Posts
February 20 2014 08:13 GMT
#8909
On February 20 2014 01:48 darkness wrote:
When you apply for Software Engineer jobs, do you get discrete math questions such as probability of something to happen (combinatorics)? I've just had to deal with such a test. Needless to say how it slightly caught me offguard because I am in year 3, and my last mathematical module was in year 1... I have chosen the software path not the pure computer science although the degree is still called computer science, but the programme is software development.

Maybe the purpose is to weed out some candidates even though they do not expect perfect scores?

Never heard of something like that. Sounds like a completely useless interview question which gains you no useful information about the candidate.

Unless the company is in a somewhat unique position that they require their engineers to know combinatorics I guess?

Wait are you talking about an interview question, or some kind of exam in Uni? Because in the latter case, all bets are off...
Who after all is today speaking about the destruction of the Armenians?
Cambium
Profile Blog Joined June 2004
United States16368 Posts
Last Edited: 2014-02-20 08:32:27
February 20 2014 08:29 GMT
#8910
On February 20 2014 17:13 phar wrote:
Show nested quote +
On February 20 2014 01:48 darkness wrote:
When you apply for Software Engineer jobs, do you get discrete math questions such as probability of something to happen (combinatorics)? I've just had to deal with such a test. Needless to say how it slightly caught me offguard because I am in year 3, and my last mathematical module was in year 1... I have chosen the software path not the pure computer science although the degree is still called computer science, but the programme is software development.

Maybe the purpose is to weed out some candidates even though they do not expect perfect scores?

Never heard of something like that. Sounds like a completely useless interview question which gains you no useful information about the candidate.

Unless the company is in a somewhat unique position that they require their engineers to know combinatorics I guess?

Wait are you talking about an interview question, or some kind of exam in Uni? Because in the latter case, all bets are off...


Counting permutations and combinations is probably the most often asked interview questions for programming jobs. Graph theory? YES.

Now, if they ask you something about Matroids (which I learned in my advanced algorithms course), then you can just tell them go to hell and die.

I know you studied Software Engineering, but you are effectively looking for Computer Science jobs. Computer science is effectively maths, so software and maths are extremely closely related, extremely.
When you want something, all the universe conspires in helping you to achieve it.
icystorage
Profile Blog Joined November 2008
Jollibee19350 Posts
February 20 2014 08:37 GMT
#8911
i took Intelligent Systems instead of Graph Theory D:
LiquidDota StaffAre you ready for a Miracle-? We are! The International 2017 Champions!
Manit0u
Profile Blog Joined August 2004
Poland17493 Posts
February 20 2014 08:48 GMT
#8912
On February 20 2014 03:52 supereddie wrote:
Show nested quote +
On February 20 2014 03:19 mantequilla wrote:
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Well it all depends on the technology you're using. Most good languages support data binding for use in the UI. Then all you have to do is create a 'data class' (very simple class with only properties) and use data binding to bind the property of that class to a textbox on your UI.


You need 3 objects.

1. Data object, where your data will be stored.
2. Update object, loads data from the data object and allows for its alteration.
3. Preview object, loads data from the data object but doesn't allow for its alteration.

From here on, it depends on how do you actually want to handle this. Do you need multiple objects with various data in them or just one that's being constantly updated?

If you need many, then the update object should load data from the data object (default values) and create a new instance of the data object as a save button action. You'll have to add options for loading and overwriting the new instances of the data object (it can simply be a text file that stores data, not necessarily many objects or anything like that, it all depends on how do you want to handle this).

If you can get by with just one data object that's constantly being updated then it's all fine and dandy (just remember to add a function in it to reset it to the default values).

I am currently working on something similar, although I took the approach of automating as much of the process as I can. Here's the code (it's a bit messy because it's still WIP and has some debugging features included which will be removed after all the testing):


#pragma strict_types

#include "../puzzle.h"

// global variables
private nosave int active_cube = 0;
private nosave int *cubes = ({ 1, 2, 3, 4, 5 });
private nosave int *displays = ({ 1, 2, 3, 4, 5 });
private nosave int *holes = ({ 1, 2, 3, 4, 5 });
private nosave int *values = ({ 16, 17, 18, 19, 20 });
private nosave string *patterns = ({ " ",
"= ",
"== ",
"=== ",
"==== ",
"=====" });

// prototypes
public int query_cube(int x, string filepath, string funcname);
public int query_display(int x, string filepath, string funcname);
public int query_value(int x, string filepath, string funcname);
public int query_hole(int x, string filepath, string funcname);
public int empty_hole(int x, string filepath, string funcname);
public int query_active_cube();
public string query_pattern(int x, string filepath, string funcname);
public void set_hole(int x, int y, string filepath, string funcname);
public void set_active_cube(int x, string filepath, string funcname);
public void remove_cube(int x, string filepath, string funcname);
public void return_cube();
public void update_values();
public void reset_puzzle();
private int validate_data(int n, string filepath, string funcname,
int errscope);
private int * shuffle_array(int *arr);


// data retrieval
public int query_cube(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);

return cubes[n];
}

public int query_active_cube()
{
return active_cube;
}

public int query_display(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);

return displays[n];
}

public int query_value(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);

return values[n];
}

public int query_hole(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);

return holes[n];
}

public string query_pattern(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 5);

return patterns[n];
}

// data manipulation
private int validate_data(int n, string filepath, string funcname,
int errscope)
{
if (n < 0)
{
LOGGER->write_error_log(n, filepath, funcname, errscope);

return 0;
}

if (n > errscope)
{
LOGGER->write_error_log(n, filepath, funcname, errscope);

return errscope;
}

return n;
}

public void set_hole(int x, int y, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);
int cube = validate_data(y, filepath, funcname, 5);

holes[n] = cube;
}

public void remove_cube(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);

cubes[n] = 0;
}

public void return_cube()
{
int i = 0;

/* locate first missing cube in the array and replace it */
while (i < 5)
{
if (!query_cube(i, DATA, "return_cube"))
{
cubes[i] = active_cube;

break;
}

i += 1;
}
}

public int empty_hole(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 4);

holes[n] = 0;
}

public void set_active_cube(int x, string filepath, string funcname)
{
int n = validate_data(x, filepath, funcname, 5);

active_cube = n;
}

public void update_values()
{
int sum = 0;

/* test for presence of cubes */
for (int i = 0; i < 5; i += 1)
{
if (query_hole(i, DATA, "update_values"))
{
sum += holes[i];
}
}

/* update values across all displays */
for (int i = 0; i < 5; i += 1)
{
values[i] = displays[i] + sum;
}
}

public void reset_puzzle()
{
int n = 0;

/* restore all available cubes */
while (n < 5)
{
if (!cubes[n])
{
cubes = ({ 1, 2, 3, 4, 5 });

break;
}

n += 1;
}

/* remove cubes from holes under displays */
for (int i = 0; i < 5; i += 1)
{
empty_hole(i, DATA, "reset_puzzle");
}

/* reset data */
shuffle_array(displays);
shuffle_array(cubes);
update_values();
}

private int * shuffle_array(int *arr)
{
for (int i = 0; i < 5; i += 1)
{
int s = random(5);
int tmp = arr[i];

arr[i] = arr[s];
arr[s] = tmp;
}

return arr;
}


That's just the data object which also serves as an interface for various other objects.
Time is precious. Waste it wisely.
Tobberoth
Profile Joined August 2010
Sweden6375 Posts
Last Edited: 2014-02-20 08:57:26
February 20 2014 08:56 GMT
#8913
On February 20 2014 03:19 mantequilla wrote:
Show nested quote +
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Personally, I would do it like Microsoft MVC handles it, you would have one controller for the whole object, which has three methods: create, edit (update) and details (view). Each one of those has a separate view. While there could be code duplication, there's a good chance there's enough differences in these three situations to warrant this separation.

This just seems like the textbook way to handle this with the MVC pattern, at least. You would supply the same actual data object in all three situations. In an MVVC implementation (Model-ViewModel-View-Controller), you would have three different viewmodels for the model, and use these for the different controller actions. This makes sense if the model object is complex and you need "extra" properties in the various actions.
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-02-20 11:35:21
February 20 2014 10:54 GMT
#8914
On February 20 2014 17:13 phar wrote:
Show nested quote +
On February 20 2014 01:48 darkness wrote:
When you apply for Software Engineer jobs, do you get discrete math questions such as probability of something to happen (combinatorics)? I've just had to deal with such a test. Needless to say how it slightly caught me offguard because I am in year 3, and my last mathematical module was in year 1... I have chosen the software path not the pure computer science although the degree is still called computer science, but the programme is software development.

Maybe the purpose is to weed out some candidates even though they do not expect perfect scores?

Never heard of something like that. Sounds like a completely useless interview question which gains you no useful information about the candidate.

Unless the company is in a somewhat unique position that they require their engineers to know combinatorics I guess?

Wait are you talking about an interview question, or some kind of exam in Uni? Because in the latter case, all bets are off...



It was some online assessment from that company. The first part was 3 programs from Codility's website (again, math based with little time to make code nice), the second part was called problem solving. All questions were probability. E.g. you have 3 couples, 6 chairs, what's the probability that each wife sits next to her husband, what's the probability that 2 wives sit next to their husbands; 2nd example is: you have 4 cities and they are all connected to each other by a narrow line. After a storm, all lines have 1/2 probability to be blocked. What's the possibility that 1 city is completely isolated? Then 2... etc.

Edit: One more. X% like chocolate, Y% like cheese, Z% like some other stuff. What's the probability that none of three three is liked? What's the probability that all three are liked? What's the probability that exactly one is liked?


I really don't feel like this online assessment for a "Graduate Software Engineer" has shown anything relevant. Maybe the problem solving part, but I dunno if combinatorics is that necessary for this position. Oh well, they've messaged me that I didn't have an enough qualifying mark. Hopefully other job applications don't ask me such questions.
Thor.Rush
Profile Joined April 2011
Sweden702 Posts
February 20 2014 12:40 GMT
#8915
Hi, I'm looking to start programming as a hobby and learn how to create Android apps. I was thinking of beginning with this book:

http://www.amazon.com/Java-Programming-Android-Developers-Dummies/dp/1118504380

And then moving on to:

http://www.amazon.com/Learning-Mobile-App-Development-Hands-/dp/032194786X/ref=sr_1_1?s=books&ie=UTF8&qid=1392899886&sr=1-1&keywords=learning mobile app development a hands-on guide to building apps with ios and android

Do any of you have a better idea on how I should begin this journey? Thanks.
| SaSe | Naniwa |Stephano | LucifroN | Mvp | MarineKing | ByuN | Polt | MC | Parting |
supereddie
Profile Joined March 2011
Netherlands151 Posts
February 20 2014 16:46 GMT
#8916
On February 20 2014 17:48 Manit0u wrote:
Show nested quote +
On February 20 2014 03:52 supereddie wrote:
On February 20 2014 03:19 mantequilla wrote:
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Well it all depends on the technology you're using. Most good languages support data binding for use in the UI. Then all you have to do is create a 'data class' (very simple class with only properties) and use data binding to bind the property of that class to a textbox on your UI.


You need 3 objects.

1. Data object, where your data will be stored.
2. Update object, loads data from the data object and allows for its alteration.
3. Preview object, loads data from the data object but doesn't allow for its alteration.

From here on, it depends on how do you actually want to handle this. Do you need multiple objects with various data in them or just one that's being constantly updated?

If you need many, then the update object should load data from the data object (default values) and create a new instance of the data object as a save button action. You'll have to add options for loading and overwriting the new instances of the data object (it can simply be a text file that stores data, not necessarily many objects or anything like that, it all depends on how do you want to handle this).

If you can get by with just one data object that's constantly being updated then it's all fine and dandy (just remember to add a function in it to reset it to the default values).

I'm confused now. But perhaps it is terminology that confuses me. Please define 'data object'. Is it some sort of object that handles loading/saving/deleting/etc data from a data store (like a database, text file, web service, whatever). Or is it an object that has the data and is being passed around to your different classes for manipulation/validation/etc?

On February 20 2014 17:48 Manit0u wrote:
I am currently working on something similar, although I took the approach of automating as much of the process as I can. Here's the code (it's a bit messy because it's still WIP and has some debugging features included which will be removed after all the testing):


*snip*


That's just the data object which also serves as an interface for various other objects.

Please try to apply 'Seperation of Concerns' to your design. It will greatly improve maintainability later on.
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
Shield
Profile Blog Joined August 2009
Bulgaria4824 Posts
Last Edited: 2014-02-20 16:51:14
February 20 2014 16:50 GMT
#8917
What's the programming language that Manit0u uses on his post? It looks like one from the C family. Maybe C#? It resembles some hybrid of Java + C I think.
Manit0u
Profile Blog Joined August 2004
Poland17493 Posts
Last Edited: 2014-02-20 17:23:45
February 20 2014 17:15 GMT
#8918
On February 21 2014 01:46 supereddie wrote:
Show nested quote +
On February 20 2014 17:48 Manit0u wrote:
On February 20 2014 03:52 supereddie wrote:
On February 20 2014 03:19 mantequilla wrote:
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Well it all depends on the technology you're using. Most good languages support data binding for use in the UI. Then all you have to do is create a 'data class' (very simple class with only properties) and use data binding to bind the property of that class to a textbox on your UI.


You need 3 objects.

1. Data object, where your data will be stored.
2. Update object, loads data from the data object and allows for its alteration.
3. Preview object, loads data from the data object but doesn't allow for its alteration.

From here on, it depends on how do you actually want to handle this. Do you need multiple objects with various data in them or just one that's being constantly updated?

If you need many, then the update object should load data from the data object (default values) and create a new instance of the data object as a save button action. You'll have to add options for loading and overwriting the new instances of the data object (it can simply be a text file that stores data, not necessarily many objects or anything like that, it all depends on how do you want to handle this).

If you can get by with just one data object that's constantly being updated then it's all fine and dandy (just remember to add a function in it to reset it to the default values).

I'm confused now. But perhaps it is terminology that confuses me. Please define 'data object'. Is it some sort of object that handles loading/saving/deleting/etc data from a data store (like a database, text file, web service, whatever). Or is it an object that has the data and is being passed around to your different classes for manipulation/validation/etc?

Show nested quote +
On February 20 2014 17:48 Manit0u wrote:
I am currently working on something similar, although I took the approach of automating as much of the process as I can. Here's the code (it's a bit messy because it's still WIP and has some debugging features included which will be removed after all the testing):


*snip*


That's just the data object which also serves as an interface for various other objects.

Please try to apply 'Seperation of Concerns' to your design. It will greatly improve maintainability later on.


It's confusing because your specifications were pretty vague. You stated you need "3 objects" and what they have to do in pretty general terms. What you need to do is figure out the way to store your data (a class, a text file, a database?) and then various ways of accessing and modifying it. It's hard to explain

SoC will come soon enough, I need to clean this thing up

On February 21 2014 01:50 darkness wrote:
What's the programming language that Manit0u uses on his post? It looks like one from the C family. Maybe C#? It resembles some hybrid of Java + C I think.


It's LPC: http://en.wikipedia.org/wiki/LPC_(programming_language)

I really like it since you get to really feel OOP in it. Also, shadowing is the best thing ever. Maybe I'll move to Pike some day, it seems nice too.
Time is precious. Waste it wisely.
supereddie
Profile Joined March 2011
Netherlands151 Posts
February 20 2014 17:25 GMT
#8919
On February 21 2014 02:15 Manit0u wrote:
Show nested quote +
On February 21 2014 01:46 supereddie wrote:
On February 20 2014 17:48 Manit0u wrote:
On February 20 2014 03:52 supereddie wrote:
On February 20 2014 03:19 mantequilla wrote:
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Well it all depends on the technology you're using. Most good languages support data binding for use in the UI. Then all you have to do is create a 'data class' (very simple class with only properties) and use data binding to bind the property of that class to a textbox on your UI.


You need 3 objects.

1. Data object, where your data will be stored.
2. Update object, loads data from the data object and allows for its alteration.
3. Preview object, loads data from the data object but doesn't allow for its alteration.

From here on, it depends on how do you actually want to handle this. Do you need multiple objects with various data in them or just one that's being constantly updated?

If you need many, then the update object should load data from the data object (default values) and create a new instance of the data object as a save button action. You'll have to add options for loading and overwriting the new instances of the data object (it can simply be a text file that stores data, not necessarily many objects or anything like that, it all depends on how do you want to handle this).

If you can get by with just one data object that's constantly being updated then it's all fine and dandy (just remember to add a function in it to reset it to the default values).

I'm confused now. But perhaps it is terminology that confuses me. Please define 'data object'. Is it some sort of object that handles loading/saving/deleting/etc data from a data store (like a database, text file, web service, whatever). Or is it an object that has the data and is being passed around to your different classes for manipulation/validation/etc?

On February 20 2014 17:48 Manit0u wrote:
I am currently working on something similar, although I took the approach of automating as much of the process as I can. Here's the code (it's a bit messy because it's still WIP and has some debugging features included which will be removed after all the testing):


*snip*


That's just the data object which also serves as an interface for various other objects.

Please try to apply 'Seperation of Concerns' to your design. It will greatly improve maintainability later on.


It's confusing because your specifications were pretty vague. You stated you need "3 objects" and what they have to do in pretty general terms. What you need to do is figure out the way to store your data (a class, a text file, a database?) and then various ways of accessing and modifying it. It's hard to explain

Heh, I never said anything of the sort . It was mantequilla who posted the orginal question.
"Do not try to make difficult things possible, but make simple things simple." - David Platt on Software Design
Manit0u
Profile Blog Joined August 2004
Poland17493 Posts
February 20 2014 17:29 GMT
#8920
On February 21 2014 02:25 supereddie wrote:
Show nested quote +
On February 21 2014 02:15 Manit0u wrote:
On February 21 2014 01:46 supereddie wrote:
On February 20 2014 17:48 Manit0u wrote:
On February 20 2014 03:52 supereddie wrote:
On February 20 2014 03:19 mantequilla wrote:
On February 20 2014 02:29 supereddie wrote:
On February 20 2014 02:25 mantequilla wrote:
Guys, help me work out a simple object oriented design.

I have an object and will have 3 forms for operations on that object:

1) A create form, which will have fields of the object and a save button. Fields will be filled by user and when user clicks the save button, a new object will be created.
2) An update form. This will be very much like the create form, but will take the object as an argument and the fields will be already filled with that object's data. When user changes some values and clicks save button, existing object will be updated.
3) A view form. And this will be like the update form, but won't have a save button, plus fields will be read-only.

How would you design something like this? Abstract classes, interfaces etc...

To start with it looks like you only need one form that has multiple states (and operations tied to these states).


That crossed my mind but that causes too many if-else state checks (makes code hard to follow) and makes difficult to change some state without affecting the others (for example changing a color in a field when form's in some state).

Well it all depends on the technology you're using. Most good languages support data binding for use in the UI. Then all you have to do is create a 'data class' (very simple class with only properties) and use data binding to bind the property of that class to a textbox on your UI.


You need 3 objects.

1. Data object, where your data will be stored.
2. Update object, loads data from the data object and allows for its alteration.
3. Preview object, loads data from the data object but doesn't allow for its alteration.

From here on, it depends on how do you actually want to handle this. Do you need multiple objects with various data in them or just one that's being constantly updated?

If you need many, then the update object should load data from the data object (default values) and create a new instance of the data object as a save button action. You'll have to add options for loading and overwriting the new instances of the data object (it can simply be a text file that stores data, not necessarily many objects or anything like that, it all depends on how do you want to handle this).

If you can get by with just one data object that's constantly being updated then it's all fine and dandy (just remember to add a function in it to reset it to the default values).

I'm confused now. But perhaps it is terminology that confuses me. Please define 'data object'. Is it some sort of object that handles loading/saving/deleting/etc data from a data store (like a database, text file, web service, whatever). Or is it an object that has the data and is being passed around to your different classes for manipulation/validation/etc?

On February 20 2014 17:48 Manit0u wrote:
I am currently working on something similar, although I took the approach of automating as much of the process as I can. Here's the code (it's a bit messy because it's still WIP and has some debugging features included which will be removed after all the testing):


*snip*


That's just the data object which also serves as an interface for various other objects.

Please try to apply 'Seperation of Concerns' to your design. It will greatly improve maintainability later on.


It's confusing because your specifications were pretty vague. You stated you need "3 objects" and what they have to do in pretty general terms. What you need to do is figure out the way to store your data (a class, a text file, a database?) and then various ways of accessing and modifying it. It's hard to explain

Heh, I never said anything of the sort . It was mantequilla who posted the orginal question.


It gets confusing when you have 6 nested quotes
Time is precious. Waste it wisely.
Prev 1 444 445 446 447 448 1032 Next
Please log in or register to reply.
Live Events Refresh
Next event in 52m
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
LamboSC2 502
Fuzer 302
BRAT_OK 62
gerald23 53
MindelVK 17
StarCraft: Brood War
Calm 4142
Shuttle 1885
Horang2 1794
Jaedong 1238
Mini 539
EffOrt 452
Light 333
Rush 297
ZerO 263
hero 247
[ Show more ]
Snow 153
Hyun 130
Sharp 67
ToSsGirL 30
sorry 29
Terrorterran 27
JYJ24
soO 24
Aegong 22
Rock 18
scan(afreeca) 15
Dota 2
Gorgc5605
qojqva3453
singsing2858
Dendi1174
syndereN339
Counter-Strike
zeus121
oskar103
Other Games
DeMusliM926
hiko870
FrodaN447
Hui .386
Liquid`VortiX115
QueenE90
KnowMe51
nookyyy 46
Trikslyr24
ZerO(Twitch)19
Organizations
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
sctven
[ Show 16 non-featured ]
StarCraft 2
• poizon28 20
• Reevou 8
• Adnapsc2 4
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Dota 2
• C_a_k_e 2875
• WagamamaTV477
League of Legends
• TFBlade1126
Upcoming Events
StarCraft2.fi
52m
Replay Cast
7h 52m
The PondCast
17h 52m
OSC
23h 52m
Demi vs Mixu
Nicoract vs TBD
Babymarine vs MindelVK
ForJumy vs TBD
Shameless vs Percival
Replay Cast
1d 7h
Korean StarCraft League
2 days
CranKy Ducklings
2 days
WardiTV 2025
2 days
SC Evo League
2 days
BSL 21
3 days
Sziky vs OyAji
Gypsy vs eOnzErG
[ Show More ]
OSC
3 days
Solar vs Creator
ByuN vs Gerald
Percival vs Babymarine
Moja vs Krystianer
EnDerr vs ForJumy
sebesdes vs Nicoract
Sparkling Tuna Cup
3 days
WardiTV 2025
3 days
OSC
3 days
BSL 21
4 days
Bonyth vs StRyKeR
Tarson vs Dandy
Replay Cast
4 days
Wardi Open
4 days
StarCraft2.fi
4 days
Monday Night Weeklies
5 days
Replay Cast
5 days
WardiTV 2025
5 days
StarCraft2.fi
5 days
PiGosaur Monday
6 days
StarCraft2.fi
6 days
Liquipedia Results

Completed

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

Ongoing

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

Upcoming

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

1. ByuN
2. TY
3. Dark
4. Solar
5. Stats
6. Nerchio
7. sOs
8. soO
9. INnoVation
10. Elazer
1. Rain
2. Flash
3. EffOrt
4. Last
5. Bisu
6. Soulkey
7. Mini
8. Sharp
Sidebar Settings...

Disclosure: This page contains affiliate marketing links that support TLnet.

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.