• Hey, guest user. Hope you're enjoying NeoGAF! Have you considered registering for an account? Come join us and add your take to the daily discourse.

I started to learn to program 4 days ago. I made a few programs. What do you think?

Status
Not open for further replies.

Lumination

'enry 'ollins
Haskell is the most beautiful programming language there is. I usually use Scheme (now Racket) or Python for first-year students, though. Haskell has some really powerful features like currying and lazy evaluation that are so damn useful it's incredible how very few people actually know about them. The abstraction model of object-oriented languages is nice and all, but achieving in Haskell with less than half the effort (and lines) of what it would take me to do something on Java makes me feel really powerful :)
How do you feel about Scala as an intro language? You can write it 99% identical to Java if that's what you'd like, but it excels in removing boilerplate that trips up newbies, and it can also be written functionally, should you choose to dip into that.
 

mclem

Member
When I was writing the second program, I wasn't immediately aware of how I was going to repeatedly ask the user for an answer if they didn't answer correctly. About halfway in, I realized that the obvious solution was to continuously invoke the asktest() method if their answer didn't match, meaning I would have to build everything into the function - except for the bucket variable holding randomnumber1.nextInt(10), as I didn't want to generate a new number each time.

In the first iteration of the program, I actually did use a while loop, as shown below -

OVd9Bxb.png




Now, even though I've only been coding for 4 days, I recognized that what I was doing in the above image was terrible. The problem was that when the method obtaintheirnumber(keyboardinput); ran within the while loop, it wouldn't change int x, because in order for it to do so, it would have to jump out of the loop, which it can only do once int x = firstrandom. As a side note, the system.out.println was supposed to be the checktheirnumber() method, but once I wasn't getting the results I wanted, I installed the print out in the while loop so I could find out what the value of x was - and I realized it wasn't changing despite the fact that I was running the obtaintheirnumber method again (because, as I figured out, it was trapped in the while loop).

I'm not quite clear what you're saying in the bolded, so I might be misunderstanding, but I think you're missing that variables can be reassigned. In that first version, x = obtaintheirnumber(keyboardinput) inside the loop should do what you want.

Were you - possibly - thrown by trying to have "int x = obtaintheirnumber" at that point, and finding that behaving oddly? That's an interesting point about scope (and I'll admit I'm thinking C rather than Java here, so I might be off on that behaviour), but I ought to check if that's the issue before I talk about why :)
 

RedShift

Member
The next thing you should look into is probably object oriented programming. It makes your code way more extendible.

For instance, your questionnaire program works fine, but if I asked you to add a third question I expect it would take a fair amount of work. If you wrote a Question class that took care of all the logic relating to asking questions, receiving answers and checking if they're correct you could add questions incredibly easily.
 

Fireblend

Banned
How do you feel about Scala as an intro language? You can write it 99% identical to Java if that's what you'd like, but it excels in removing boilerplate that trips up newbies, and it can also be written functionally, should you choose to dip into that.

I actually haven't given Scala much attention. It sounds nice though! Removing boilerplate code and having stuff like type inference is nice indeed for people starting out. Compiled Scala code running on a JVM to enable interoperability with Java libraries sounds pretty damn cool and I guess that's its main appeal, even though it's probably not a feature that is of much use in a teaching environment, at least for first year students, and I do wonder how that looks in practice.

I wonder if it can be used as a gateway drug for Java programmers to get into functional programming? :p
 

Lumination

'enry 'ollins
I actually haven't given Scala much attention. It sounds nice though! Removing boilerplate code and having stuff like type inference is nice indeed for people starting out. Compiled Scala code running on a JVM to enable interoperability with Java libraries sounds pretty damn cool and I guess that's its main appeal, even though it's probably not a feature that is of much use in a teaching environment, at least for first year students, and I do wonder how that looks in practice.
After about a year of only Scala development, I tried writing some Java recently. After typing away for about 5 minutes, I realized that I hadn't written anything of importance yet.

