Learn programming languages such as Java, C++, Visual Basic, and more!
See all
Members (1,991)
Fr. Robert Ballecer, SJ's profile photo
Adam Pryke's profile photo
A. John Peters's profile photo
A.J. Horton's profile photo
Adrian Santaella's profile photo
AJ White's profile photo
Adel Shata Suez's profile photo
Adam T's profile photo
Adel Shata Note4's profile photo
Aaany thingg's profile photo
Aaron Lewis's profile photo
Al Lewis's profile photo
Adrian Chung's profile photo
Adam Williams's profile photo
Abdullah Shah's profile photo
Abe Abrahamian's profile photo
Al B's profile photo
Abhishek Solanki's profile photo
Alan Baker's profile photo
Adam Baker's profile photo
Adam Cartwright's profile photo
Alan Bauer's profile photo
Ag Lenoir's profile photo
Adam Grusky's profile photo


Join this community to post or comment

Lee Crocker

Episode Discussion  - 
State and Behavior

Another cool episode with Smitty, but I think Lou and Padre's opening bit about structures and objects was more confusing than useful. In particular, they make it sound like a matter of choice. Apparently it is if you're using C#--I'll take Lou's word for that. For the other 95% of programmers, the choice is easy: in C++, use structs to interface with C code, otherwise use classes. In every other programming language in the world, use the one your language has.

Lou also emphasized the value of information hiding, which is indeed a benefit of OO design, but not what I'd call it's defining characteristic. Padre got this one right: what makes objects different from structures is behavior. That is, object have methods as well as data, and because they do, they can have data that is private to those methods.

The more general question of why to use either one was never really answered clearly, but the answer is quite simple: computer programs model parts of the world, and structures are ways to encapsulate the representation of complex things. Things in the world have state, which is to say more-or-less static (but perhaps changeable) properties: a car has a make, model, color, location, direction, occupants, and so on. You might be able to come up with many such properties. Which ones you choose to track is a matter of what you need your program to do, but collecting them into a structure of some type makes it clear that they belong to a single thing, and simplifies dealing with those things. Things also have behavior, which is what they do, or what can be done to them, and how they interact with other things (drive, paint, sell. etc.)

Structures in programming languages collect into one place the state of something. Objects collect both state and behavior. Some languages (Java, Go, ...) have collections of behavior only, called "interfaces". Classes are a further way to organize and, well, classify, different kinds of objects. Some languages (JavaScript, Lua, ...) have objects, but not classes. To further complicate things, languages use all kinds of different terms for these things: "records" (Pascal...), "tuples" (Erlang...), etc. Go calls its objects "structures". :-)

But it's all about state and behavior: what are the "things" in your program, how do you describe and differentiate them, and what do they do?
Add a comment...

Matthew Reardon

Episode Discussion  - 
For the geek who just wants know....One's complement info. 
Add a comment...

Kenneth Longcrier

Episode Discussion  - 
Finally caught up with coding 101 Episode 51. Listening to Steve, I have to agree that the knowledge of computer hardware is both critical and missing from current curricula in many college programs. (I wonder how many computer majors could explain the usage of a 1s complement or 2s complement...)

When the Navy trained me to repair computers (Many many years ago.) We were taught troubleshooting to the NOR gate level (trust me, with electronics, everything is a NOR gate.) As well as Assembly programming (lovely Binary coded octal)

Understanding how computers work on this kind of fundamental level has paid dividends in my understanding of problems over the course of my career as a software developer.
Add a comment...

Jason Perry

Everything Else!  - 
Anyone here with recommendations on a Zigbee radio other than the Xbee? Furthest distance the signal would have to travel is 25ft and up or down a floor, more realistically 10ft since it is a mesh network. 
Toby Robb's profile photoJason Perry's profile photo
Price is right and the form factor also fits what I am after. I think I may start with something like that and build with the thought in mind that I may switch radios down the road. I would rather. buying 20 cheap radios that will work for my purpose makes more sense than buying 1 radio that goes above and beyond.
Add a comment...
This guy has it figured out. He is up to 12 episodes on his smart house. I have to say there are a few things I am not 100% with his model; but, with the time he has spent on it there is probably a reason I am not thinking of. 
Add a comment...

Jason Perry

Episode Discussion  - 
1-Day Project: Build Your Own Arduino Uno for $5: http://youtu.be/sNIMCdVOHOM
Nathan Follmer's profile photo
That's pretty cool 
Add a comment...

Lee Crocker

Episode Discussion  - 
To clarify something that wasn't pointed out on the show...The programming language there is C; nothing more, nothing less. In fact, under the hood, the Arduino IDE uses avr-gcc as its compiler and avrdude as its uploader, both of which you can use directly without the IDE if you choose.

