• Breaking News

    Wednesday, September 29, 2021

    How to start programming from zero learn programming

    How to start programming from zero learn programming


    How to start programming from zero

    Posted: 28 Sep 2021 02:15 PM PDT

    I hope mods are okay with this. I also published this text on some other page so it is not stolen.

    Intro

    It is 2021 and there are so many people working as programmers. If you want to be part of that world, you need to know the programming basics.

    Why is this post better than most of the other posts or video courses on the internet? And also how can this be a post about programming when there is not any programming language in it?

    Well, there is a difference between learning to program and learning some programming language. You could 'learn' two programming languages and there is a chance that you would still not know how to program.

    Learning a programming language is the same as learning a foreign language. Learning to program is like learning to think. When people are born they have the ability to think. That ability naturally gets better and better with time. That means most people would react in the same way in the same situation no matter where are they from. For example, if they see an accident on the road, they would call an ambulance. The only difference is that they would use their own language to describe the accident.

    The ability to think is not bounded or dictated by some language. If you learn a new language, your ability to think would not change at all. The same thing is with programming. Programming concepts are independent of programming languages.

    In this post, I will teach you programming concepts that will help you learn any programming language. Learning this way is much faster and you are not distracted by the syntax of the programming language.

    How to think like a programmer?

    This is a question that is asked by many people who wants to start with programming. And to answer it straight away - you need to use an algorithmic approach to solving problems. What does that mean exactly? I will explain it in this chapter.

    Computer programming is the process of designing and building an executable computer program. A computer program is a collection of instructions that can be executed by a computer to perform a specific task.

    In layman's terms, programming is just telling a computer what it needs to do. To describe to a computer what it needs to do, programmers use various programming languages.

    Now, I would require you to take a pen and paper or just open your favorite text editor and write down all steps you need to do to make a bowl of cereals. I will do the same thing, but I will do it in a way that is similar to describing it to a computer. After you are done you can compare yours and my result:

    My result:

    • go to the fridge and open its door
    • take out a bottle of milk and put it on the table
    • close the fridge door
    • go to a cupboard (or cabinet) and open its door
    • take out a cereal box and bowl and put those to the table, next to milk (this step depends on where you are keeping bowls and cereals)
    • close the cupboard door
    • go to the drawer with spoons and open it
    • take one spoon and close the drawer
    • go to the table, put the spoon next to a bowl
    • grab cereal box and take the plastic bag out of it (let's assume that cereals are inside a plastic bag)
    • pour cereal out of the plastic bag into a bowl until the bowl is half-full or one-third full
    • return the plastic bag to the cereal box (or throw it away if it is empty)
    • grab a bottle of milk and open it
    • pour milk over the cereal that is inside the bowl until the bowl is half full
    • close the bottle of milk and put it on the table

    And this is it, breakfast is ready.

    This is how programmers think. You can see that it is not anything complicated and that everybody can do that. In the steps above there are some extra cases that I left out for simplicity of demonstration like what if milk is not in the fridge, what if you run out of milk or cereal, what if you don't have any clean spoon or bowls, what if you dropped and broke a bowl, etc.

    But you got the idea. And in the following video, you will see what happens if you are not specific and detailed when you are writing instructions (or code). Check out this video:

    https://www.youtube.com/watch?v=cDA3_5982h8

    This is how programming works most of the time. You know what you have to do, you write code for that, and then you test does it work what it needs to do. If not, then you know that you did something wrong. You change your code and try again until you get the right solution.

    Algorithm

    In this chapter, I will explain things in a formal way.

    An algorithm is a defined set of step-by-step procedures that provides the correct answer to a particular problem.

    The algorithm needs to satisfy the following conditions to be valid:

    • same inputs always need to produce the same output
    • must be unambiguous meaning that is explicitly defined and only one interpretation is possible
    • must be finite meaning that it needs to be done in finite time and use finite space

    The best example of an algorithm that you saw in your life is a meal recipe. You know how long it will take to cook that meal, what groceries you need, and in what order you need to prepar them. And if you follow that recipe twice and make the meal in the exact same way both times you will get the same meal.

    To solve tasks with programming, the first thing we need to do is to devise an algorithm. When you are doing that, it is a good idea to write it down. There are two ways to write an algorithm - with flowchart and with pseudocode.

    Flowchart

    A flowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task.

    Each flowchart consists of its building blocks. To understand a flowchart, you first need to know what each building block means. I created this simple table so you can always return here until you learn them all.

    https://marinsborg.com/img/posts/intro-to-programming/symbols-table.jpg

    As you can see, there are not a lot of them. Some other exists but they are not important right now. I will show you how to solve tasks using only these symbols. Let's start with examples.

    Sequence

    Instructions in programs are executed in the sequence in which they are written. Let's create a flowchart for a simple task in which the user will input two numbers and the program will print out a sum of those two numbers.

    https://marinsborg.com/img/posts/intro-to-programming/sequence-diagram.jpg

    Branching

    If some part of code in the algorithm we need to execute only in case if some condition is fulfilled then we need to use branching. With branching, we can split the code into two or more paths. To show an example of branching let's create a flowchart for a program that takes the user's input which is a number and prints "Number is positive" or "Number is negative".

    https://marinsborg.com/img/posts/intro-to-programming/branching.jpg

    Loops

    Sometimes in code, we need to do the same thing several times. We always have two choices. One is to write the same code several times and the other is to use a loop. The problem with writing the same code several times is that is it not clean and it is time-consuming. That is why we should use loops.

    In computer programming, a loop is a sequence of instructions that is continually repeated until a certain condition is reached. Most of the time we write a loop with some kind of a counter so the loop knows how many times it needs to execute the same code and when to stop. Let's create a flowchart for a program that takes a number as the user's input and prints all (whole) numbers between 0 and that number.

    https://marinsborg.com/img/posts/intro-to-programming/loop.jpg

    As you can see, the loop repeats three steps: checking if variable A is lower than variable Counter, print value of variable Counter, and increase the value of variable Counter by one.

    Now try to solve this task by yourself: Make a program that takes the user's input and check if it is number 0. If it is not, then print the square of that number and if it is 0 then finish the program.

    You can check the solution on Reddit.

    Variables

    In previous tasks I always mentioned variables but I never explained what it is. Variables are locations in memory that have some name and in which we save data from the input. The value of each variable can be changed during program execution. To access the value of a variable we only need to write its name.

    Each variable has a name, a value, and a type. I will talk about data types a bit later. To assign value to a variable we need to write the name of the variable then equality sign '=' and then the value.

    For example:

    To assign a value 10 to a variable with the name 'age' we just need to write age = 10.

    If we want to change the value of the variable 'age' we can do it in the same way age = 30. That is called re-assigning.

    It is always a good idea to name variables in a descriptive way instead of using just one letter like 'A' or 'x'.

    Data types

    In computer science and computer programming, a data type or simply type is an attribute of data that tells the computer how the programmer intends to use the data. I will not bother you with the details, you just need to remember these five common data types:

    • Integer (int) - this data type is used for whole numbers. For example int age = 20 or int size = 10
    • String - this data type is used for text or sequence of characters. For example string name = "John Doe" or string sentence = "Today is a sunny day." Usually, a string is always surrounded with quotation marks
    • Character (char) - this data type is used for a single letter. char letter = 'a'
    • Float - this data type is used for numbers that contain a decimal point. For example float number = 3.14
    • Boolean (bool) - this data type is used for True or False only ( yes or no, 0 or 1). For example bool flag = True

    As I mentioned before - Each variable has a name, a value, and a type. When I write

    int age = 10

    int is the type of the variable, age is the name of the variable, and 10 is the value of that variable.

    Arithmetic operators

    In programming, you can use arithmetic operators between variables or some concrete value. Addition, subtraction, multiplication are the same as in math and division is a bit different.

    For example, you can write this:

    sum = a + b -> this will save the sum of values a and b into variable sum

    c = d - 7 -> this will save the result of subtraction to variable c

    result = 15 * 3 -> this will save 45 in variable result

    There are three 'types' of division:

    x = a/b -> this is real division

    y = 13 DIV 5 -> this is integer division and it will save 2 in variable y

    z = 13 MOD 5 -> this is remainder and it will save 3 in variable z

    Relational operators

    In computer science, a relational operator is a programming language construct or operator that tests or defines some kind of relation between two entities. These include numerical equality (e.g., 5 = 5) and inequalities (e.g., 4 ≥ 3).

    The result of the evaluation is either true or false. Relational operators are used for branching which I explained above.

    Operators are: equal to (==), not equal to (≠), greater than (>), less than (<), greater than or equal to (≥), less than or equal to (≤).

    Boolean operations

    Boolean operations come from Boolean algebra in which which the values of the variables are either true or false (1 or 0). I don't want to bother you much with Boolean algebra but there are three main operations you need to know about:

    • AND - conjunction - the result of this operation is true only when both conditions are true, otherwise false
    • OR - disjunction - the result of this operation is true when either of the conditions is true
    • NOT - negation - this operation inverts the value of the condition. If the condition is true then negation will result in false and vice versa.

    Boolean operations are also mostly used for branching and can be combined with relational operators. For example, if you have a task in which you need to check if the number is lower than 50 and it is not 7 then you would do that in a flowchart like this:

    https://marinsborg.com/img/posts/intro-to-programming/branching-operator.jpg

    And this is it. If you have understood everything so far you can say that now YOU can think like a programmer. This is the bare minimum you need to know to start with programming. This is the foundation on which you build more and more knowledge.

    You might notice that we did not start with any programming language. It is because everything above can apply to most programming languages. Now when you understand the foundation you can easily start with any programming language.

    If you do not understand some part or you need extra explanation you can always search on Google or you can ask me on Reddit

    I will give you some tasks to practice, something like homework. I will publish solutions and explanations to those tasks on Reddit in near future.

    Homework tasks

    To solve these tasks you will use the knowledge from above. For each task, you need to draw a flowchart. You can draw flowcharts online on diagrams.net

    1. Create a program that allows to user to input three numbers and print the product of that three numbers.
    2. Create a program that allows to user to input a number. Print if that number is odd or even. Hint - you need to use the remainder operator.
    3. Create a program that allows to user to input a number. Multiply that number by 2 and print it out. Repeat multiplication and printing until the result of the multiplication is not larger than 1000.
    4. Create a program that prints all numbers between 1 and 100 that are not divisible by 7 and are divisible by 5.
    5. Create a program that allows to user to input a number. If the number is 0, end the program and print "The end". Otherwise, multiply that number by itself and check if that new number is larger than 1000. If yes then print "Extra large number". If the number is larger than 500 then print "Large number", otherwise print "Small number"

    Next steps

    Once you are done with the practice tasks above you might ask what are the next thing to do or learn. It is obvious you can't do much with just a knowledge of drawing flowcharts.

    Now you can select one programming language and learn its syntax. I would recommend learning Python or JavaScript. Both languages are easy to set up on your computer and syntax is straightforward. For know, if you are at this stage of programming experience, I would recommend you to pick either Python or JavaScript and not C#, Java, or any object-oriented programming language.

    If you want to learn JavaScript and explore web development with it, you can start with The Odin Project. It is a website that will walk you through the installation of proper tools, explain how the web works, how to use git and there are basics in HTML, CSS, and JavaScript. If you like to watch videos you can find many good JavaScript tutorials on YouTube.

    If you want to learn Python which is a good programming language for multiple stuff you can follow this book - Automate the boring stuff with Python. It starts with Python basics and progresses into some real-world problems that are easily solved with Python. If you don't like it, you can always look for videos on YouTube.

    Conclusion

    In this post, I explained to you the fundamentals that you need to know to start with programming. These fundamentals are applicable to most programming languages and now you need to pick one and learn its syntax.

    Programming is not hard as it might seem. You need to be patient with yourself, invest some time and effort in understanding the basics.

    I just want to point out the importance of starting with easier tasks and then progressing towards some bigger project you might want to build. You can not learn some foreign language over the night but you will get better and better with it over time - it is the same with programming.

    When you learn the syntax of some programming language try to solve tasks from the homework chapter with that programming language.

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

    First big win!

    Posted: 28 Sep 2021 03:04 PM PDT

    Sorry, this isn't a post looking for help, I had my first big win and none of my friends or family really understand programming so I don't have anyone to share it with.

    I got hired on at a small local company for a student position over the summer as a data analyst, pretty boring stuff with no coding. They decided to keep me on for the school year and just last week I had a meeting with my boss, one of the other employees is leaving and he's the only one that knows R, they use it for some pretty minor data analytics to help the annotation team, they asked if I would be willing to learn. So I spent the past week learning R and going through his script file.

    I've managed to almost completely automate the process, before it would take someone who is familiar with the language 100's of lines of code to analyze the data, now anyone can answer a couple of prompts in the console and the rest takes care of itself.

    I know this isn't the biggest of deals, but I'm excited because this is the first time I have applied what I've been learning to a real project and managed to improve it.

    Thanks for listening!

    submitted by /u/Burnt-Marsupial
    [link] [comments]

    So funny story - I tried learning Git, ended up deleting ALL my files.

    Posted: 28 Sep 2021 05:37 AM PDT

    This happened about a week ago.

    I have a habit of just "jumping" into things when I'm learning something new. So naturally I download Git, open up my VS Code, and take a look at the source control tab on the left.

    Now, I should explain that at this point I've made a separate folder in my "programming" folder for (what would be) all my Github applications.

    Upon opening the source control tab, I noticed that it actually is displaying every single file in my programming folder - to put that into perspective, its basically just any and all files that have anything to do with programming. My entire directory that I would usually open up in VS Code. A few years of project files. This is where I begin to panic.

    In my head, I'm thinking that Git Hub is about to post my entire directory online for the world to see, so in a panic I selected everything from the "source control" tab, and deleted it. Even with the giant warning it provides saying something like "ARE YOU SURE YOU WANT TO LITERALLY DELETE EVERYTHING FOREVER?" I assumed it only meant that I was removing it from the source control tab, and not my PC.

    I'm surprised at how fast it deleted everything - quite efficient for how many files there were.

    I'm lucky that (as far as I'm aware) most files ended up in my recycle bin. after about an hour I was able to restore most of them, but it was quite a large amount of files so I still have a bit of work to do.

    Anyway just thought this was funny enough to share.

    TLDR; I thought Github was about to post all the files on my computer online, and in a panic, I deleted them from the source control tab in VS Code. What I didn't know was that the source control tab is not exclusive from the directory on my computer, so in doing so, deleted the files from my computer.

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

    I feel like my school is pushing against me learning programming

    Posted: 28 Sep 2021 07:37 PM PDT

    TL;DR at bottom if you don't feel like reading a wall today

    So, I'm a 13 year old in a middle school. I have much more experience in programming than almost anyone else in the school. Now, this is a public school with no CS courses available, so you can't expect the next person you see in the hallway to look at your computer and understand the code. But the assumptions are getting out of hand.

    I've been developing technologies to bypass my school's content blocking for a while, partially for fun and partially for programming practice. I first used screen share with noVNC, but recently have created websites and hosted proxies for the people at my school to use. It has taught me a lot about computer science, system administration, and programming.

    Now, you're probably thinking, "Well of course they don't want him hacking up all the school computers. This is bad for a learning environment, and is disruptive to his classmates." Well, yes, it is. But I'm not doing that anymore. I'm not actively developing the bypass technologies, and even if I still was, I'm not using them personally. I am, in no way, shape, or form, violating the technology agreement I had to sign when I borrowed my chromebook from the school. It says that the usage of the chromebook is not to play games, or do things online irrelevant to education. Offering a service has nothing to do with what I do on my chromebook.

    That was all to say, I probably have some bad reputation with people trying to stop me. Which makes since, but is irrelevant to what I actually do on my chromebook.

    I'm a programmer, and so I like to program things on my chromebook. I don't miss assignments and I do my work at school and home (all my grades are above 95), but I program things as well. I program things through an SSH connection to my home computer. This does not have X capability, so why should someone think I could possibly do anything like play actual video games or browse websites?

    Despite all of this, on numerous occasions when I had free time in class I was called up so I could explain to one of my teachers exactly what the scary black text screen TTY was. I explained to them I was programming something. Ironic that none of my classmates were called up when they were playing games, right?

    Today was the real kicker, though. I was told that the teachers thought that me programming on a TTY was a problem so large it needed district level attention. They said they are taking screenshots of the scary black text screen using the monitoring software, and said it might need actual disciplinary action. Now, playing games and failing your classes? Maybe. Practicing an actual future life skill and still getting your work done? Um, I don't think so.

    Ironically, my friend (same age/grade) goes to a different school where they actually encourage learning things like this. He even got to do some IT stuff (like he set up some routers for the school). Of course, people there are probably educated in this specific department.

    I just wish people would get some knowledge about things before they judged others.

    Here's a TL;DR to sum this up -

    • My school has a monitoring system to block "inappropriate" content
    • Originally, I have developed unblocking websites and used proxies and screen share technologies to bypass the system
    • More recently, I have begun coding through SSH and began to phase out of using these technologies personally (other people still use them)
    • Me coding irrelevant things has gotten me more negative attention from the school than me playing games and visiting unblocked websites. What?

    I guess what I'm trying to ask is why is my school trying to eliminate my programming? Is it just because they are not familiar with it? I can't find another reason.

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

    Just had the worst interview of my life

    Posted: 28 Sep 2021 09:30 PM PDT

    Was told the interview will be about data structures & algorithms. Interviewer asked me to implement queue using any language that I like. First, I implement it using javascript array but it wont run but I explain theoretically, I would implement it like this using push & shift. Im too nervous and I forgot the syntax. He said if no built-in method allowed, how would I implement it? I said I will use linked list with head & tail. I got lost implementing it and he didnt help at all. He said "Sorry, but we are running out of time. Thanks for your time" and ended the meeting. Ive been practicing leetcode but i cant even implement a simple queue. And the interviewer was making it worse by not saying anything. Im really not cut out for this field

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

    I started learning programming and I got upset very often and want to cry

    Posted: 28 Sep 2021 10:48 PM PDT

    So I started learning C++(first time learning coding) and sometimes I can't really think so then I feel like I am very stupid and dumb. To be a software developer is my goal and sometimes I feel like I can't reach it.Any ideas to overcome this?Sorry for my bad English.Thank you!

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

    Git Cheat Sheet from GitLab. Not sure If you already have this.

    Posted: 28 Sep 2021 06:53 AM PDT

    I found this useful and handy for day today use when working with programming, pushing codes to github or gitlab.

    Git Cheat Sheet from GitLab: https://about.gitlab.com/images/press/git-cheat-sheet.pdf

    submitted by /u/Wild-Bread4388
    [link] [comments]

    Self-Teaching/Work Balance

    Posted: 28 Sep 2021 05:33 PM PDT

    Hello all!

    Been contemplating for a while now to take a trip down this path of self-learning/teaching myself programming. Finally reached the point in my current career where I am just aimlessly logging in everyday not feeling accomplished or on a worthwhile path (mindless tasks, semi-managing books of business). It's all frustrating because we are considered a tech company, I just am in the wrong dept.

    One of the perks of being remote currently is that I have time to begin to learn and start teaching myself these new fundamentals. My question is how many of you have balanced work and teaching during the day or do you work once you log off.

    I understand and am ready for the challenge to work during the entire day. I would just like to use all hours and not limit myself to after-hours time to engage in this new environments

    Any tips/guidelines would be appreciated!

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

    If the Odin Project is free, why would anyone pay to learn from the others?

    Posted: 28 Sep 2021 05:04 AM PDT

    A simple question: I saw a lot of people here saying good things about the Odin Project. And it seems it is 100% free. So why would anyone pay for the courses from e.g. Codeacedemy/Coursera/Udemy?

    I'd guess the courses offered by the other sources must have some advantages over the Odin Project, right? So what are the things in the other sources which justify the payment?

    Basically I was wondering if the Odin Project is good enough for a beginner to learn e.g. Web dev to land a job or would it be wiser to pay to learn from other places?

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

    How to add acm libraries to IntelliJ Idea?

    Posted: 28 Sep 2021 10:59 PM PDT

    So I've recently started learning java, and I'm following a course on programming methodology, where he uses the IDE eclipse and imports acm libraries onto it. However, I've installed the IntelliJ ide, and when I try to import the act libraries it shows an error, "Cannot resolve symbol 'acm' ". Could anybody tell me how to resolve this issue?

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

    When do you feel it is appropriate to put a programming language in your resume?

    Posted: 28 Sep 2021 03:54 PM PDT

    I am currently a masters student studying information systems, but as part of that program I have taken a Java class, a Python class, and am about to start a web dev (JavaScript, html, css, php, etc) class.

    Am I a total phony if I put Java and Python on my resume? I did well in the classes, and feel that I have a solid understanding of the fundamentals, but I also recognize that one class can only teach so much. What are your thoughts on the matter?

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

    Is "THE ODIN PROJECT" a good course to follow if I want to become a Software Engineer?

    Posted: 28 Sep 2021 02:38 PM PDT

    I'm currently 19 and lost.
    I'm trying to be a YouTuber/streamer but I'm not delusional, I understand I should put a high paying career first and pursue creative ventures on the side so I don't screw myself. Currently I'm in community college for a Business Admin Ass. degree and will graduate next semester with it, but ik it will be kind of useless. After looking at high paying/in-demand/something-I'd-like jobs I found Software Engineering. I'm not rich, not the best focuser with regular school, and want to get into the career as reasonably fast as possible, so I was gonna do a bootcamp instead of doing 4ish more years of college. My plan was to teach myself as much as I can on my own for about a year, finish my Bus. Admin degree, and work to save for a bootcamp and then do a bootcamp in a year. In trying to find where to start learning I came across this sub and then "THE ODIN PROJECT" and it is really good, but it is more focused on Web Development instead of Software Engineering.

    So my questions are: Should I continue with it if I want to pursue a career in Software Engineering?, Is there something better I should be learning from/using to become a software engineer?, Is my plan to get into the industry good or am I making a mistake/being foolish?, and Is there any general advice I should know?

    Thank you to anyone that took the time to read or respond to this, I appreciate any feedback I get.

    TL;DR: Is THE ODIN PROJECT a good course to follow if I want to become a software engineer? Should I do a coding bootcamp at 20 to become a software engineer?

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

    Java debugging – String is not adding leading zeros in if-else statement

    Posted: 28 Sep 2021 11:27 PM PDT

    The full program is at this link: https://codeshare.io/JbPz6E

    This class supposed to model time in 12-hour format, and let user add or subtract times.

    I wrote series of if-else statements to add leading zeros if the hours is single digit, or if minutes are single digit, e.g. 01:06AM

    But for inputs 12:59AM and 12:59PM, I get:

    1:58AM

    1:58AM

    12:0PM

    12:0PM

    submitted by /u/ASAP-Nerd
    [link] [comments]

    Compare 2 double to 3 decimal places.

    Posted: 28 Sep 2021 11:20 PM PDT

    Compare 2 double to 3 decimal places.

    areEqualByThreeDecimalPlace(-3.1756, -3.175) --> return true

    areEqualByThreeDecimalPlace(3.175, 3.176) --> return false

    Honestly, I have no idea why I keep getting the wrong returned value. probably my logical reasoning.

    i have tried using absolute value, but that would be a problem if this

    areEqualByThreeDecimalPlace(3.175, 3.176) is to returns false

    please, somebody, tell me how to get by this. I probably would have made the code much smaller, but that didn't do me much good. my code is below

    public static boolean areEqualByThreeDecimalPlace(double firstNumber, double secondNumber){

    int first = (int) firstNumber;

    int second = (int) secondNumber;

    if(first == second){double round1 = aDoubleToInt(firstNumber, 3);

    double round2 = aDoubleToInt(secondNumber,3);

    double ep = Math.abs(round1 - round2);

    if(round1 == round2 || ep < 0.01){
    return true;
    }

    }

    return false;

    }

    public static double aDoubleToInt(double number, int decimalDigit){

    double decimalUnit = Math.pow(10,decimalDigit);

    double roundValue = number * decimalUnit;

    roundValue = Math.round(roundValue);

    roundValue /= decimalUnit;

    return roundValue;

    }

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

    Uploading a project to Git - should I include all VS 2019 files?

    Posted: 28 Sep 2021 05:19 PM PDT

    First off, I apologize if I demonstrate some misunderstanding here or if this comes off as a silly question - I am still new in my programming journey, and I appreciate any corrections anyone can offer. I checked the FAQ and searchbar and couldn't find a similar question.

    I've been studying programming for about a year now, and decided I was ready to try to put together my first portfolio project to demonstrate some of the features of OOP I've picked up. It's a text-based RPG, inspired by Zork, and while it's not complete, I've gotten some serious work done on it.

    The program has a main file as well as a number of additional files for classes I've designed for the program. I wrote the program on VS 2019, which I understand creates some additional files beyond those explicitly created/designed by the programmer (for example, a "program debug database").

    My question is - if I am going to push my project to Github to share with fellow programmers, should I push all of the files in my project folder, including the ones generated by VS 2019? Or would the existence of those files on my Github be considered unusual by more experienced programmers?

    Edit: Thank you guys for the awesome advice! Really appreciate the clarification.

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

    Program doubt (Static variable called back to the main function)

    Posted: 28 Sep 2021 11:15 PM PDT

    The output of the following program is 0 0 0 0. How?

    Please explain.

    #include<stdio.h>

    int main()

    {

    static int i=5; if(--i){ main(); printf("%d ",i); } 

    }

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

    How to return objects rather than foreign key ids (SQL)?

    Posted: 28 Sep 2021 11:14 PM PDT

    I have the current tables:

    // users id int username text password text role_id int // roles id int name text // foo id int user_id int value text 

    And am currently returning the following in my web application:

    // Getting User { id: 1, username: "bar", roleId: 1 } // Getting all roles (mapping of user's roleId to an object here happens in the frontend) [ { id: 1, name: "Admin" }, { id: 2, name: "Viewer" } ] // Getting all Foo for associated user (again mapping happens frontend) [ { id: 2, userId: 1, value: "hello" }, { id: 25, userId: 1, value: "world" }, { id: 64, userId: 1, value: "!" } ] 

    This becomes difficult to manage and would be better if all the relevant data would be returned as part of the User objects, would mean less calls to the api as well. What I would like to achieve:

    // Getting User { id: 1, username: "bar", role: { id: 1, name: "Admin" }, foos: [ { id: 2, userId: 1, value: "hello" }, { id: 25, userId: 1, value: "world" }, { id: 64, userId: 1, value: "!" } ] 

    How would I do this with SQL (using golang as my backend and writing raw SQL queries)? Is there a way to join everything in a single query or would I be better off getting each of the relevant items separately and combining the result, e.g.:

    SELECT * FROM user WHERE id='1'; // Use the above result to run a new query SELECT * FROM role WHERE id='1'; SELECT * FROM foo WHERE user_id='1'; // Combine the above three using backend 
    submitted by /u/Lemtale
    [link] [comments]

    Need help to use JavaScript to click submit button (without ID)

    Posted: 28 Sep 2021 11:11 PM PDT

    Need help to use JavaScript to click submit button (without ID), I try this but does not work :

    docuement.querySelector('input[type*="submit"]').submit();

    the form link is here:

    https://docs.google.com/forms/d/e/1FAIpQLSfQiOnXWDwgBWtDu4kQKEFHM5XiZ5Sxb2bKfrp31BxpQKLbBQ/viewform

    Hope someone to help me with the Javascript. Thanks

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

    In SQL and Databases why do Foreign Keys need to reference a unique set of values?

    Posted: 28 Sep 2021 11:07 PM PDT

    So I understand Foreign Keys need to reference either Primary Keys, Composite Keys made up of columns, or a column with a UNIQUE constraint. But: why? What's the point? Why wouldn't Foreign Keys be able to function with non-unique columns, I thought the point was just to make sure that the value that is input in the table where the Foreign Key exists also appears in the table it references, in which case I see only a question of existence rather than uniqueness. Can someone explain?

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

    The value of cheat sheets

    Posted: 28 Sep 2021 10:42 PM PDT

    When it comes to learning the basic syntax of a language, is there any use in taking notes on cheat sheets? When I say "use" I mean real tangible value.

    For the last few months, I've been going through tutorials. I find them very useful but they're slow. It takes me about a week to get the basics of a language doing 10 - 12 hours a day. I contemplated switching to just working off of cheat sheets. But then I wondered if their only use is for reference once I start building projects and should be avoided otherwise. Thoughts?

    Thank you for your help.

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

    How do you find the balance between "doing" (building projects) and "learning" (courses, books)?

    Posted: 28 Sep 2021 10:12 PM PDT

    Title says it. I know that I probably lean toward too much studying before jumping in, and even as I write that, part of me says "but there's so much important stuff you don't know yet"!

    Tell me about the cool projects you delivered even before you'd learned the ins and outs of whatever language or tech stack.

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

    serial async print javascript

    Posted: 28 Sep 2021 10:11 PM PDT

    I have been at this for hours and for the life of me cannot figure it out. Especially frustrated because I know it cant be that hard. I have tried promise chains, callbacks, async/await, and promisify-ing my print callback. Sorry I have not written them all out as I have deleted them each time one fails.

    All I am trying to do is print the result of a longer setTimeout before a shorter one.

     const print = (err, contents) => { if (err) console.error(err) else console.log(contents) } const waitLonger = (cb) => { setTimeout(() => { cb(null, 'A') }, 1000) } const waitShorter = (cb) => { setTimeout(() => { cb(null, 'B') }, 500) } 

    I am clearly missing something because in my mind "await" means js will wait for the first function to print before calling the second. I've gone in so many circles so here is my last attempt which was also my first.

    async function serial(){ const first = waitLonger(print) await first const second = waitShorter(print) await second } serial(); 

    I know there is a million ways to do this, I would love to learn them all. My head hurts. No matter if I push into a queue or make separate functions, when I run my file in node I always get:

    second first 

    Thank you for your help.

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

    I'm out of ideas, so here's what I'll do.

    Posted: 28 Sep 2021 10:04 PM PDT

    When I check back later, the top-voted comment is what I'm going to try to make for Hacktoberfest.

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

    JavaScript newbie - what is console.log() actually for??

    Posted: 28 Sep 2021 11:00 AM PDT

    Sorry this may be a dumb question- but I'm learning JavaScript. When do you ACTUALLY need console.log() ? I'm confused about it since we can use Var or let for stating variables . What's the actual importance of console.log()

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

    No comments:

    Post a Comment