That, and you never have to deal with those infernal semicolons ever again.
 

Fireblend

Banned
After about a year of only Scala development, I tried writing some Java recently. After typing away for about 5 minutes, I realized that I hadn't written anything of importance yet.

That, and you never have to deal with those infernal semicolons ever again.

If you think semicolons in Java are bad, try writing anything of substance in Lisp/Scheme.
You'll be closing parenthesis (and double-checking them) hours after your last line of actual code :p
 

TVexperto

Member
Thanks for posting Codeacademy! I never knew something like this existed, now I am hooked! Are there any more interactive coding learning sites?
 

Cse

Banned
I'm not quite clear what you're saying in the bolded, so I might be misunderstanding, but I think you're missing that variables can be reassigned. In that first version, x = obtaintheirnumber(keyboardinput) inside the loop should do what you want.

Were you - possibly - thrown by trying to have "int x = obtaintheirnumber" at that point, and finding that behaving oddly? That's an interesting point about scope (and I'll admit I'm thinking C rather than Java here, so I might be off on that behaviour), but I ought to check if that's the issue before I talk about why :)

Variable scope has probably been my biggest hurdle thus far. I'll declare something in a method, and then want to use it outside the method, but will have trouble extracting it from the method. Or, I'll delcare something outside the method, and then realize I can't use it within the method, because I already have arguments defined for that method.

When I made the while loop, I thought that when I invoked the obtaintheirnumber(keyboardinput) method, it would simply filter in keyboardinput object, print the question, return the input to the integer variable theirfirstguess, and then return that integer outside of the method, effectively changing the value of the integer x.

It does this the first time the program executes, but then it hits the while loop, goes to the obtaintheirnumber(keyboardinput) method, and then runs through the method, but I think the problem was that in order to return theirfirstguess to int x, it would have to jump out of the while loop to do so, which it can't do unless the condition I declared is incorrect.

And I'm still not sure what I was thinking with int x. I just look at it now and don't even understand what I was trying to do. I just realized midway through trying to figure all of that out that I could simply bundle everything inside the method (aside from generating a random number), and then just have that method invoke itself until the user answered correctly.

It also kind of avoided the issue I've been having with variable scope, as pretty much everything was already declared inside the method.
 

railGUN

Banned
Good job so far, keep it up.

For me, coding is like golf. I love it, but I'm not great at it. I know the fundamentals, I practice lots, every once in a while I make a great shot, but I struggle putting it all together on a consistent basis.

I do remember writing a piece of code to make one of those slide puzzles with the blank square using Director / Shockwave in college, did it using like 10% of the code in the teachers answer, and he ended up using my code as the answer after I showed him.
 

Brakke

Banned
Pretty cool. I helped a buddy learn programming a little while back. The first real project I gave him was to scrape a website, which covers a bunch of topics. You might create something that takes in a GAF thread page URL, and returns a list of all the users who posted. That'll cover IO, iteration, string manipulation and parsing. You'll maybe use a regular expression or learn something about HTML.

My number one top tip is to get in the habit of writing a test method for every "actual" method you write. Test-driven development is a great practice, but even if you don't go that far, good test discipline will save your ass every day.
 

tengiants

Member
Impressive after four days. Clever use of recursion in the asktest function but probably not the best practice for needing a simple loop, but recursion like this didn't come natural to me (but I've seen for others it does) so I'm impressed.

Could probably clean up the ifs into a switch case or else if block, but nice work!
 

mclem

Member
Variable scope has probably been my biggest hurdle thus far. I'll declare something in a method, and then want to use it outside the method, but will have trouble extracting it from the method. Or, I'll delcare something outside the method, and then realize I can't use it within the method, because I already have arguments defined for that method.

The thing is, there's also scope within a loop. But I don't think that's the issue here.

When I made the while loop, I thought that when I invoked the obtaintheirnumber(keyboardinput) method, it would simply filter in keyboardinput object, print the question, return the input to the integer variable theirfirstguess, and then return that integer outside of the method, effectively changing the value of the integer x.

