|
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. |
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...
|
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).
|
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.
|
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.
|
haha norlock, that's a stab in the dark if i ever saw one.
|
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.
|
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.
|
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().
|
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...
|
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.
|
i took Intelligent Systems instead of Graph Theory D:
|
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.
|
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.
|
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.
|
|
|
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.
|
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.
|
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.
|
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.
|
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
|
|
|
|
|
|