Programming

java weirdness

Learn Programming - Thu, 01/17/2019 - 16:02

class X { public void proc (X p) {/prints 1/} }

class Y extends X { public void proc (X p) {/prints 2/} }

class Z extends Y { public void proc (Z p) {/prints 3/} }

class Main { public static void main(String args[]){ X x = new Z(); Y y = new Y(); Z z = new Z(); x.proc(z); } }

the program prints 2. my question is why?

submitted by /u/HadesMyself
[link] [comments]

New to designing RESTFUL API's, need some input to see if I understand it correctly

Learn Programming - Thu, 01/17/2019 - 15:53

I have been working with SOAP for a while but I am pretty new to REST API's and now it is my first time having to design one myself and I am just having a difficult time to wrap my head around it so far. I am just gonna give a simple example of what I am trying to do.

Let's say we are making a very simple API consisting of two resources: Companies and Products. Companies and Products have a one-to-many relationship. A Company can have many products, but each product only belongs to a single Company. Sounds simple enough, and it probably is as well.

Example of a response given GET:/COMPANIES/123

{

`companyname: "My stupid company"` `companyid: 123` `"links": {`

"self": {

"href": "http://[...]/companies/123",

"verbs": [

"GET"

]

},

"products": {

"href": "http://[...]/companies/123/products",

"verbs": [

"GET"

]

},

}

}

Since we have a link to a resource called Products, this means there also exists a resource called "Products":

Example of a response given GET:///PRODUCTS/456

{

`productname: "Some product"` `productid: 456` `"links": {` `"self": {`

"href": "http://[...]/products/123",

"verbs": [

"GET"

]

},

"companies": {

"href": "http://[...]/products/123/companies",

"verbs": [

"GET"

]

},

}

}

Is it enough here that companies has a link to products or do products need a link to companies as well like I did in the example? To me it sounds there needs to be a link both ways, but for some reason that kinda seems like a many-to-many relationship in this way, so I am no sure if this is the right way of doing it.

Just to give an example something I would want to query and how I think I would do it:

All the products belonging to company 123 ? -> http://[...]/companies/123/products

How about which given that productid is an unique attribute, how do I then enquire if I have a product with productid 454363, which company owns it? -> http://[...]/products/454363/companies ?

submitted by /u/Impossible_Gas
[link] [comments]

Python "Game" help

Learn Programming - Thu, 01/17/2019 - 15:49

Hi, Im trying to make a text based game, and one of my lines says

if myline == ('Homeless attacking farmers 3-5 homeless 2-4 farmers'):

rhe = (random.randint(2, 6))

rfe = (random.randint(1, 5))

if rfe == (1):

print("You see", rhe, "homeless people attacking a farmer");

if rfe != (1):

print("You see", rhe, "homeless people attacking ", rfe, "farmers");

but when i run it, it says

Homeless attacking farmers 3-5 homeless 2-4 farmers

You see {random number} homeless people attacking {random number} farmers

I want to get rid of that first line, how would i do that?

submitted by /u/404_Joy_Not_found
[link] [comments]

Kubernetes vs. Docker

Programming - Thu, 01/17/2019 - 15:44
Categories: Programming

Just had my first product put into production

Learn Programming - Thu, 01/17/2019 - 15:42

No question, not self-promotion, just super excited. I didn't graduate with a degree remotely resembling computer science and I've never been through a code boot camp, I just scraped and clawed my way into my first programming position 2 months ago and was tasked with a super small UI. The thing is more or less trivial, it's only for use by other devs, and it was a very small codebase, but I could not be more excited about it!

I just wanted to toss up some encouragement for those who don't have degrees (those who do as well, I suppose) that with a bit of hard work, you'll land the gig someday! And then once you're there, with a bit more hard work, you're going to do great!

submitted by /u/LampShadeHelmet
[link] [comments]

Programming a text game with images ?

Learn Programming - Thu, 01/17/2019 - 15:36

Hello

Beginning in programming I would like to start programming a text game like Sram where you have to write with your keyboard some instruction like "search bag" to make an action.