Do note that on that second call of Obtaintheirnumber, you're not actually assigning it to anything. It runs, generates theirfirstguess, and returns, but main does nothing with the return value and just discards it.

It does this the first time the program executes, but then it hits the while loop, goes to the obtaintheirnumber(keyboardinput) method, and then runs through the method, but I think the problem was that in order to return theirfirstguess to int x, it would have to jump out of the while loop to do so, which it can't do unless the condition I declared is incorrect.

Or just reassign it. If you were to replace that loop with this:

Code:
while (x != firstrandom) {
	[b]x = [/b]obtaintheirnumber(keyboardinput);
	System.out.println(x);
}

I think it should work. And would lead to funky stuff like (for instance) counting the number of guesses, which is possible with the recursive version, but somewhat icky!
 

Cse

Banned
Good job so far, keep it up.

For me, coding is like golf. I love it, but I'm not great at it. I know the fundamentals, I practice lots, every once in a while I make a great shot, but I struggle putting it all together on a consistent basis.

How long have you been programming?

I love computers and technology in general, and have always wanted to code. The idea of actually creating software is just....so incredibly appealing to me. It's almost addicting, and I've loved it so far.

However, I put off learning for the longest time for two reasons -

- It looked intimidating.
- I won't be good it , at least not good enough to be employed.

The first reason is slowly becoming less of a factor, as I'm becoming more familiar with the structure, motifs, patterns, etc, and any piece of code is not nearly as intimidating to me as it once was.

The second reason, however, still scares me to no end. I love it so far, and I'm almost addicted to learning more, and I love computers and technology in general, but I'm afraid of transitioning to this field, because, at the end of the day, I'm afraid I just won't ultimately been good enough for employment.

I see these undergraduates and grad students at "hackathons" hosted by universities and companies, where they have something like 24-36 hours to create a novel application. Most of them end up creating something quite cool, whether it's a new Chrome extension or a new app for Android that can receive internet data over FM radio waves. I'm just afraid that I'll never get to that level, or that I don't have what it takes to be an "excellent" programmer. I've never been strong in math, and I know that going forward, my ceiling as a programmer is going to be limited by my mathematical knowledge.

I'm definitely going to continue to learn, but that fear of failure and inadequacy, and never becoming "good" still bothers me.
 

NJDEN

Member
MORE NESTING!

jk, I know python reasonably well and I decided to teach myself the basics of HTML the other week.
 

Fireblend

Banned
How long have you been programming?

I love computers and technology in general, and have always wanted to code. The idea of actually creating software is just....so incredibly appealing to me. It's almost addicting, and I've loved it so far.

However, I put off learning for the longest time for two reasons -

- It looked intimidating.
- I won't be good it , at least not good enough to be employed.

The first reason is slowly becoming less of a factor, as I'm becoming more familiar with the structure, motifs, patterns, etc, and any piece of code is not nearly as intimidating to me as it once was.

The second reason, however, still scares me to no end. I love it so far, and I'm almost addicted to learning more, and I love computers and technology in general, but I'm afraid of transitioning to this field, because, at the end of the day, I'm afraid I just won't ultimately been good enough for employment.

I see these undergraduates and grad students at "hackathons" hosted by universities and companies, where they have something like 24-36 hours to create a novel application. Most of them end up creating something quite cool, whether it's a new Chrome extension or a new app for Android that can receive internet data over airwaves. I'm just afraid that I'll never get to that level, or that I don't have what it takes to be an "excellent" programmer. I've never been strong in math, and I know that going forward, my ceiling as a programmer is going to be limited by my mathematical knowledge.

I'm definitely going to continue to learn, but that fear of failure and inadequacy, and never becoming "good" still bothers me.

Trust me: You're much, much closer than you think to being able to do this kind of stuff. Keep at it, and you'll be more than ready to tackle problems like retrieving information from the Internet or building something that interacts with Facebook or Twitter or whatever or even connecting to something like an Arduino to automate something like the lighting in your house in a matter of months.

