Sign in to follow this  
Followers 0
ShellBox

I'm really getting frustrated.

206 posts in this topic

Edit:    simplezz's response one page back is more succinct than mine and says the same thing... Just can't bring myself to delete all this typing... :)  Probably best to refer to that one instead.

 

 

I'm going to elaborate on Seabizkit's response here.  With no offence intended to Seabizkit, his answer is a good one, but I think the description is a little difficult for a total novice to wrap his head around.

  • Class: A template
  • Object:  A thing based on that template that elaborates on it

An object is a filled-in template (that can actually do stuff, too).  The fields you fill in on the template are variables (integers and strings for example).  When you fill in fields of the template you create an "object".  So a class isn't a thing, it's a description of a thing.  An object is a thing.

 

The class can be a tea cup, a car, or an internet connectivity device.  It can be anything because you're making it.  An "object" is created by filling in the template of a class.  

 

Do you have a car?  I do, too!  We both have cars, but our cars are different from one another, even though they're both cars.

 

Both of our cars have:

  • Two, Three, or four doors
  • A colour
  • Standard or automatic

These are called "attributes", and we hold them in variables

 

Both of our cars can:

  • Go forward (accelerating at a specific speed)
  • Reverse (accelerating at a specific speed)
  • Lock and unlock the doors

These are called "methods", and we make these things happen with functions.

 

