• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 22:34
CET 03:34
KST 11:34
  • 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
[ASL22] Finals Preview: Sweet Victory!12[ASL22] Ro4 Preview: Mirror Mirror6[ASL22] Ro8 Preview: Within Reach5[ASL22] Ro8 Preview: In A Tizzy11[ASL22] Ro16 Preview: Holy Diver5
Community News
Weekly Cups (October 19-25): Clem triples first in 5.0.175Evil Geniuses - shutting down20ISSL (IntoTheTV x SOOP SC2 League): Premier6Weekly Cups (October 12-18): 5.0.17 era begins1[$1250] International ShieldBattery League92
StarCraft 2
General
SC2 Power Rank: epic29 No more SC2 streamers on team liquid? Weekly Cups (October 19-25): Clem triples first in 5.0.17 How do you feel about the mass reverts in the 5.0.17 PTR? Evil Geniuses - shutting down
Tourneys
RSL goes to London! 2026 Offline Finals Nov 21-22 ISSL (IntoTheTV x SOOP SC2 League): Premier Stellar Fest TWO the Moon (Dec 16-20) RSL 2026 Offline Finals LCQ Sign-Ups Sparkling Tuna Cup - Weekly Open Tournament
Strategy
[H] ZvP Mid-Late Game: Stalkers Collossi HT
Custom Maps
Simple Questions/Answers [G] How to playtest arcade maps [A] Nemrods 1/4 players
External Content
Mutation # 549 Endless Sparkles The PondCast: SC2 News & Results Mutation # 548 Shining Bright Mutation # 547 Temple Of Terror
Brood War
General
Bot on ladder SCHNAIL now supports Remastered Rollback Netcode in Brood War BW General Discussion [Megathread] Daily Funny Videos
Tourneys
[Megathread] Daily Proleagues [Women's StarCraft] MonstarZ vs BA 2026-10-30 Star Con San Diego 2026 Small VOD Thread 2.0
Strategy
50,000-Word Terran Builds Memo 2026-10-22 Cliff Jump Revisited (1 in a 1000 strategy) Simple Questions, Simple Answers
Other Games
General Games
Stormgate/Frost Giant Megathread Nintendo Switch Thread Mobile Legends: Bang Bang Armies of Exigo - YesYes? General RTS Discussion Thread
Dota 2
Dota 2 Champions League Season 3 Begins April 25!
League of Legends
[TL LoL EUW IHs] Teemo shall perish
Heroes of the Storm
Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Community Thread
Community
General
European Politico-economics QA Mega-thread US Politics Mega-thread R I P Patrick Stewart Russo-Ukrainian War Thread Things Aren’t Peaceful in Palestine
Fan Clubs
Reynor Fan Club The Flash Fan Club Serral Fan Club
Media & Entertainment
Anime Discussion Thread Movie Discussion! [Manga] One Piece
Sports
TeamLiquid Health and Fitness Initiative For 2023 Football (Soccer) Thread MLB/Baseball 2023
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread
TL Community
Recent Gifted Posts
Blogs
Why I built Repalyzer (1.1.…
BlueStar
Innovate or Game Over?
TrAiDoS
ShieldBattery on Mac
Kraekkling
[ASL22] Ro4 Day1 Ticket Giv…
bITt.mAN
Can Bots Beat Pros?? Starcr…
namkraft
Customize Sidebar...

Website Feedback

Closed Threads



Active: 8712 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
Poland17865 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
Turkey781 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
Poland17865 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
Poland17865 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
Poland17865 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
Poland17865 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
Replay Cast
08:00
GSL CK 6
CranKy Ducklings95
Liquipedia
OSC
07:00
Masters Cup #151: Group D
davetesta26
Liquipedia
The PiG Daily
05:30
Best Games of SC
herO vs Rogue
GuMiho vs ShoWTimE
Clem vs herO
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
RuFF_SC2 207
PiLiPiLi 43
StarCraft: Brood War
ProTech173
Sexy 73
LancerX 22
Dota 2
monkeys_forever772
PGG 232
League of Legends
JimRising 687
Counter-Strike
taco 556
Super Smash Bros
hungrybox600
Other Games
summit1g10677
WinterStarcraft296
XaKoH 295
C9.Mang0258
Maynarde136
JuggernautJason30
Organizations
Other Games
gamesdonequick790
[ Show 12 non-featured ]
StarCraft 2
• Hupsaiya 149
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• Migwel
StarCraft: Brood War
• Azhi_Dahaki10
• Pr0nogo 1
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
Other Games
• Scarra984
Upcoming Events
Sparkling Tuna Cup
7h 26m
WardiTV Invitational
9h 26m
Epic.LAN
10h 26m
IPSL
13h 26m
eOnzErG vs McRibbed
LancerX vs StRyKeR
AI Arena Tournament
14h 26m
OSC
1d 11h
Yamato Cup
1d 12h
IPSL
1d 14h
Artosis vs RiceHat
Kyrie vs Sony
Map Test Tournament
1d 20h
WardiTV Weekly
2 days
[ Show More ]
Ultimate Battle
2 days
Rush vs BeSt
Replay Cast
2 days
Rogue vs Classic
Patches Events
3 days
PiGosaur Cup
3 days
Kung Fu Cup
4 days
The PondCast
5 days
KCM Race Survival
5 days
Liquipedia Results

Completed

Proleague 2026-10-30
Blizzard Classic Cup 2026
HCC Season 3

Ongoing

Acropolis #5
KCM Race Survival 2026 Season 4
International ShieldBattery League
BSL Season 23
IPSL Winter 2026-27
PGL Masters Bucharest 2026
Stake Ranked Episode 5
1win Private Club #2
Thunderpick World Champ. '26
ESL Pro League Season 24
Stake Ranked Episode 4
1win Private Club #1
Logitech G Play Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #3
BLAST Open Fall 2026
Esports World Cup 2026

Upcoming

1xBet Invitational
SC4ALL II: Brood War
BSL 23: Non-Korean Championship
HSC XXX
Stellar Fest 2: Lunar Cup
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
RSL Offline Finals
BLAST Bounty Winter 2027
eXTREMESLAND 2026
PGL Major Singapore 2026
Stake Ranked Episode 6
BLAST Rivals Fall 2026
IEM Beijing 2026
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 © 2026 TLnet. All Rights Reserved.