I learnt programming at an university, true, but it'd be naive of me to think I'm somehow inherently superior to the incredible amount of people who're learning by themselves, some of which I work alongside everyday and are some of the best devs I know. Just take a look at the latest Stack Overflow developer survey: a staggering 41% of people on that website identify themselves as self-taught. Believe me, if, after 4 days you grasp what you've demonstrated to understand in this thread, and feel the satisfaction and thrill that comes with a successful answer to a problem or clever logic in your code, you're leaps and bounds beyond a good portion of that 41% already. In a way, most good developers are self-taught. The area evolves so fast that by the time you're done with a college program 50% of what it covered has been rendered obsolete by the most recent advances and you're out of the loop. What a good university program does, and a good approach to learning even if you're self taught, is not teaching Java or Python or whatever, but teaching to learn and adapt to new tools. For example, out of college Android was this new thing that had just launched. Now I'm among other things an Android developer, and I'm sure in a couple of years I'll be learning something that hasn't been heard of yet just to continue working on projects that interest me and not get stuck as a legacy developer managing and maintaining old code. As a programmer you never stop learning.

Don't belittle yourself just because you're learning all by yourself. The amount of resources available on the web guarantees that all the information you need is out there just waiting for you to catch up with it. I'm sure you could be showing us a cool extension or app or game or whatever in a couple of months if you keep as committed to this as you've shown to be so far.
 

Brakke

Banned
Yo don't freak out about employability. You'd be surprised how far you can get with not much more than what you have. The *really* hard shit is things most professionals don't even trust themselves to do, they just import a library.

Interviewing might be tough, because dev interviewers are dumb and want you to implement red-black trees or whatever. Which is silly: they never implemented a red-black tree in their professional life.

If you get to the point where you're serious about pursing a job, you could honestly probably get by in most contexts if all you do is take a night class on Introduction To Algorithms And Data Structures or whatever class teaches Big O notation and search algorithms.
 

Cse

Banned
Trust me: You're much, much closer than you think to being able to do this kind of stuff. Keep at it, and you'll be more than ready to tackle problems like retrieving information from the Internet or building something that interacts with Facebook or Twitter or whatever or even connecting to something like an Arduino to automate something like the lighting in your house in a matter of months.

I learnt programming at an university, true, but it'd be naive of me to think I'm somehow inherently superior to the incredible amount of people who're learning by themselves, some of which I work alongside everyday and are some of the best devs I know. Just take a look at the latest Stack Overflow developer survey: a staggering 41% of people on that website identify themselves as self-taught. Believe me, if, after 4 days you grasp what you've demonstrated to understand in this thread, and feel the satisfaction and thrill that comes with a successful answer to a problem or clever logic in your code, you're leaps and bounds beyond a good portion of that 41% already. In a way, most good developers are self-taught. The area evolves so fast that by the time you're done with a college program 50% of what it covered has been rendered obsolete by the most recent advances and you're out of the loop. What a good university program does, and a good approach to learning even if you're self taught, is not teaching Java or Python or whatever, but teaching to learn and adapt to new tools.

Don't belittle yourself just because you're learning all by yourself. The amount of resources available on the web guarantees that all the information you need is out there just waiting for you to catch up with it. I'm sure you could be showing us a cool extension or app or game or whatever in a couple of months if you keep as committed to this as you've shown to be so far.

I appreciate the encouragement, it really means a lot. As mentioned, I've wanted to learn for so long (as in, years...) but have always been too afraid to just dive in. I finally just did it this past Tuesday and have loved it so far.

Still, my lack of mathematical knowledge still worries me in terms of how far I'll ultimately be able to progress if I stick with this. As a biology grad student, my mathematical toolset is slim to none. I took Calculus I at the end of my freshmen year in college, but that was 8 years ago. I'm just afraid that I'm going to reach a certain point that, in order to progress or create more efficient and complex software, I'm going to need to learn a lot more math.