So now we can make a class of a car.  (ignore the exact syntax -- it'll change from language to language)

 

class Car
{
   
       public:
       // Attributes:  things that describe this car
       int doorCount;
       string colour;
       bool isAutomatic;
 
       // Methods:  things the car can do
       Car::Car (int doorCount, string colour, bool isAutomatic);    // This is the "constructor", a special type of method that's used to filled in the template (create an object of this class)
 
       GoForward (int speed);
       GoReverse (int speed);
       LockDoors (bool lockOrUnlock);          // true = lock the doors; false = unlock the doors
}
 
Now it's time to make two objects out of this class:  my car and your car.  My car is red.  Yours is blue.  We call the constructor to fill in the template.
 
Car myCar(4, "Red", false);
Car yourCar(2, "Blue", true);
 
Now have two cars.  One is a 4 door red car with standard transmission.  The other is a 2 door blue car with automatic transmission.  We can make as many cars with this template as we like.
 
We can make our cars go in different directions or lock/unlock the doors by creating methods and calling them.  Does that make sense?
1 person likes this

Share this post


Link to post
Share on other sites

You're asking for a whole computer science course here... Narrow your questions to what you need to do the job right now.

 

I'll answer the immediate questions above:

 

- Boolean (Why can it only be true and false?)

 

For the same reason the alphabet only has letters in it and not numbers or symbols.  The nature of boolean is that it's either true or false.

 

- Integer (What's the difference between an integer and a short for example)

 

You don't really have to worry about it.  Just use integers.

 

I don't understand this bit though, everyone says that I need to learn what these are and when I ask what they are people say that I'll learn that in university.

Share this post


Link to post
Share on other sites

I don't understand this bit though, everyone says that I need to learn what these are and when I ask what they are people say that I'll learn that in university.

A Boolean is just defined as a true or false value. The keyword in C# for it is bool.

It's named after a mathematician named George Boole because he specialized in logic, which has true or false answers. :)

An Integer is just a whole number. In C# there are 8 that are defined:

Signed values - SByte, Int16, Int32 and Int64. There are keywords you can use instead: sbyte, short, int, and long.

Unsigned values - Byte, UInt16, UInt32 and UInt64. Keywords: byte, ushort, uint, ulong.

In some languages char is the same as sbyte, but in C# a char value is a single character like 'q' or ' '.

Share this post


Link to post
Share on other sites

Also, I wouldn't bother with obfuscation right now. It's just a way of making your code harder to understand, usually for the purpose of protecting it.

Wikipedia's OOP article is a good place to start on that topic. The overview in the article is fairly straightforward and you can browse the other sections for more specific answers.

Everyone's description of class and object is about what I'd describe... A class is a type of thing, an object is a reference to a specific thing.

(A Car is a class, my Car is an object.)

Share this post


Link to post
Share on other sites

I don't understand this bit though, everyone says that I need to learn what these are and when I ask what they are people say that I'll learn that in university.

I like to define my own boolean type in C. It's basically just two values, usually true or false, yes or no, etc. It's intended to represent truth logic and allows the programmer to control program flow. For example:

 

#define _GNU_SOURCE
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

/* create a new boolean data type */
typedef enum { TRUE, FALSE } boolean;

void
main ( void )
{
     char *input = NULL;
     boolean Happy;
     
     puts ( "Are you Happy? Type yes or no" );
     
     getline ( &input, NULL, stdin );
     Happy = ( 0 == strcmp ( input, "yes" ) ) ? TRUE : FALSE;
         
     if ( TRUE == Happy )
        puts ( "You are Happy :)" );
     else
        puts ( "You aren't Happy :(" ); 

     free ( input );
}
It can also make the code more readable than using 1 or 0, or other values. It doesn't really matter what values TRUE and FALSE have as long as the meaning is consistent in the code.

Share this post


Link to post
Share on other sites

Also, I wouldn't bother with obfuscation right now. It's just a way of making your code harder to understand, usually for the purpose of protecting it.

Obfuscation can also be an unintended consequence. OOP especially can lead to it.

Here's an interesting blog post about how OOP can go wrong. It's old but still accurate: http://www.codinghorror.com/blog/2007/03/your-code-oop-or-poo.html

Share this post


Link to post
Share on other sites

I like to define my own boolean type in C. It's basically just two values, usually true or false, yes or no, etc. 

 

/* create a new boolean data type */
typedef enum { TRUE, FALSE } boolean;
It can also make the code more readable than using 1 or 0, or other values. It doesn't really matter what values TRUE and FALSE have as long as the meaning is consistent in the code.

 

 

It's a nice practice, but will confuse the heck out of a new programmer:  your TRUE evaluates to zero (which is a logical fallacy -- wokka wokka).  Only the comparative in the 'if' makes it return a logical true.  If OP doesn't know what boolean is yet, he's going to have a really tough time understanding how (0 == 0) returns true, but that zero is false, and any non-zero is logically true all at the same time.  Add to that trying to get him to understand that strcmp 0 return for a match in the code above it and he'll be tearing his hair out trying to understand what's true and what's false.

 

I like your TRUE == style -- it avoids lots of pesky assignment bugs.

Share this post


Link to post
Share on other sites

write a payroll program that calculates wages, taxes,  prints checks, and W2s. Don't come back or ask for help for help until it's done. It's an easy put tedious program to write.

Share this post


Link to post
Share on other sites

write a payroll program that calculates wages, taxes,  prints checks, and W2s. Don't come back or ask for help for help until it's done. It's an easy put tedious program to write.

 

Hmm, I don't think you have properly read the OP. I can barely code so I can't really do that. I'm trying to get the theoretical work out of the way.

Share this post


Link to post
Share on other sites

write a payroll program that calculates wages, taxes,  prints checks, and W2s. Don't come back or ask for help for help until it's done. It's an easy put tedious program to write.

If you think that's easy, tell it to the folk who actually develop payroll software products and managed to screw it up throughout the last 20 years  :laugh:

 

 

Hmm, I don't think you have properly read the OP. I can barely code so I can't really do that. I'm trying to get the theoretical work out of the way.

Are you getting some of the concepts down that people are explaining?

 

 

It's a nice practice, but will confuse the heck out of a new programmer:  your TRUE evaluates to zero (which is a logical fallacy -- wokka wokka).  Only the comparative in the 'if' makes it return a logical true.  If OP doesn't know what boolean is yet, he's going to have a really tough time understanding how (0 == 0) returns true, but that zero is false, and any non-zero is logically true all at the same time.  Add to that trying to get him to understand that strcmp 0 return for a match in the code above it and he'll be tearing his hair out trying to understand what's true and what's false.

 

I like your TRUE == style -- it avoids lots of pesky assignment bugs.

That's a terrible use of enum :laugh:... Let's not introduce things that lead to subtle bugs...

Share this post


Link to post
Share on other sites

If you have autism and/or dyslexia make it visual that's how I learnt the basics, get a whiteboard and make it big and annotate your findings, learn how you want to learn and don't follow exactly how others learn.

Create ideas out of the code (forgot what name of the term) so make IF statements personal choices of the variables(ppl) etc, its so much easier.

Share this post


Link to post
Share on other sites

First of all, multiple languages? Pick one and focus on it. My recommendation is either Java or C# as they are both commercially viable and some of the best languages out there.

 PHP is a scripting language and Visual Basic will give you some very bad programming habbits so stay away from those.

 

Second, you don't need to learn all the complex stuff now like polymorphism etc. You must start with the basics. Nothing wrong with "Hello, World" in contrast to what most people will tell you.

 

Third, you will never learn the language until you apply it on a regular basis. The long you stop using it, the harder it will be to get back to it. From time to time, think of a simple application you would like to build. Don't think big, keep it simple.

 

I started programming with BBC BASIC then QBasic, then Visual Basic, then Visual Basic.NET. Now I am on C# for the past decade and I cant code VB/.NET anymore :D

1 person likes this

Share this post


Link to post
Share on other sites

You're asking for a whole computer science course here... Narrow your questions to what you need to do the job right now.

 

I'll answer the immediate questions above:

 

- Boolean (Why can it only be true and false?)

 

For the same reason the alphabet only has letters in it and not numbers or symbols.  The nature of boolean is that it's either true or false.

 

- Integer (What's the difference between an integer and a short for example)

 

You don't really have to worry about it.  Just use integers.

 

In fact Boolean Algebra is a vast and very interesting topic on it's own; from truth tables to logical gates.

Share this post


Link to post
Share on other sites

I don't understand this bit though, everyone says that I need to learn what these are and when I ask what they are people say that I'll learn that in university.

 

Just accept that Boolean is either true or false. Do you know enough about gravity? or do you just accept that everything falls?

This is what holds you back, you want to try and understand everything.

 Your questioning ends up in physics and about electrons something most developers do not have to know about.

Share this post


Link to post
Share on other sites

I don't understand this bit though, everyone says that I need to learn what these are and when I ask what they are people say that I'll learn that in university.

Asking random people on forums is a great strategy for specific programming problems. It's not so great for learning all the basic notions. The most efficient way for you to learn programming is to find a good book and read it from cover to cover. I suggested the Yellow Book a couple of pages earlier, which answers all the questions you asked here in a clear, progressive and example-driven way.

Share this post


Link to post
Share on other sites

@At All

 

Clearly there are some clever people in here...

but you being too clever...

Well if i was reading this as a noob I would get bogged down with some of the stuff that is just being said without, SellBox being the context.

I mean i understand what you guys are saying but i feel SellBox is just getting confused.

 

Its like some are having their own waffle which is cool just... not sure its helping SellBox.

 

@+LambdaLambdaLambdaFn 

 

I agree...

but i wanted to avoid the word template.... although you said it well.... I was trying to keep it very simplistic, I also wanted to avoid the word object as well.

Just until he had a good idea of what a class is. Do like the way you described some of it tho.

 

@ShellBox

 

Do you now know what a class is? As i feel that in order to get anywhere you need to understand this.

 

Example --> C# 

--------------------------------------

TeaCup A = new TeaCup();

--------------------------------------

Do you know what i am doing here: explain both sides

Share this post


Link to post
Share on other sites

If you think that's easy, tell it to the folk who actually develop payroll software products and managed to screw it up throughout the last 20 years  :laugh:

 

 
 

Are you getting some of the concepts down that people are explaining?

 

 
 

That's a terrible use of enum :laugh:... Let's not introduce things that lead to subtle bugs...

 

Not really to be honest. Everyone's just throwing these terms at me that I don't understand. This is really confusing and most people are making it even more confusing.

@At All

 

Clearly there are some clever people in here...

but you being too clever...

Well if i was reading this as a noob I would get bogged down with some of the stuff that is just being said without, SellBox being the context.

I mean i understand what you guys are saying but i feel SellBox is just getting confused.

 

Its like some are having their own waffle which is cool just... not sure its helping SellBox.

 

@+LambdaLambdaLambdaFn

 

I agree...

but i wanted to avoid the word template.... although you said it well.... I was trying to keep it very simplistic, I also wanted to avoid the word object as well.

Just until he had a good idea of what a class is. Do like the way you described some of it tho.

 

@ShellBox

 

Do you now know what a class is? As i feel that in order to get anywhere you need to understand this.

 

Example --> C# 

--------------------------------------

TeaCup A = new TeaCup();

--------------------------------------

Do you know what i am doing here: explain both sides

Not exactly, no. I'm just so confused because everyone's saying go for this language or this language, learn it this way or this way, do it this way or this way. I'd be glad to just have a grasp on the fundamentals.

Share this post


Link to post
Share on other sites
To be honest there's no way you'll be able to learn programming from a forum. There's certainly no point in going into the nitty gritty. That's what a structured learning resource is for. So, as a general set of tips, here's what worked for me:

 

Pick a language, or have one picked for you. Maybe start with the one that your school will be using. Mine came with the computer I had as a kid: BASIC. It's a language that no one uses anymore. It's certainly a language that I can't use professionally, or even productively for my own projects. However, it doesn't matter much which language you start with. You will learn many more later on, and it gets easier to pick up new languages after the first.

 

Get some learning resources. Books. Lecture videos from online courses. There are plenty of free ones too.

 

Practise by writing code. Code examples in the book? Type it in. Code exercise at the end of a chapter? Do it.

 

Practise by writing code. Pick a small project and have at it. You will be more motivated to keep at it if you're working on something that has an end goal other than simply "learn programming".

 

I repeat: write code! You can't learn programming by reading 10 books from cover to cover. I once tried to learn data structures by sitting in a university library, reading my textbook, and writing out pseudocode using a pencil. What a total waste of time that was. I almost failed that class. No one told me that you can't learn programming that way. To learn programming you need to be sitting in front of your keyboard, typing in code, and running it to see what happens. You cannot learn programming in a non-interactive environment. Programming is all about iteration. You bash code in, no matter how crude, you run it to see what happens, and change your code. You mold the program like you mold clay to make a vase. Pseudocode can help to *plan* a program, but you do not use it to help you derive the logic for the program. Because it's way faster to work in an environment where you can see the results of your commands. That means writing out code and running it.

 

Keep at it. Spent the last hour trying to figure out a concept? I've spent days struggling with new concepts. The eureka moment will eventually happen. It comes faster if you play with the concepts by... writing code. Test things out. Break things, put them back together.

 

Keep at it. Spent the last hour trying to fix a bug in your code? I've spent days trying to fix a bug. Eventually you'll figure it out. You will. There's nothing that you can't solve if you apply yourself. And once you've figured how to fix something, you'll never be bogged down by the same issue again. Because you would have been so scarred by the previous encounter that it'll have been burned into your brain. This is what we call experience. Experienced programmers aren't better than novice ones because they are smarter. It's because they have made, and fixed more errors than the novice programmer.

 

I believe that it's not being better at logical thinking that allows some people to learn programming while others fail. It's perseverance. It takes a certain type of person to persevere for days on the same problem, and to see it through. This is what it takes to become a programmer. Sheer doggedness.

5 people like this

Share this post


Link to post
Share on other sites

Not really to be honest. Everyone's just throwing these terms at me that I don't understand. This is really confusing and most people are making it even more confusing.

Not exactly, no. I'm just so confused because everyone's saying go for this language or this language, learn it this way or this way, do it this way or this way. I'd be glad to just have a grasp on the fundamentals.

I've been trying to post information relative to C# when I can. If that's what you think you want to start with let us know and we'll try to keep the info simple and related to that. Did you have any luck porting your VB class?

Share this post


Link to post
Share on other sites

I've been trying to post information relative to C# when I can. If that's what you think you want to start with let us know and we'll try to keep the info simple and related to that. Did you have any luck porting your VB class?

I won't actually get any programming until I get onto level 3 which is next year. I'm now struggling between JAVA and C# because both seem so attractive to me. They both seem fun and I've got a bit of experience in JavaScript and a bit of experience in VB. I will keep you guys updated.

Could anybody give me a small and easy project to start with? Just suggest anything that's do-able.

Thank you.

Share this post


Link to post
Share on other sites

Could anybody give me a small and easy project to start with? Just suggest anything that's do-able.

 

Here's assignment #1:  

 

Make a program, in the language of your choice, that asks the user two questions:

 

Q1:  What is the first number?

Q2:  What is the second number?

 

Print to the screen:  "The sum of those numbers is " firstNumber + secondNumber

 

Then tell us what language you chose (don't bother with explaining why -- it doesn't matter).

1 person likes this

Share this post


Link to post
Share on other sites

I won't actually get any programming until I get onto level 3 which is next year. I'm now struggling between JAVA and C# because both seem so attractive to me.

C# without a doubt. The learning material is better, gaming libraries are better (if you're into that), the official documentation is better, the language is more flexible, the standard libraries are generally a joy to work with, out-of-the-box powerful visual design tools, etc. Install Visual Studio Express for Desktop and you're good to go.

3 people like this

Share this post


Link to post
Share on other sites

I'm now struggling between JAVA and C# because both seem so attractive to me. They both seem fun and I've got a bit of experience in JavaScript and a bit of experience in VB. I will keep you guys updated.

It really comes down to whether or not you want your skills to be useful beyond Windows and Microsoft platforms. Language wise they're about the same in terms of features, documentation, tools etc. The key difference is that Java is truly multiplatform. You can code and run it pretty much anywhere, whereas with C# you're much more limited to Windows and poorly compatible and expensive alternate implementations like what Xamarin produces.

So if you want to write products in the future that target Linux, Android, OS X etc as well as Windows, it might be better to go with Java.

Share this post


Link to post
Share on other sites

Hello,

ShellBox if you need some help, feel free to PM me.

Im personally done with this thread but its not your fault or has anything to do with you.

Good luck and I hope you learn and enjoy to program which seems to make you pretty happy :)

Share this post


Link to post
Share on other sites

This is an excellent thread. Some real good information in here guys. This should almost be stickied.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0

  • Recently Browsing   0 members

    No registered users viewing this page.