• Log InLog In
  • Register
Liquid`
Team Liquid Liquipedia
EDT 10:10
CEST 16:10
KST 23:10
  • Home
  • Forum
  • Calendar
  • Streams
  • Liquipedia
  • Features
  • Store
  • EPT
  • TL+
  • StarCraft 2
  • Brood War
  • Smash
  • Heroes
  • Counter-Strike
  • Overwatch
  • Liquibet
  • Fantasy StarCraft
  • TLPD
  • StarCraft 2
  • Brood War
  • Blogs
Forum Sidebar
Events/Features
News
Featured News
Serral wins HomeStory Cup 2914Serral wins Maestros of the Game 243ByuL, and the Limitations of Standard Play3Team Liquid Map Contest #22: Results and Winners7Code S Season 2 (2026): RO4 and Finals Preview12
Community News
ZeroSpace Early Access is Now Live!7Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters2Balance hotfix patch 5.0.16b (July 16)71Reynor: GSL Loss Wasn't About Preparation Format16[IPSL] Spring 2026 Grand Finals - This Weekend!18
StarCraft 2
General
Balance hotfix patch 5.0.16b (July 16) Weekly Cups (July 13-19): Terran & Protoss rise; Zerg falters How would you feel about frequent/monthly balance patches for SC2? Clem: "I don't have that much hope in Blizzard" [D] Wireframe Casting Removed
Tourneys
RSL Revival: Season 6 - Qualifiers and Main Event Master Swan Open (Global Bronze-Master 2) WardiTV Summer Cup 2026 GSL CK #5 Race War HomeStory Cup 29
Strategy
[G] Having the right mentality to improve
Custom Maps
New Map Maker - Looking for Advice - Love or Hate Work In Progress Melee Maps [D]RTS in all its shapes and glory <3
External Content
Mutation # 535 Assembly of Vengeance The PondCast: SC2 News & Results Mutation # 534 Burning Evacuation Mutation # 533 Die Together
Brood War
General
HORROR STARCRAFT MOVIE BGH Auto Balance -> http://bghmmr.eu/ How Famous was FlaSh before his Debut? BW General Discussion screpdb: new Starcraft reporting tool
Tourneys
[Megathread] Daily Proleagues [IPSL] Spring 2026 Grand Finals - This Weekend! Escore Tournament - Season 3 Small VOD Thread 2.0
Strategy
Simple Questions, Simple Answers PvT advise for noobs Fighting Spirit mining rates Creating a full chart of Zerg builds
Other Games
General Games
ZeroSpace Early Access is Now Live! ZeroSpace at Steam NextFest - Last free demo Path of Exile Nintendo Switch Thread Stormgate/Frost Giant Megathread
Dota 2
Looking for a Dota Mentor Official 'what is Dota anymore' discussion
League of Legends
Heroes of the Storm
Simple Questions, Simple Answers Heroes of the Storm 2.0
Hearthstone
Deck construction bug
TL Mafia
TL Mafia Power Rank NeO.D_StephenKing vs This Guy From 1 Million Dance TL Mafia Community Thread Vanilla Mini Mafia
Community
General
US Politics Mega-thread Russo-Ukrainian War Thread How to buy a book - shipping from Korea to Europe The Games Industry And ATVI UK Politics Mega-thread
Fan Clubs
The IdrA Fan Club The HerO Fan Club!
Media & Entertainment
Movie Discussion! Anime Discussion Thread [Req][Books] Good Fantasy/SciFi books Series you have seen recently...
Sports
2024 - 2026 Football Thread TeamLiquid Health and Fitness Initiative For 2023 Formula 1 Discussion MLB/Baseball 2023 McBoner: A hockey love story
World Cup 2022
Tech Support
Computer Build, Upgrade & Buying Resource Thread Simple Questions Simple Answers FPS when play League Of Legend on laptop
TL Community
Northern Ireland Global Starcraft The Automated Ban List
Blogs
Hello guys!
LIN1s
Role of Gaming on Mental Hea…
TrAiDoS
ASL S22 English Commentary…
namkraft
Poker (part 2)
Nebuchad
An Exploration of th…
waywardstrategy
ramps on octagon
StaticNine
Customize Sidebar...

Website Feedback

Closed Threads



Active: 3366 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
Poland17797 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
Poland17797 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
Poland17797 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
Poland17797 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
Poland17797 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
WardiTV Summer Champion…
12:05
Summer Cup Group B
WardiTV784
TKL 28
LiquipediaDiscussion
[ Submit Event ]
Live Streams
Refresh
StarCraft 2
ProTech90
SHIN 67
RushiSC 13
StarCraft: Brood War
Calm 6971
Shuttle 2446
Bisu 2382
Jaedong 1244
Soma 566
Light 426
Hyuk 364
firebathero 334
Stork 320
Mini 282
[ Show more ]
Larva 252
actioN 236
Soulkey 229
Snow 206
ggaemo 187
Rush 137
hero 131
Hyun 119
Mong 115
Dewaltoss 106
Pusan 87
Sharp 67
ToSsGirL 46
soO 42
JYJ 39
Killer 38
Free 38
910 29
sorry 25
HiyA 24
Movie 21
Sacsri 17
Barracks 17
Hm[arnc] 15
Sexy 15
Bale 14
IntoTheRainbow 13
zelot 12
Rock 11
GoRush 10
Terrorterran 10
Noble 9
ajuk12(nOOB) 8
Icarus 8
Dota 2
qojqva1604
Dendi1231
syndereN363
XaKoH 286
XcaliburYe202
League of Legends
KnowMe40
Counter-Strike
fl0m2909
byalli354
Other Games
FrodaN4409
singsing2581
hiko788
B2W.Neo782
Lowko506
DeMusliM300
crisheroes297
Harstem256
Liquid`VortiX172
Hui .162
ArmadaUGS62
Livibee54
CosmosSc2 41
Trikslyr29
TKL 28
Chillindude13
Organizations
Other Games
gamesdonequick1094
StarCraft 2
Blizzard YouTube
StarCraft: Brood War
BSLTrovo
[ Show 13 non-featured ]
StarCraft 2
• StrangeGG 66
• AfreecaTV YouTube
• intothetv
• Kozan
• IndyKCrew
• LaughNgamezSOOP
• Migwel
• sooper7s
StarCraft: Brood War
• BSLYoutube
• STPLYoutube
• ZZZeroYoutube
League of Legends
• Nemesis2357
• TFBlade888
Upcoming Events
PiGosaur Cup
9h 50m
The PondCast
19h 50m
Kung Fu Cup
20h 50m
OSC
1d 9h
CrankTV Team League
1d 20h
Replay Cast
2 days
CrankTV Team League
2 days
Korean StarCraft League
3 days
Afreeca Starleague
3 days
RSL Revival
3 days
Serral vs SHIN
herO vs Solar
[ Show More ]
Online Event
4 days
Replay Cast
4 days
RSL Revival
4 days
Clem vs ByuN
Rogue vs Lambo
WardiTV Weekly
5 days
Sparkling Tuna Cup
6 days
Liquipedia Results

Completed

Acropolis #4
HSC XXIX
Eternal Conflict S2 E3

Ongoing

CSL 2026 Summer (S21)
KCM Race Survival 2026 Season 3
RSL Revival: Season 6
CranK Gathers Season 4: BW vs SC2 Team League
SCTL 2026 Spring
BLAST Bounty Summer Qual
Stake Ranked Episode 3
XSE Pro League 2026
IEM Cologne Major 2026
Stake Ranked Episode 2
CS Asia Championships 2026
Asian Champions League 2026
IEM Atlanta 2026
PGL Astana 2026

Upcoming

Escore Tournament S3: W4
ASL S22 SEASON OPEN Day 2
Escore Tournament S3: W5
CSLAN 4
Blizzard Classic Cup 2026
HSC XXX
SC4ALL II: StarCraft II
Kung Fu Cup 2026 Grand Finals
Light Tournament 2026
Eternal Conflict S2 Finale
ESL Pro League Season 24
Stake Ranked Episode 4
Logitech G Connect 2026
SL StarSeries Fall 2026
FISSURE Playground #5
BLAST Open Fall 2026
Esports World Cup 2026
BLAST Bounty Summer 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.