This is where those with degrees have the advantage, as I believe most universities that offer a CS degree require quite a few math courses as part of the degree track (discrete math, differential equations, etc). I may be able to teach myself programming, but if there is one thing I know I can't teach myself, it's advanced mathematical concepts.
 

mclem

Member
This is where those with degrees have the advantage, as I believe most universities that offer a CS degree require quite a few math courses as part of the degree track (discrete math, differential equations, etc). I may be able to teach myself programming, but if there is one thing I know I can't teach myself, it's advanced mathematical concepts.

It rather depends on what you're trying to do. Fancy 3D graphics definitely need a background in mathematics (although I'm not sure to what end certain engines can ease that.), but other things are less mathematics-dependent.

The one aspect of mathematics which does help is logic, but that's a level of maths that people often pick up fairly easily. There's certainly formal mathematical concepts, too, things like "How to ensure a loop is guaranteed to end", but while you might not know the formal terminology to prove that, there's still an instinctive understanding of it which is much easier to grasp.
 

Fireblend

Banned
I appreciate the encouragement, it really means a lot. As mentioned, I've wanted to learn for so long (as in, years...) but have always been too afraid to just dive in. I finally just did it this past Tuesday and have loved it so far.

Still, my lack of mathematical knowledge still worries me in terms of how far I'll ultimately be able to progress if I stick with this. As a biology grad student, my mathematical toolset is slim to none. I took Calculus I at the end of my freshmen year in college, but that was 8 years ago. I'm just afraid that I'm going to reach a certain point that, in order to progress or create more efficient and complex software, I'm going to need to learn a lot more math.

This is where those with degrees have the advantage, as I believe most universities that offer a CS degree require quite a few math courses as part of the degree track (discrete math, differential equations, etc). I may be able to teach myself programming, but if there is one thing I know I can't teach myself, it's advanced mathematical concepts.

Well, I won't lie and say having a strong math knowledge base isn't a good thing to have, and you should probably at least review some of the most basic discrete math concepts (I mean, you're already using DM in your code), but for the purposes of building a cool extension or app, I think you'd be surprised how little of it you actually need, specially considering how many tools and frameworks out there help you do most if not all of the work for common mathematical tasks. Unless you're planning to build a graphics engine or implement some cryptography algorithm or something like that, I doubt you'll find any task that requires you to think too hard about math formulas or logarithms or whatever. Heck, with some of the physics engines out there, you could probably build Angry Birds without having to worry about the calculations needed for the birds' acceleration and gravity and stuff.
 

StuKen

Member
Best advice I got starting was this:

PMD

Its the most pedantic annoying son of a bitch you can possibly imagine but if you follow its suggestions you _will_ become a better programmer. There is a nice plugin for eclipse which will show you your coding flaws based off the PMD analysis. Remember, just because it compiles doesn't make it right.

Also, Law of Demeter is you friend. Never ever ever ever break it. Its the single most fundamental bit of knowledge any software engineer needs. You code will be modular, unit testable, have well defined interfaces to other code and just generally be great and wonderful.
 
Logic math is a necessity, I think everything else is optional though. Depends on whether you want to work with AI and 3D graphics or not
 

Cse

Banned
Alright, so, my previous two programs were completely worthless in that they didn't provide much utility. I was ready to learn a few new things this morning, but had an idea to create a program that was actually useful.

As mentioned previously in the thread, I'm a bio grad student, and do a lot of work in a neurophysiology lab. We conduct quite a few patch clamp experiments on unmyelinated squid axons, and usually have to calculate the amount of potassium ions that leave the cell in order to result in a given resting membrane potential. Usually, this calculation only takes about 20 seconds by hand, especially if multiple unit conversions have to be made.

However, I decided to write a program in Java that reduces this calculation down to about 3 seconds. After entering in the resting membrane potential and axon diameter, the program calculates the amount of moles of K+ (as well as the amount of ions) that had to leave the cell to result in the given resting membrane potential. For a little added flare, I also allowed the user to input the axon diameter in either millimeters or micrometers.

LDYDMZI.png



Again, I know most of you could write something like this in a few minutes (it took me about an hour and a half), but this is the first ever functional program I've written (I started 5 days ago, so that isn't saying much) that actually has some utility.