An Arduino "sketch" is nothing but a C program, except that they've already written the "main" function for you, that looks something like:

    int main(int ac, char *av[]) {

        while (1) {

You are expected to fill in the setup() and loop() functions. But if you don't want to use the Arduino IDE, you can do your own main() instead if you want.  Likewise, the IDE links in its own libraries with things like digitalWrite(), which are written in terms of the Arduino hardware pins. If you use avr-gcc directly, you have to write in terms of the chip's registers, so turning on an LED might be more like:

    DDRB |= 0x20;
    PORTB |= 0x20;

(Pin 13 on the Arduino board is connected to pin "PB5" of the Atmel chip.) Avr-gcc also allows you to write interrupt service routines and use in-line assembly. Finally, the IDE shows you how much memory is being used by your program. This too is available outside the IDE with the program avr-size. On my latest work project, it looks like this:

    avr-size -C --mcu=atmega164p testcode.elf
    AVR Memory Usage
    Device: atmega164p

    Program:    9682 bytes (59.1% Full)
    (.text + .data + .bootloader)

    Data:        572 bytes (55.9% Full)
    (.data + .bss + .noinit)

All in all, sticking with Arduino IDE is a great place to start. But realize that you are in fact learning C at the same time, and you can take your code with you when you outgrow it.

Final note: A Radio Shack near me was having a big sale what with them going bankrupt and all, and I got an Uno and a Relay Shield for about $40. Thinking of making a sous vide rig with it.
Matthew Reardon's profile photoLee Crocker's profile photo
Object-oriented design is great for many things--particularly GUIs. I'ts definitely something worth learning. But devices with two buttons and a few LEDs are usually better served with state-machine designs.
Add a comment...

Benjamin Frost

General Coding Questions  - 
hey everyone I'm trying to make a program in python that i can use to run scripts on my computer using my phone or some kind of other device. it is made up of a server and a client, and it is the client i have problems with.

the client works fine when i use it on my computer. but on the phone it says "s.connect((host, port))
File "<string>", line 1,in connect
socket.error: [error 110] connection timed out. "

i think the problem comes because i use python27 on my computer and sl4a on my phone uses python26. but i can't really find out what it is and i would be very happy if someone could help me fix it.

the code is on github here https://github.com/benjamin1313/scriptLauncher/blob/master/scriptLuncherClient.py
Benjamin Frost's profile photoAdrian Chung's profile photo
Things to check:
What network are the two computers and the phone connected to? Are they all WiFi on the same router? What routing rules have been configured on the router.
Are IP addresses allocated dynamically or statically for each device?
Or is the phone on cellular data?
Add a comment...

christophe vandingelen

General Coding Questions  - 
Have a question about databases. I want to develop an app/program witch can be accessed on the web, but also has a native app on Android. Now, Android uses SQLite as a database and most of the webhosts today use mySQL together with php as I'm also writing my code that way. So my question is: how can I make this compatible? Should I switch to SQLite for the web too and if yes, where can I get hosting that supports it. Or are there other ways? 
christophe vandingelen's profile photoTravis Hershberger's profile photo
+Nathan Follmer Already pointed you in the best direction here.  All I'll add is that SQLite is actually just another file in the filesystem, if you want support for it that has to come from the program/language used to access it.
Add a comment...
Been doing a crash course in PHP and mysql with little more than the couple of episodes of Coding 101 on PHP and a non-conclusive 13 part series by Eli The Computer Guy on YouTube. With that and a few extra Google searches as questions arose, and a lot of sweat and tears, I think I integrated the mysql database into my concrete5 based website without many holes. ie, it works as I want, but I'm sure there are security holes in my coding, such as I'm not parsing the entries for perhaps bad escape sequences and such.

I guess what I want t ask is "Is my database showing?" In an earlier attempt, I was able to see ll about my database, address and password, just by viewing the page source. I've got the database display in an iframe now, and from what I can tell, it's not showing.

Does anyone care to give it a try and see if you can spot mistakes or errors?
Thanks, Mike

BTW, pay no attention to the domain name. It has nothing to do with Leo or Leoville. It's the city I live in, and prior to about 1998, never heard of (even though my great grandparents were married here)... I've known about Leo LaPorte much longer (since his Dvorack on Computers days.)

The website is www.MyLaPorte.Info and the page with the database calls is "The Petition"
Michael Maxfield's profile photo
Thanks Jeff, for causing me to look where I haven't already. Concrete5 is so simple, so intuitive (as well as lacks decent documentation) that I hadn't looked into it having the facilities in itself. Concrete5 5 is so simple that I was able to figure it out right out of the box (and due to the poor documentation, never set out to check it out.)
Of course looking at the documentation there was no clear cut info that such facilities exist or how to deal with them, but using the built in forms blocks and putting all sorts of "@$!<,' info in and seeing that it ends up in the database by viewing with phpMyAdmin and seeing the characters in there without erors.
Of course the documentation doesn't tell me how to use the stock forms block to put the data in a database separate from the operational CMS database for the website nor how to extract the different forms from a single table.(all forms created under the the form block wind up in the same table of the site's CMS database.

aID asID msqID answer answerLong
1 1 8 no
2 2 9 Johnny Jay
3 2 10 Sheep don't think for themselves
4 2 8 no
5 3 9 Jeff Walker
6 3 10 Bahhh
7 3 8 yes
8 4 9 Jack A' Roberts
9 4 10 Whn I say "I am not" that means I am not! period.
10 4 8 no
11 5 11 a new name
12 5 12 No
13 6 9 freak
14 6 10 what, and not
15 6 8 no

first field line second field is sequential form, third field question id,, etc.

But I know it's there, just need to figure a way to manage it efficiently for multiple forms, preferably in their own databases or at least separate tables.

I think I will prefer to write my own controls for my presentation outside the Concrete5 structure however, so I am currently viewing the following video which looks like it isthe best answer for my task.

Add a comment...

About this community

Join the Digital Jesuit, Father Robert Ballecer, as he speaks with programmers, engineers and software tinkerers to tease out the secrets of becoming a code warrior. With a combination of classroom-style teaching, interviews and start-to-finish project, Coding 101 will offer something for everyone, no matter if your a newbie, advanced, or in possession of great code-fu. Records live every Thursday at 1:30pm PT / 4:30pm ET.

mike klaene

Episode Discussion  - 
In plain old 'C' - a structure is a way to group together a set of data that are to be used together.  A good example is the 'FILE' structure that is defined in the stdio.h file. The FILE structure contains all of the values that are needed by the standard I/O functions to manage all of the file operations for you.

In languages that support classes, the basic 'C' type structure concept is expanded such that one or more of the data values in the structure can be defined as private. Also a class may include the specific functions, called 'methods', for acting upon the class.

Both 'C' and OOP languages have their uses - they are just tools. You, as the programmer, should selected the best tool for the task at hand.
mike klaene's profile photo
+Louis Maresca Lou - thanks for the compliment.
Add a comment...
I was just thinking of an Arduino project the other day that could use something like this... I'm throwing money at the screen as I type this: https://www.kickstarter.com/projects/sparkdevices/spark-electron-cellular-dev-kit-with-a-simple-data
Spark IO is raising funds for Spark Electron: Cellular dev kit with a simple data plan on Kickstarter! The Electron is an Arduino-like cellular development kit with a SIM card and affordable data plan from the creators of the Spark Core.
Louis Maresca's profile photo
This is going to be fun!
Add a comment...

Hector Coluccio

Episode Discussion  - 
I don't see the location of the libraries for the RTC and Time in the show notes. I found some in the internet but I don't know if they are all the same, I prefer to use the same libraries being used in the show.
Fr. Robert Ballecer, SJ's profile photoHector Coluccio's profile photo
Thank you Padre, bendiciones.
Add a comment...
Libraries can consist of your own code.  It is a very good way to re-use your own code without having to include the actual source into your project.
Coding is fun and anybody CAN do it.  But not everybody will be a Steve Gibson class coder.
Add a comment...

Lee Crocker

Episode Discussion  - 
Great episode. BTW, I2C stands for "Inter-Integrated Circuit", which is meant to highlight the fact that it is a protocol that communicates between ICs. Minor correction: Smitty says the Arduino's analog inputs are 8 bits (0..255). They are in fact 10 bits (0..1023).

And a correction of my own post from last week: I said Arduino sketches were in C. They are in fact in C++. (Using the same tools I mentioned).
Louis Maresca's profile photo
Love your posts Lee
Add a comment...

Jason Perry

Episode Discussion  - 
I am sitting here taking in every second of episode 1 of the embedded programming series. So excited.

The one thing I would love to see is how to move beyond the arduino. Once I am finnished my project, how do I build my own board that strips out everything I dont need, simplify every thing into one board, and makes me feel the project is complete and keeps it working past the desire to rip out the arduino for the next project.
Travis Hershberger's profile photoJason Perry's profile photo
You make some good points. In the case of the clock you would have to build in a way to change the time past flashing the sketch on the chip I am not sure you need to communicate. Power is also something you dont want to screw up, unless you dont mind melting your creation.
Add a comment...

Josiah Mory

Episode Discussion  - 
Great episode today padre! Looking forward to the next, even if not live!
Louis Maresca's profile photo
Love Embedded Devices!
Add a comment...
Here's the first test of my Podcast Player on the Raspberry Pi B. I definitely recommend getting the PiPlate, it was my first time soldering and as you can see even if you suck at it like I do, the plate will still work :) the code for this is still very barebones but I'll post it if someone's interested.
Fr. Robert Ballecer, SJ's profile photo
Add a comment...

Charles Kelly

Episode Discussion  - 
The IDE I use for teaching assembly language and computer architecture is http://easy68k.com . It runs on Windows, is open source and uses the 68000 architecture. There are some impressive user created programs on the site.
Add a comment...