|
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. |
On February 18 2014 01:21 Akka wrote: Isn't that an empty menubar? Hm, i didnt specify any so it's null. JMenuBar mb = new JMenuBar(); setJMenuBar(mb); mb.setVisible(false); Doesnt work either. Edit: If i do have a menubar and its visible, there's still the same margin below the menubar.
|
personally i strictly follow the RGM standard.
|
On February 18 2014 00:07 darkness wrote:Do you guys follow the SOLID principles and to what extent? Some points may be debatable in detail, but for OOP languages, would you ever not follow these? I guess aside from working with existing code where conforming to those principles would take more effort than you can spare, and quick 100 line programs. Which tend to turn into bigger programs anyways, so you would still want to do them properly...
|
On February 18 2014 02:27 spinesheath wrote:Some points may be debatable in detail, but for OOP languages, would you ever not follow these? I guess aside from working with existing code where conforming to those principles would take more effort than you can spare, and quick 100 line programs. Which tend to turn into bigger programs anyways, so you would still want to do them properly...
Okay then, I have a specific question based on:
The Single Responsibility Principle
There should never be more than one reason for a class to change. Basically, this means that your classes should exist for one purpose only. For example, let's say you are creating a class to represent a SalesOrder. You would not want that class to save to the database, as well as export an XML-based receipt. Why? Well if later on down the road, you want to change database type (or if you want to change your XML schema), you're allowing one responsibility's changes to possibly alter another. Responsibility is the heart of this principle, so to rephrase there should never be more than one responsibility per class.
Source: codeproject
If I have a class that wraps a grid (2D array) that offers methods to enter a value for an index or get a value from an index, can I still use the same class for validation purposes? E.g. to check if a number is in boundaries. I'm kind of confused if this would count as two responsibilities: 1) (wrapping a grid, set/get a value) and 2) validation? Or maybe responsibility may be very high level such as "grid management", so in this class 1) and 2) are just 1 responsibility.
|
Edit: Scratch that, I don't think it was very good advice in the end :/ You might want to change your validation process at some point, so if you view the validation step as something separate from the grid (or like, additional to it), I say go ahead, make them 2 classes.
|
On February 18 2014 08:02 darkness wrote:Show nested quote +On February 18 2014 02:27 spinesheath wrote:On February 18 2014 00:07 darkness wrote:Do you guys follow the SOLID principles and to what extent? Some points may be debatable in detail, but for OOP languages, would you ever not follow these? I guess aside from working with existing code where conforming to those principles would take more effort than you can spare, and quick 100 line programs. Which tend to turn into bigger programs anyways, so you would still want to do them properly... Okay then, I have a specific question based on: Show nested quote + The Single Responsibility Principle
There should never be more than one reason for a class to change. Basically, this means that your classes should exist for one purpose only. For example, let's say you are creating a class to represent a SalesOrder. You would not want that class to save to the database, as well as export an XML-based receipt. Why? Well if later on down the road, you want to change database type (or if you want to change your XML schema), you're allowing one responsibility's changes to possibly alter another. Responsibility is the heart of this principle, so to rephrase there should never be more than one responsibility per class.
Source: codeprojectIf I have a class that wraps a grid (2D array) that offers methods to enter a value for an index or get a value from an index, can I still use the same class for validation purposes? E.g. to check if a number is in boundaries. I'm kind of confused if this would count as two responsibilities: 1) (wrapping a grid, set/get a value) and 2) validation? Or maybe responsibility may be very high level such as "grid management", so in this class 1) and 2) are just 1 responsibility.
The Array would have the validations, but the actual Validator that handles validations would be a separate class.
http://api.rubyonrails.org/classes/ActiveModel/Validations.html
class Person include ActiveModel::Validations
validates_presence_of :name end
Sometimes things can't be simply explained you need to read more than just a few acronyms to understand this sort of stuff. Have a look at Responsibility Driven Design.
|
Is anyone familiar with agent programming, agentspeak and/or Json?
|
On February 18 2014 09:55 Zorkmid wrote: Is anyone familiar with agent programming, agentspeak and/or Json?
I think you mean Jason not Json. JSON is a different thing.
Edit: Websites such as Codility and OnlineJudge annoy me... what's the point? I think they just promote sloppy code in favour of quicker implementation.
|
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); } }
|
On February 18 2014 10:34 darkness wrote:Show nested quote +On February 18 2014 09:55 Zorkmid wrote: Is anyone familiar with agent programming, agentspeak and/or Json? I think you mean Jason not Json. JSON is a different thing. Edit: Websites such as Codility and OnlineJudge annoy me... what's the point? I think they just promote sloppy code in favour of quicker implementation.
Yes you're right.
|
So we got an assignment (long term, 4-5 months time) to create a quiz-system. Basically, they want us to create a powerpoint-like application specialized in creating quizzes (the kind of quizzes where there's a guy presenting it to groups of people who write down answers on paper). We're currently planning on implementing in Qt, because I think creating the GUI is a lot easier than with java's swing (We have to use an OO language, so preferably java or c++).
The main question I have are about packages, are there any packages available which we should use? Some packages for creating a workspace for the slides for example is something we'll really would like and have no idea where to look for.
|
Hiya all, I want to learn some web programming - and decided that I want to use C# and .NET for it. Do you know any good books to start with? I know about Headfirst C# and C# for dummies, but they mostly only cover desktop or console application. I would like to get right into web programming since it would make learning a bit more fun!
The best thing i found so far is http://www.w3schools.com/ASPnet/default.asp and where should i start : webpages, mvc or web forms? Thanks for your help
|
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...
|
kitaman27
United States9245 Posts
For the TL Mafia subforum, we have put together a simple php site that uses a mysql database to record game and player records
http://tlmafiadatabase.sourceforge.net/.
Whenever I attempt to update or insert a record, the database does reflect the change, however when I attempt to run the select query a second time, it returns a result set as if the update or insert never took place. The updates and inserts are permanent so it doesn't seem like a rollback issue.
When I clear the web browser's cache and cookies and reload the page, the select statement does return the updated records, so are there perhaps any caching issues that I might need to look into?
My php knowledge is pretty limited, so any suggestions would certainly be appreciated. Thanks!
+ Show Spoiler [Code] +Upon page load, selectplayers is called and will return player A and B. I then call deleteplayer to remove B and the record is indeed removed from the database. I call selectplayers a second time and it still returns player A and B. If I clear the cache and reload the page, it returns only player A. function selectplayers() { $db = new db("mysql-t","user","password","database"); $id = $db->escape($_REQUEST["id"]); $db->execute("SELECT name FROM players WHERE id=$id"); $db->close(); //echo result set to page }
function deleteplayer() { $db = new db("mysql-t","user","password","database"); $id = $db->escape($_REQUEST["id"]); $db->execute("DELETE FROM players WHERE id=$id"); $db->close(); }
|
This might not be considered directly in the scope of this thread, but I'm looking to learn a bit more about Twitch.tv's engineering culture and structure. If someone who works there could give me some insight it would be greatly appreciated.
|
On February 19 2014 23:33 Makavw wrote:Hiya all, I want to learn some web programming - and decided that I want to use C# and .NET for it. Do you know any good books to start with? I know about Headfirst C# and C# for dummies, but they mostly only cover desktop or console application. I would like to get right into web programming since it would make learning a bit more fun! The best thing i found so far is http://www.w3schools.com/ASPnet/default.aspand where should i start : webpages, mvc or web forms? Thanks for your help 
http://www.asp.net/mvc/tutorials
Start from there. Start with MVC, it's will learn you some design method that is easy to maintain.
On February 18 2014 10:34 darkness wrote:Show nested quote +On February 18 2014 09:55 Zorkmid wrote: Is anyone familiar with agent programming, agentspeak and/or Json? I think you mean Jason not Json. JSON is a different thing. Edit: Websites such as Codility and OnlineJudge annoy me... what's the point? I think they just promote sloppy code in favour of quicker implementation.
That surely depends on what goals you have for your code. When I play around with them, I usually make two solutions, one that is pragmatically correct and one that's fast as hell. You learn a lot from both ways of designing code.
|
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?
|
On February 19 2014 23:52 teamamerica wrote:Show nested quote +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
|
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...
|
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).
|
|
|
|
|
|