It's one thing to create some random program that does nothing of value but still works - but creating something like this that can actually serve some purpose...it just feels incredible.

Hopefully I can translate most of this into the Android API so everyone can run this application on their phone in the lab whenever they may need to.

Any suggestions on making the code more efficient would be appreciated as well. I learned quite a bit from the comments from yesterday.

Also, I suppose one thing I don't entirely understand thus far is how methods work with the dot operator. I was under the impression that the dot operator + method() only worked with objects within a class. For example, object.method(). However, as noted in the program above, I was able to use the "Math" class with a method via a dot operator, in the format of class.method(). Does it just depend on the class as to whether methods can run off the class name itself or on objects within the class?
 
Also, I suppose one thing I don't entirely understand thus far is how methods work with the dot operator. I was under the impression that the dot operator + method() only worked with objects within a class. For example, object.method(). However, as noted in the program above, I was able to use the "Math" class with a method via a dot operator, in the format of class.method(). Does it just depend on the class as to whether methods can run off the class name itself or on objects within the class?

The methods that you can call with a class name are a special type called static methods. They tend to be not used as often and in many situations making static methods results in poorly structured code, so they tend to be deemphasized in introductory material.
 

John Dunbar

correct about everything
can someone program a program where you can just write what you want it to do and it will program it for you?
 

SRG01

Member
OP, if you want to tackle more problem-solving, algorithmic problems, you should visit Project Euler. I recommend it to all my students.

Also, I highly recommend branching out to different programming languages (not simultaneously) as soon as possible. I tend to make the analogy that programming is a lot like learning a language; having more languages in your belt means that you're able to tackle problems from multiple standpoints.

For example, the Arduino programming language may be easy to use -- many schools recommend it as a part of their intro curriculums now -- but it's incredibly lacking when it comes to advanced functionalities such as interrupts.
 

Fireblend

Banned
can someone program a program where you can just write what you want it to do and it will program it for you?
Well, high-level programming languages are already abstractions of lower-level languages which are in turn abstractions of "machine language", so in a way, that already is the case. It's just that we haven't reached that high a level as to be able to use natural language quite yet :p
 

Mr.Mike

Member
Well, high-level programming languages are already abstractions of lower-level languages which are in turn abstractions of "machine language", so in a way, that already is the case. It's just that we haven't reached that high a level as to be able to use natural language quite yet :p

Natural language also depends on cultural context, has many multiple ways to express ideas, and can often be kinda imprecise. You'd need some crazy AI to parse it, or impose so many rules where it's not really " natural " language anymore.
 

Fireblend

Banned
Any suggestions on making the code more efficient would be appreciated as well. I learned quite a bit from the comments from yesterday.

Also, I suppose one thing I don't entirely understand thus far is how methods work with the dot operator. I was under the impression that the dot operator + method() only worked with objects within a class. For example, object.method(). However, as noted in the program above, I was able to use the "Math" class with a method via a dot operator, in the format of class.method(). Does it just depend on the class as to whether methods can run off the class name itself or on objects within the class?

In terms of efficience, little can be done to improve your code. Good job! If you wanted to improve it, I would probably recommend adding some error-proofing to your code. For example, make sure your code won't crash even if the user's input isn't numerical for the values you request. This can be done with a while loop and a try-catch block.

About the static methods (the Math methods) you should probably read up on object-oriented programming, which is going to be pretty useful for you anyway once you begin to create bigger stuff. Try to get a grasp on what a class, instance and other associated concepts are. Thus far you've only been working within the "Main" class, which is sufficient for the kind of stuff you've been doing but not considered a very good practice for more complex stuff.
 
Small tidbits of advice...

Spend some time if you can learning computer architecture in general. Understand how you code is compiled and/or interpreted and how it is executed on the hardware in question.