So I would like to programing a text game like Sram With images and everything that goes with it

Unfortunately, I have no idea where to start.

Which language is best suited to this type of request?

Which software?

Thank you.

submitted by /u/KeunoTHOR_42
[link] [comments]

Where can I learn about advanced back-end infrastructures?

Learn Programming - Thu, 01/17/2019 - 15:34

Hello everyone,

It's been a few months since I started my first programming job, as a Ruby on Rails back-end developer. Until now all I had done was adding simple features to a website.

However, the company creates enterprise web applications with complicated infrastructures combining Machine Learning, Big data and the web interface written in JS. The problem is, from my viewing point, I am standing in the middle of all of this and I feel overwhelmed when I hear people talking about stuff like Redis, Kafka, Elasticsearch, AWS, Hadoop etc. When I will get to the point when I have to actually put all these together as a back end developer I want to be able to do something and not creep all day my mentor with questions. I don't need to learn in depth machine learning or big data, just need to know the overall picture.

I have done a bit of research on these but I feel like what I actually need is a book/video course about the situations where you need this kind of infrastructure and how it all puts together... What do you recommend?

Thank you very much

submitted by /u/DaaamnYoureUgly
[link] [comments]

What are the advantages of publishing a library you made on Github?

Learn Programming - Thu, 01/17/2019 - 15:27

Hey Reddit, recently I've been working on a personal project, a library, an API. Now, after I finish it, I was wondering what am I gonna do with it. So I thought about putting it on Github. But... Why? And why not?

I've never had something on Github. I don't really know how things work there. Therefore I'm in doubt.

  1. First, how can publishing my work on the platform help me? I'm basically giving my work for people to use which I completely understand, it's not like a did something extremely great, but I'm quite proud of myself. A github does it also act as a portfolio? So when I go to university/job, I can basically tell them "hey this is my project pretty cool huh"?

  2. Also, let's say someone is using my code in commercial ways. Is that possible and okay?

  3. Also Also, its in c#, is it worth to upload it on NuGet?

Sorry for my bad English, I'm really in doubt, I worked a lot on this, I gained a lot of experience, but I don't want to keep it there in my pc and use it only for myself. And since Im not sure how everything works in this field, I'm a bit in doubt. Thanks for reading!

submitted by /u/KawaiiKuramaXD
[link] [comments]

I would like some help learning programming

Learn Programming - Thu, 01/17/2019 - 15:16

Hello! I am 18, and I am a self-taught programmer and I have been learning PHP and Python and also web development with HTML and CSS. I would like to have some people to ask questions to help me learn the mentioned or different languages and best practices when it comes to programming. Programming buddies to study or collaborate on projects with would be amazing too. Sometimes it has been hard for me without assistance to solve some problems and learn some new things without getting confused. I tried to find some CS programs in my city (Antofagasta, Chile.) However, I had no luck and I don't have enough money for mentoring. I can teach Spanish if you are interested in learning as I am a native speaker.

I would appreciate so much your help.

submitted by /u/TheKaizenWolf
[link] [comments]

Motivation?

Learn Programming - Thu, 01/17/2019 - 15:13

Heey im ok new to coding and trying to learn. Maybe 5 months ago i started coding it was rly fun but after a month i lost motivation in it. but after 2 Month i started again and had motivation. 1 month ago i lost motivation again xD. now i have motivation i now i dont want to fuck it up and really learn it fully

but is there some tips to not lose motivation?

or some tips to get better to be a overall Programmer

BTW im 14

submitted by /u/Gormhb
[link] [comments]

Advice for a beginner

Learn Programming - Thu, 01/17/2019 - 15:11

