stefanbund / cis155

3 stars 5 forks source link

Week 6 Discussion #14

Open kayvee opened 8 years ago

kayvee commented 8 years ago

Now that you are gaining experience in the development of fairly large java applications, what do you think about creating multiple classes, to support an application? What advantages did making several objects give you? Normally we reserve the instruction on objects and classes until the end of an introductory class like this, but I teach them straight out of the gate. What advantages do having objects give you?

I think, firstly, that teaching OOP/object logic at the beginning of a Java class is a wise move. Java is essentially structured to work as an OOP language. The advantage of several objects is the modular approach to solving a problem. I can think of things in piecemeals rather than trying to figure out an entire system. Though one can in functional or also just "regular" programming, the simplification and interactions of objects makes sense with certain programs, especially where there are multiple parts to the whole. I can have my stock class be 'done,' and know all it needs to know. Then I can have my market class be the same, and only call the stocks in the sense that it needs. The market doesn't need all the information a stock has. It just needs what it, well, needs.

stefanbund commented 8 years ago

Thanks for the encouragement. The challenge comes when we basically dump tons of technical information on students. This can't be easy… But we are learning how to do this. So long as students think in terms of objects, they are vastly advantage versus other undergraduate Computer science students.

I recently was told by a computer science student that this class equaled the first two classes he took as a CS major… This was a nice complement, coming from an enrollee at a major Polytechnic University… so as long as you are moving through it, you should know you are on track to do well in the major

From Stefan

On Mar 10, 2016, at 9:18 PM, Kaveh Varjoy notifications@github.com wrote:

Now that you are gaining experience in the development of fairly large java applications, what do you think about creating multiple classes, to support an application? What advantages did making several objects give you? Normally we reserve the instruction on objects and classes until the end of an introductory class like this, but I teach them straight out of the gate. What advantages do having objects give you?

I think, firstly, that teaching OOP/object logic at the beginning of a Java class is a wise move. Java is essentially structured to work as an OOP language. The advantage of several objects is the modular approach to solving a problem. I can think of things in piecemeals rather than trying to figure out an entire system. Though one can in functional or also just "regular" programming, the simplification and interactions of objects makes sense with certain programs, especially where there are multiple parts to the whole. I can have my stock class be 'done,' and know all it needs to know. Then I can have my market class be the same, and only call the stocks in the sense that it needs. The market doesn't need all the information a stock has. It just needs what it, well, needs.

— Reply to this email directly or view it on GitHub.

WesleyTo commented 8 years ago

Coming from Python, Ruby, C++, Objective-C, etc..., I'm very used to OOP at this point. It's certainly application specific, but using OOP in the right situation (especially with inheritance) greatly simplifies things, allowing you to take advantage of class hierarchies(if applicable), intuitive problem modeling, and modularity, as well as good OOD principles, like single-responsibility and open/closed (generally, SOLID).

kayvee commented 8 years ago

@WesleyTo :

What would you say are good practices in continuing to learn to program? It seems as though you have a very solid background. I've worked in Python primarily, and usually just on NLP/language data, so I'm coming to this class to gain those 'general' skills.

WesleyTo commented 8 years ago

@kayvee As is true in most things, it's important to develop good habits. I was a CS major at Berkeley, so that certainly helped reinforce good habits. I graduated recently, but hadn't used Java since freshman year, so I took this class as a refresher (more on that below).

Focusing on the big picture is a major one. If you focus on the big picture, you will start seeing patterns among the problems you encounter, and pattern recognition is quite possibly the most important skill a programmer can have. You have to practice and work hard at it, though. Recognizing a problem in the real-world is much harder than in class or in interviews. The real-world is dirty, and messy, but if you abstract and look at the big picture, most of the time you'll recognize the problem as something you've solved before, or as something others have solved/attempted to solve.

Which leads to the next good practice: asking for help. No one lone-wolfs it anymore, at least not on anything interesting. Talk to people on your team, or go on StackOverflow. 99.9% of the time, the general problem you're trying to solve has been encountered before in one form or another.

Never stop learning. If all else fails, you will have to lean back on your knowledge, and the more you have, the better. At any given time, I'll have 4 or 5 programming / software engineering books, 1 or 2 classes (Community College, Udacity, Coursera, etc... including this one), and plenty of programming challenges (Project Euler, LeetCode, etc...) that I'm working through. Community college is a great resource, so are MOOCs. So are hackathons, MeetUps, conferences, the list goes on.