Get as familiar as you can with this and it will transition your understanding from being a competent coder once you understand all the paradigms and idioms of modern HLLs, into a "great" programmer on so many levels.

You'll also want to consider investing time in learning established design patterns, data structures and algorithms and advanced debugging techniques as it will not only massively improve your understanding of how to design code well, but will also build solid practises to improve modularity, extendibility, maintainability and robustness in what you write in a sensible and concise form that will make other coders swoon.

Also if you choose to learn C++, go straight to C++11, don't pass go and don't collect $200..
 

jon bones

hot hot hanuman-on-man action
Great work for 4 days in! Looks like you're more than willing to put the work in.

These are the topics you absolutely should be learning next:
-Object Oriented Programming - the meta-structure of your code, high-level concepts
-Data Structures - how can / should you package data together? low-level concept, very hands on
-Algorithms - using your coding tools to solve problems, repeatable frameworks to help you solve common coding tasks
 

Fireblend

Banned
Natural language also depends on cultural context, has many multiple ways to express ideas, and can often be kinda imprecise. You'd need some crazy AI to parse it, or impose so many rules where it's not really " natural " language anymore.
Yeah, obviously. Not even I can figure out what my client wants 50% of the time no matter how many times he says it :p I don't think he's even sure himself.

Writing software specs is an art :p

Speaking of data structures, you should look into lists, OP. Try writing a "Contacts" application, creating contacts, storing each of them in a list, being able to save and retrieve them to and from a file, etc. That should cover a ton of useful stuff.
 

MJLord

Member
Great work for 4 days in! Looks like you're more than willing to put the work in.

These are the topics you absolutely should be learning next:
-Object Oriented Programming - the meta-structure of your code, high-level concepts
-Data Structures - how can / should you package data together? low-level concept, very hand's on
-Algorithms - using your coding tools to solve problems

I'd add Arrays and multidimensional arrays. It's not as much as a concept as it is a good way to practice logical thinking as a beginner.
 

Zeppu

Member
OP, could you paste your code inside
Code:
 tags.  It'll be easier to give feedback than with images.

As a very minor suggestion, you should store the avogadro's number as a constant, so you won't have to do that calculation every time.  You can define floats in scientific format using the following float notation.

[CODE]double avog = 6.023e23;

Also, it's in general good practice to try and not repeat code within if blocks. In your last sample, when getting the units, just calculate diamcm within the if block. Call the other two lines outside the block. That way if you ever need to do changes to calculatevalues(), you will only have to change code at one location, not two.

Some other general recommendations involve code structuring and naming. I know you're just testing and in your first projects, but make it a habit to give functions and parameters descriptive names. If you look back at the code in a week, you'd have a hard time remembering exactly what the parameters a, b and c are. You'll have to look through the code, or to some other place where you're calling the same function to remind yourself which parameter goes where. If you give each parameter sensible values, you'll have no questions. Similarly, calculatevalues is vague, call it calculateIonCount() or whatever you deem fit.

Pretty solid work though, incredible for less than a weeks experience! Keep on reading and practising. That's all it takes.
 

itxaka

Defeatist
How long have you been programming?

I love computers and technology in general, and have always wanted to code. The idea of actually creating software is just....so incredibly appealing to me. It's almost addicting, and I've loved it so far.

However, I put off learning for the longest time for two reasons -

- It looked intimidating.
- I won't be good it , at least not good enough to be employed.

The first reason is slowly becoming less of a factor, as I'm becoming more familiar with the structure, motifs, patterns, etc, and any piece of code is not nearly as intimidating to me as it once was.

The second reason, however, still scares me to no end. I love it so far, and I'm almost addicted to learning more, and I love computers and technology in general, but I'm afraid of transitioning to this field, because, at the end of the day, I'm afraid I just won't ultimately been good enough for employment.

