Learning to use classes in C#
August 31, 2014 8:46 PM   Subscribe

Mr. Killian is struggling in an intro to C# programming class, specifically learning to use classes. Are there online resources out there that would supplement his classroom work?

Mr. Killian is attempting to make a career transition, and is returning to programming after a long absence (long enough that his original languages were Cobol, Basic, and Assembler). He's taking classes towards an AAS in info tech, but is flailing a bit in his C# class, specifically creating and referring to classes. (He's helping me write this question, as I know nothing about programming.) Any web resources or books would be great - free is lovely but good is better.
posted by PussKillian to Computers & Internet (12 answers total) 8 users marked this as a favorite
Does he not understand the object oriented paradigm in general, or is this an issue specific to C#?
posted by dilaudid at 8:51 PM on August 31, 2014

He's struggling with the object oriented paradigm in general, C# is his first exposure to it.
posted by PussKillian at 8:53 PM on August 31, 2014

There are millions of C# references / how to / beginners guides out there. back in the day when books were popular resources the Wrox series weren't too bad at getting started. I just checked - they seem to still be in business.

Here's a list of links form a similar thread in Reddit
posted by mattoxic at 9:06 PM on August 31, 2014

Objects are presented as more magical than they really are. There's not really a lot of difference between


The main differences between objects methods and regular functions are
* an object organizes functions and data that are related into a single unit
* an object permits inheritance which lets you have different data types that are similar to each other, that have the same function names, where the behavior is slightly different.

It might help to know what his specific difficulties are. For me it was understanding the life cycle of objects from construction to destruction, and getting comfortable with variable scope and usage within classes, I think.
posted by RustyBrooks at 9:30 PM on August 31, 2014 [3 favorites]

Objects actually *are* magical.

Here's a little intro. An oversimplification is that objects 'encapsulate' state and behavior - meaning that they provide a way to intelligently partition related 'stuff'. This is a very long road, and like all things *code*, mostly makes sense in the context of real-world examples.

Caveat: there are shit tons of examples (even from reputable authors/publishers/vendors) that use the syntax of objects but do not adhere to the true paradigms. Beware of MS examples, which generally demonstrate a framework capability and not an OOP best practice.

The SOLID principles are the foundation.

Deeper discussion is found at the world's first wiki - the wiki-wiki-web - c2.

A terrific intro to practical OOP (using java which is very c#-ish) is in Head First Design Patterns.

Design Patterns are an essential approach to OOP.

To do objects 'right', one generally swims upstream in an industry sometimes married to the reciprocal paradigm, procedural programming.

Shorter tell: if an object's state (any of it ) is public, OOP and encapsulation are usually fundamentally broken.
posted by j_curiouser at 9:47 PM on August 31, 2014 [2 favorites]

Caveat 2: Someone who cannot articulately discuss the Dependency Inversion Principle has no business addressing 2¢
posted by j_curiouser at 10:09 PM on August 31, 2014 [1 favorite]

I assume he's already familiar with Stack Overflow?
posted by kinddieserzeit at 12:53 AM on September 1, 2014

Classes can be hard to get your head around, mostly because they are a solution to a problem (increasing complexity) that you don't necessarily see in a beginner programming course.

If he comes back to it in a while after he has tried to create more real-life programs, it will likely make a lot more sense.

For now, he can maybe just think of it as a way of organising groups of methods and variables that go together - in the same way as a method organises chunks of code that go together.
posted by emilyw at 1:28 AM on September 1, 2014 [1 favorite]

Everytime someone asks a programming question on here I point them to Pluralsight. It has videos that take you from noob to ninja. It *is* a pay site but they offer 10hrs free introductory trial so get him to use that. They do a ton of c# courses - maybe the 'c# from scratch' by Jesse Liberty might be a good fit?

There's also Resharper which is an extension for Visual Studio (which I assume he is using) which helps you write neater error free code. Again, you have to pay for it but again they and a trial version that works for 30 days.
posted by oh pollo! at 1:35 AM on September 1, 2014

How to understand classes: go read about the Platonic theory of forms. Classes are forms, objects are instantiated things, that can exist in the real world. This is helpful if you liked philosophy, I guess.

Inheritance was also pretty much stolen from biological (Linnean) taxonomy, too.
posted by curuinor at 2:08 AM on September 1, 2014

There is a fantastic course available on iTunes U called 'Programming Methodology" taught by Mehran Shami, taught at Stanford University. He covers all the concepts of Object-Oriented Programming in a comprehensive but understandable way. Highly recommended for people making a shift into OO programming because you can get a solid understanding of OO. The language used is Java, but nearly all the material applies to other OO languages (C++, Objective C, C#, etc).
posted by apennington at 7:28 AM on September 1, 2014

I've earned my living programming in C# for about eight years and I can't remember creating a new class by inheritance by any method other than having Dot Net do it for me. (Basically "new Windows Form. Save as myForm") All the confusing stuff is under the covers.

I understand that an academic approach would emphasize it, but as a practical matter, it's not a big deal. They are basically just containers for functions aka subroutines.

Possibly,Mr Killian is also having his first experience with event driven programming as well. This can be quite confusing for a BASIC programmer. It tends to be a related issue because OOP came in about the same time as the mouse. It requires some different thinking.
posted by SemiSalt at 1:17 PM on September 1, 2014

« Older What are your favourite (veget...   |  I want an International Protot... Newer »

You are not logged in, either login or create an account to post comments