Lastly, relax. It's good practice to step away from a problem for a while. Refresh yourself, and let your subconscious keep churning away at the problem. There have been plenty of times where I stepped away from a hard problem, and the solution comes to me a few hours later, seemingly out of nowhere, while I'm eating dinner or doing something else mundane. Red-lining your brain all the time will only degrade your code, not improve it.

stefanbund commented 8 years ago

Great comment. I was especially interested in the notion of pattern recognition, in the process of software analysis. This is very true when approaching real business problems other social problems people need us to solve.

I had an individual ask me about what I was doing in a Starbucks the other day, as I was laying down some code. I told him that I was programming for a project, and they said 'oh you must be good at math.' I told him software engineering had more to do with orchestrating social behaviors, rather than doing straight up calculations.

I also told him that people are asking for software to act as a form of referee or governor over certain cultural interactions. Thus, we have to think about how to push individuals in certain directions. This surprised him, as he did not believe that software exerted that kind of influence over the culture.

From Stefan

On Mar 14, 2016, at 6:27 PM, Wesley To notifications@github.com wrote:

@kayvee As is true in most things, it's important to develop good habits. I was a CS major at Berkeley, so that certainly helped reinforce good habits. I graduated recently, but hadn't used Java since freshman year, so I took this class as a refresher (more on that below).

Focusing on the big picture is a major one. If you focus on the big picture, you will start seeing patterns among the problems you encounter, and pattern recognition is quite possibly the most important skill a programmer can have. You have to practice and work hard at it, though. Recognizing a problem in the real-world is much harder than in class or in interviews. The real-world is dirty, and messy, but if you abstract and look at the big picture, most of the time you'll recognize the problem as something you've solved before, or as something others have solved/attempted to solve.

Which leads to the next good practice: asking for help. No one lone-wolfs it anymore, at least not on anything interesting. Talk to people on your team, or go on StackOverflow. 99.9% of the time, the general problem you're trying to solve has been encountered before in one form or another.

Never stop learning. If all else fails, you will have to lean back on your knowledge, and the more you have, the better. At any given time, I'll have 4 or 5 programming / software engineering books, 1 or 2 classes (Community College, Udacity, Coursera, etc... including this one), and plenty of programming challenges (Project Euler, LeetCode, etc...) that I'm working through. Community college is a great resource, so are MOOCs. So are hackathons, MeetUps, conferences, the list goes on.

Lastly, relax. It's good practice to step away from a problem for a while. Refresh yourself, and let your subconscious keep churning away at the problem. There have been plenty of times where I stepped away from a hard problem, and the solution comes to me a few hours later, seemingly out of nowhere, while I'm eating dinner or something mundane. Red-lining your brain all the time will only degrade your code, not improve it.

— You are receiving this because you commented. Reply to this email directly or view it on GitHub: https://github.com/stefanbund/cis155/issues/14#issuecomment-196598211

pricedjp commented 8 years ago

@stefanbund @kayvee I am behind in the class and am trying to get caught up. I am working through lesson 10 and am stuck. Every time I try and fix my code I just seem to make it worse. I am going to post nine screen shots of my Brain & Stock (in order from top to bottom) and was hoping someone in the class might be able to help me fix the errors in my code. So I can try and get back on track. I'd appreciate any help I can get.

picture_1_cis_155 picture_2_cis_155 picture_3_cis_155 picture_4_cis_155 picture_5_stock_cis_155 picture_6_stock_cis_155 picture_7_stock_cis_155 picture_8_stock_cis_155 picture_9_stock_cis_155

kayvee commented 8 years ago

@pricedjp

Delete or comment lines 44 to 57. You have that code right above it, it isn't wrapped in a method, and it's causing some errors due to syntax errors.

Also, make sure to post pictures of your code in order. I saw the middle of your code and wrote this at first instead:

"It looks like your code from line 50 to 58 isn't in a method. On line 46, add:

private void setSymbol();

Also, delete or comment out your current lines 44 and 45. You aren't getting letter by letter now. Your loop is calling getRandomLetter four times."

On Wed, Mar 16, 2016 at 10:10 AM, pricedjp notifications@github.com wrote:

@stefanbund https://github.com/stefanbund @kayvee https://github.com/kayvee I am behind in the class and am trying to get caught up. I am working through lesson 10 and am stuck. Every time I try and fix my code I just seem to make it worse. I am going to post nine screen shots of my Brain & Stock (in order from top to bottom) and was hoping someone in the class might be able to help me fix the errors in my code. So I can try and get back on track. I'd appreciate any help I can get.