Hi there! I’m a wannnabe autodidact with a mind for mathematics, looking to expand his mind a bit. Seeing as how I hate formal education, it wasn’t long before programming called to me, as there are already a ton of resources out there for how to learn yourself. Between the top posts on this subreddit, and Harvard’s CS50 and the likes it’s a walk in the park compared to other subject. I have so many questions, so please bare with me. But first, a bit more background on me. I’m 19yo male in the US. I am currently a PCA. I graduated hs when I was 16, took 2 semesters of college before dropping out. I studied developmental psychology and geomatics. I took one cs class in high school. It was an independent learning class and I read the entire textbook and finished the class in a matter of weeks. It was Visual Basic, and I took to it very quickly. The methodical processes, combined with the concept of “abstraction” made me fall in love. Few years have passed, life has been coming at me fast and learning hasn’t been a priority of mine for a long time, but I digress. The point is, now I want to learn to code. The one thing I completely lack: an idea for a project. My goal is more to get a job making more than I do now. Which is not much. So my questions are these:

1)After I’ve learned the languages, how do I show a potential employer I can actually use them without a degree? 2)What languages are most universal and most likely to score me a job? 3)Do I have to have an idea of my own, or is there coding work that can be done without designing your own software/app? 4) What are the best and/or worst case scenarios for diving into this headfirst?

Any help is hugely appreciated. I don’t know what I’m doing, so I’m here to learn. So correct me, roast me, do what you gotta do. I gotta learn. Also, I love hearing a good success story! So brag a bit.

submitted by /u/johndabsattheend
[link] [comments]

Using other people's code

Learn Programming - Thu, 01/17/2019 - 15:02

Before I begin I want to make it clear that I would like to hear both 'moral' and 'immoral' viewpoints. Nobody is an angel and I would like to understand all options and possibilities.

I am looking at more advanced projects and obviously Git has a tonne of open source projects. Now say for example I want to produce a clone of a social media site. I can find a good few and the code is readily available.

At first, my project would be just for a learning experience but if it proved good then who is to say that monetizing it in someway would be an option (I'm covering all possibilities). I'm not lazy, it's just a matter of efficiency. For anyone who cooks it is no different in my eyes to buying something like puff pastry from a shop instead of spending many hours making it myself (also even famous chefs would never recommend making your own pastry for fear of poor results and inconsistency). Strange analogy but I think it is relevant here.

Is it practical that I write every line of code myself? Is it acceptable to use someone else's code? If so, then how much? How would I give credit? Am I correct in the notion that using someone else's code is no different from consuming someone's API or library?

Much appreciated.

submitted by /u/KSeptimus
[link] [comments]

Why does returning end a function

Learn Programming - Thu, 01/17/2019 - 15:00

Seems a pretty common rule among languages so for conceptual understanding I'd like to know why returning hard completes a function. What is the risk or problem of allowing instructions after a function return?

submitted by /u/seands
[link] [comments]

Should I be posting all my code to Github?

Learn Programming - Thu, 01/17/2019 - 14:56

I've heard two sides to this and want to know what is best for someone trying to find a career in either software or web development.

One person I heard (YouTube interview) said that before they got a job, all code they wrote they put on their Github. This person said it helped because it showed they were working on something all the time. I tend to agree with this.

I heard another differing opinion more recently though. This Lead Engineer in charge of hiring (different interview on YouTube) said that he won't look at or call an applicant if when he looks at their Github all or most of their projects are from (or seem to be) from a tutorial or tutorial based. He said to either not put tutorial projects on Github or create a private repository for them. This I can understand to cause it doesn't really give you a good indicator of the applicant's skill level. Although, tutorials do help a person learn and I would think having something is better than nothing.

Thoughts?

submitted by /u/assmayonnaise
[link] [comments]

Announcing Rust 1.32.0

Programming - Thu, 01/17/2019 - 14:47
Categories: Programming

Java: How can Comparator.comparing return a Comparator when it is a interface?

Learn Programming - Thu, 01/17/2019 - 14:42

Hi,

We have learned that when you sort by Collections.sort(someList, Comparator.comparing(e -> e.getSomeField)) that Comparator.comparing returns a Comparator object, that specifies the ordering for the sort.

How is this possible when Comparator is an interface?

Thank you so much!

submitted by /u/fedtmandspa
[link] [comments]

Pages