I see these undergraduates and grad students at "hackathons" hosted by universities and companies, where they have something like 24-36 hours to create a novel application. Most of them end up creating something quite cool, whether it's a new Chrome extension or a new app for Android that can receive internet data over FM radio waves. I'm just afraid that I'll never get to that level, or that I don't have what it takes to be an "excellent" programmer. I've never been strong in math, and I know that going forward, my ceiling as a programmer is going to be limited by my mathematical knowledge.

I'm definitely going to continue to learn, but that fear of failure and inadequacy, and never becoming "good" still bothers me.

I learned how to program by myself too, started a couple of years ago with no background of it at all.

Now I'm working mostly as DevOps (about 80% of the time dev) and I can program in ruby, python, java, JavaScript and some c. In one year I have developed a control plane that allows our business to launch our platform (or just a bunch of machines with some roles) on ANY cloud provider and have them configure themselves with all the bells and whistles (attributes, DNS, authorization, auto discovery, etc..) So easy, even management launch their our test platforms to do demos on them. It weights about 100k lines.


My point here is, dont let your lack of knowledge or your fears get in the way. Program every day or every week at least. Try different language's until one clicks with you (python is mine, so elegant). READ BOOKS! There is plenty of nice books of everything related to programming. Find a project that you like or use and try to help with a patch.

Basically, turn proframming into something that you like, and the issues of not enough knowledge will go away with a bit of time.
 

Mexen

Member
I've been writing code for nearly a decade but I'd never have the courage to post my work here(codeGAF would eat me alove).
Well done, OP for reminding me of my humble beginnings as well as taking a step to show the world what you build.
I'm gonna participate in some local hackathons and stuff, something I've always put off because I honestly write code because I enjoy it and not because I want the world to see it (which is redundant because my clients have to assess it lol), but you've sparked something in me, OP.
Keep at it.
 

TheSeks

Blinded by the luminous glory that is David Bowie's physical manifestation.
I've been trying to learn javascript via codecedemy but it's just making me bang my head against the wall due to the weird syntax of it compared to something like HTML/CSS or even Ruby.
 
You can hire another human. A good amount of app startups involve someone with a lightbulb idea working with coders

Those are pretty bad startups unless the guy with the lightbulb is bringing something to the table other than an "idea" (which is something that just about everyone has).
 
Thank you OP and everyone giving him/her support for this thread. I am in a rut with my work life, I am constantly telling others to better themselves and try to learn new things, but I never took my own advice. I had looked at buying some books about learning to program, first as a hobby, but then if I become competent at it, I will try to start a new career that gives me satisfaction, and seeing how much progress you have made in such a small amount of time has inspired me give it a try.
Subbed to the thread, good luck!
 
I started with Visual Basic, then moved on to C sharp. I can't say I'm too great at either though, but things didn't click until a week of making toy examples. My first program was an MLG name generator.
 

Makai

Member
You're just starting, so don't worry about doing things the "right" way. :)

Down the line, though -> encapsulation
 

Two Words

Member
A good simple practice on nested loops is to draw a right triangle with "*" characters. The rule is that you enter a number into the keyboard, and that number will be the height and base of the triangle. The nested loop program should print out a triangle, but you should only have code that prints out a single * at a time.


Another tip I would give is practice debugging with the debugger or debugging code even on your smaller programs. It is easier to spot bugs on smaller programs without using the debugger or using output code to debug, but it is really important to build a habit of how to find bugs with the tools that you have.
 
It took me about 2 months to get where you're in c++. Excellent job! I don't have any experience with Java, but I can see a huge similarity.

Edit: I am one of those people who just registered for programming class. I absolutely had no idea what programming is,
and how to do it. In fact I didn't know of what cout and cin meant. I remember the instructor talking about Hello world in code blocks, he tried explaining line by line, but I noticed that he had expectations that most students already took other classes like python. I struggled the first week, but when I had a grasp of the logic, I kinda got good at it. It felt like overcoming learning how to ride a bicycle for the first time. Once you learn the basic stuff the rest is a lot more manageable.
 
Status
Not open for further replies.
Top Bottom