[image: picture_1_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821475/1d40e4cc-eb5f-11e5-92cb-a1cd62131687.PNG [image: picture_2_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821481/201543c8-eb5f-11e5-95bd-0839141b67c5.PNG [image: picture_3_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821485/25a2aea2-eb5f-11e5-83d8-4c28fb32f097.PNG [image: picture_4_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821489/286eeab0-eb5f-11e5-98ff-b2e4593f89ab.PNG [image: picture_5_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821492/2b2542f4-eb5f-11e5-8394-260c18cc4c3b.PNG [image: picture_6_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821497/2dcc3e4a-eb5f-11e5-86e6-fd359c087a51.PNG [image: picture_7_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821504/30d78298-eb5f-11e5-9f48-38b6d5ff6def.PNG [image: picture_8_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821509/33606598-eb5f-11e5-9474-a1b7c9300f96.PNG [image: picture_9_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821515/394b0f6c-eb5f-11e5-8509-5399789aa9a8.PNG

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/stefanbund/cis155/issues/14#issuecomment-197432528

pricedjp commented 8 years ago

Thanks @kayvee Here are photos of my braincenter following the edits your recommended:** (1) image (2) image

Here are photos of my Stock.java following the edits:

(1) image (2) image (3) image (4) image image

kayvee commented 8 years ago

Great, @pricedjp . Let me see if I can pinpoint some errors for you, which should hopefully help other bits fall into place.

Also, as a side note, if you click on those red 'x' next to the numbers of the lines, you should see what the errors are and some possible solutions.

in brainCenter:

1) Remove the "}" in line 20 and 28.

2) Add "}" in line 57.

I think that in this file, you just have "}" in the wrong section and too many times.

in brainCenter:

1) Comment out lines 44-54.

This section is from the setSymbol() method, which you have completed in lines 30-42.

2) Add a } between lines 69 (after return result;) and 70 (before }).

Your else statement is not closed with the } in this section.

3) Add a } between lines 96 (after return rv;) and 97 (before }).

Same as #2. Your if statement is not closed with the } in this section.

4) In line 128, "}" is supposed to be a "{".

Some general tips:

1) Remember, for every }, you should find the matching { that it closes.

2) Make sure to 'clean' your code as you go. Have { line up with }, and everything indent when you do something 'new' that depends on something else (e.g., indent after an if).

I think the main thing throwing you off is the basic layout of a java file (indenting cleanly) and managing your { and } openings and closings. Other than that, you seem to be doing fine!

Good luck! Fix the above and let me know if it still doesn't work/you still have errors.

kayvee commented 8 years ago

@WesleyTo :

Thank you for taking the time to write all of that! Definitely a nice boost in the way I'm looking at things. I recently have been participating (actively) in a few Coursera courses and am learning Python and web design, along with a Java coursera series, so it's nice seeing all of these things being used by a 'real' CS major/grad as well.

pricedjp commented 8 years ago

Thanks @kayvee was a huge help.

Here is my braincenter following the edits you suggested.

(1) image (2) image

And the "in Stock" (1) image (2) image (3) image (4) image (5) image (6) image

kayvee commented 8 years ago

@pricedjp :

brainCenter

1) on line 19: remove the "}"

2) On line 27: remove the not "{".

You are removing the l.printPriceAndIPOQTY(); statement on line 26 from the main method. You are also blocking the code from line 44 onwards.

3) On line 55: I'm not sure why your 'out' is not coding correctly. Click on the red 'x' next to the line to see some solutions.

General) in your brainCenter, basically everything should be under your 'main' method (for now).

Stocks

1) Lines 77-80: delete them. You already have a setIndustry() function in lines 118-139.

Like I said, I think you can just do with going through the code with a finebrush comb for details like this to clean it. Watch the videos again and follow the code as it's being written. Compare it to what you have. Remove excess code and combine where possible. Watch your { and }.

Good luck!

pricedjp commented 8 years ago

thanks @kayvee

I made the changes you suggested. Most of the code is fixed. But for some reason I can't get a few finals lines of code to stop showing an error.

brainCenter:

(Line 5) { expected after token"

(Line 8) multiple markers at this line

(Line 15) multiple markers at this line constructor undefined duplicate local variable

image

(Line 56) syntax error, insert { to complete block (Line 58) multiple markers at this line

image

Stock.java

(Line 56) this method must return a result of type string

image

kayvee commented 8 years ago

@pricedjp

brainCenter

1) In line 6, it should be a {, not a }. Like I said, make sure to pay attention to these brackets, as there should always be a { at the beginning of a section and a } at the end of one. Right now, it looks like you are closing your entire brainCenter class on line 6.

public class brainCenter 
{ 
    public static void main(String[] args) 
    { 
        // Market m = new Market(6100);
        ...etc...

2) In line 56, I think you want to have this be a } rather than a {.

Stocks

I'm wondering if this again has to do with the { and } of the code. It looks like that should work. 'result' is a string, and it is what is being returned. So it should be fine. If you could post your entire code somewhere more accessible, it would be easier to see. Looking at the images is a bit hard with no context. You can go to the following websites to share code for a certain amount of time:

http://pastebin.com/

stefanbund commented 8 years ago

Get random letter is in need of else if, not just else. This is what causes the result to fail at the end.

From Stefan

On Mar 16, 2016, at 10:44 AM, Kaveh Varjoy notifications@github.com wrote:

@pricedjp

Delete or comment lines 44 to 57. You have that code right above it, it isn't wrapped in a method, and it's causing some errors due to syntax errors.

Also, make sure to post pictures of your code in order. I saw the middle of your code and wrote this at first instead:

"It looks like your code from line 50 to 58 isn't in a method. On line 46, add:

private void setSymbol();

Also, delete or comment out your current lines 44 and 45. You aren't getting letter by letter now. Your loop is calling getRandomLetter four times."

On Wed, Mar 16, 2016 at 10:10 AM, pricedjp notifications@github.com wrote:

@stefanbund https://github.com/stefanbund @kayvee https://github.com/kayvee I am behind in the class and am trying to get caught up. I am working through lesson 10 and am stuck. Every time I try and fix my code I just seem to make it worse. I am going to post nine screen shots of my Brain & Stock (in order from top to bottom) and was hoping someone in the class might be able to help me fix the errors in my code. So I can try and get back on track. I'd appreciate any help I can get.

[image: picture_1_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821475/1d40e4cc-eb5f-11e5-92cb-a1cd62131687.PNG [image: picture_2_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821481/201543c8-eb5f-11e5-95bd-0839141b67c5.PNG [image: picture_3_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821485/25a2aea2-eb5f-11e5-83d8-4c28fb32f097.PNG [image: picture_4_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821489/286eeab0-eb5f-11e5-98ff-b2e4593f89ab.PNG [image: picture_5_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821492/2b2542f4-eb5f-11e5-8394-260c18cc4c3b.PNG [image: picture_6_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821497/2dcc3e4a-eb5f-11e5-86e6-fd359c087a51.PNG [image: picture_7_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821504/30d78298-eb5f-11e5-9f48-38b6d5ff6def.PNG [image: picture_8_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821509/33606598-eb5f-11e5-9474-a1b7c9300f96.PNG [image: picture_9_stock_cis_155] https://cloud.githubusercontent.com/assets/16979043/13821515/394b0f6c-eb5f-11e5-8509-5399789aa9a8.PNG

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub https://github.com/stefanbund/cis155/issues/14#issuecomment-197432528

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

stefanbund commented 8 years ago

I was tracing the error back to screenshot number one. In this, you are creating a new stock object by sending it a long string. This is probably not the way to do it. Don't send the long quoted string into the stock object. It is probably not expecting that input.

From Stefan

On Mar 16, 2016, at 12:40 PM, pricedjp notifications@github.com wrote:

Thanks @kayvee ** Here are photos of my braincenter following the edits your recommended: (1)

(2)

Here are photos of my Stock.java following the edits:

(1)

(2)

(3)

(4)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

stefanbund commented 8 years ago

If you are to take a look at the stock object, the constructor there is not prepared to handle the input you're sending it from the brain center. Check out the stock() function in the stock object, it will not take any input parameters, and you're sending it some.

From Stefan

On Mar 16, 2016, at 3:24 PM, pricedjp notifications@github.com wrote:

Thanks @kayvee was a huge help.

Here is my braincenter following the edits you suggested.

(1)

(2)

And the "in Stock" (1)

(2)

(3)

(4)

(5)

(6)

— You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub

forrestbennett commented 8 years ago

Looking back at our project, I could not imagine doing it without creating multiple classes. Creating separate objects make all the intricate moving piece manageable. Also, compartmentalizing each object allows you too test them individually and hone them separately.