Go Down

Topic: Demonstration code for several things at the same time (Read 343411 times) previous topic - next topic

Robin2


that's highly constructive and educational. I love the explanation you give of why it's horrible.


You need to develop a thick skin here. @PeterH is by no means the most critical. Interpret "is horrible" as "I don't like it" and get over it.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

beefy23

#61
Mar 27, 2014, 01:16 am Last Edit: Mar 27, 2014, 04:50 am by beefy23 Reason: 1


that's highly constructive and educational. I love the explanation you give of why it's horrible.


You need to develop a thick skin here. @PeterH is by no means the most critical. Interpret "is horrible" as "I don't like it" and get over it.

...R


Completely disagree Robin.

First of all I am "over it", but I wouldn't be over it if I hadn't responded to that irritating comment.

How is it supposed to work here ??. Someone says something bordering on insulting, and definitely not constructive or educational, and the one he's telling it to just has to "get over it" and say nothing. I don't work that way, if someone talks pointless rubbish to me, I let them know I don't accept it and I give something back. Talk constructively to me, and as you have seen from my other posts I express thanks and talk with respect to others.

It's interesting that you aren't saying to Pete that if he doesn't like my bracketing style then HE should get over it and not post pointless aggressive comments. C'mon think about who is the one that initiated this rubbish, and give him the talking to, not me.

I've been a member of quite a few forums for a few years now, and comments like Pete made do nothing except irritate others & start a crap fight. And working on "interpretation" is the worst thing you can do when all there is to go on is written words, so when commenting, that should be taken into account.

Robin2

I complain about unhelpful and offensive comments too, including recently.

I don't happen to think that saying the appearance of something is "horrible" is insulting or offensive. It is certainly not unusual and is not confined to the sphere of programming.

Different people like different things and I believe they should be allowed to express their opinions even if we don't like them.

And I doubt if 0.0001% of human statements are ever supported by a justification.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

beefy23

Well, it's all a matter of opinion and it looks like you and me disagree.

So my advice to you is right back at you what you said to me. Why don't you get over it, get a thicker skin, and stop being bothered by my opinion about a comment made to me. I'm sure you could devote your time to some other beginners.

I've just been on the AVR Freaks forum today, and they are having a problem with certain responses. The basic request over there is that is you don't have anything decent to say then don't say it.

Keith.

Robin2


and stop being bothered by my opinion about a comment made to me


My original comment in response to your opinion post was intended as a friendly assistance to somebody new to this Forum. I'm sorry you haven't seen it like that.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

beefy23



and stop being bothered by my opinion about a comment made to me


My original comment in response to your opinion post was intended as a friendly assistance to somebody new to this Forum. I'm sorry you haven't seen it like that.

...R


Robin,

thank you for your good intentions with your friendly advice. You could however, choose better words than "get over it".

The problem is I find your advice very one sided, unfair, and not conducive to helping this forum become a better one. You are totally condoning how Pete can talk to a beginner on the forum, and telling the beginner to just get over it. Further you are saying people should be allowed to express their opinions, so it's OK for Pete to post a worthless knockdown comment to a beginner, but it seems like I should not be expressing my opinion about that comment, and I should get a thick skin and get over it. So where is my freedom to express my opinion. Seems like different rules for me and Pete.

I've been busting my guts the last few days learning this coding because it's all fairly new to me. As a beginner I come to ask questions with a little nervousness, and a feeling that I may ask irritating questions. I've clearly stated I am a beginner so when a more established member has nothing more to say than, "That's horrible" without explaining why, it gets my back up a bit, and as you say member should be free to do, I express my opinion back. I'm  rather shocked that your opinion is not more along the lines of "let's keep comments constructive", especially when beginners are the target.

Just because your advice is supposed to be friendly does not mean I will lie down and take it if I feel it's completely wrong and unfair. As you said people should be free to express their opinion and looks like I'm following your advice and doing exactly that. Seems when  I give the same advice to you (my last post) that you originally gave to me, then you say I'm not seeing your advice as friendly. Seems to me like you can dish out your friendly advice but you don't like it when someone disagrees.

Don't try and make me out to be the bad one. Sparks (Petes' comment) create fires. The answer lies in not letting the sparks start.

Keith.

JChristensen

#66
Mar 28, 2014, 02:14 am Last Edit: Mar 28, 2014, 02:17 am by Jack Christensen Reason: 1
Hi Keith,

Welcome to the forum :D  Here's my $0.02 on the indentation/style business (guaranteed to be worth every penny ;))

As you can well imagine, no two people do it exactly the same way. And people get very invested (I might say overly so) in the particular way they do it (yes, me too, absolutely). Some companies write extensive rules that specify how every tiny syntax feature should be written. But without going that far, there are certain norms or patterns or conventions that are common. It's in a programmer's best interest to adopt something fairly close because others will be able to read their code easier and vice-versa.

I'm sure I can't do a decent job here of explaining typical norms or conventions. Best to study several texts to get a feel for it. The autoformat tool does do a good job so a person can't go too far wrong with that. Most folks, once they've been at it for a while and have interacted with enough other programmers, probably adopt a style that is 90%-95% like that of others.

I know programmers far better than I, who, while they have a very good style, do one or two little things that just make me absolutely crazy. But in the end they are little things, so I figure that's just their bit of artistic flair, and we all can indulge in some small amount of that.

No doubt quite a few newcomers here feel very puzzled when they're the object of a derisive response, because they don't have the first clue as to how they caused such a reaction. The compiler didn't complain (assuming their code compiles) so what could possibly be the problem. That's unfortunate, but it happens, I guess, because it's just the fast and easy way out. Truly there is some horrible looking code around the forum, but folks usually want to focus on more immediate issues than style, like fixing a problem and getting the code working.

PS: On the lighter side, there are a good number of people out there with a sense of humor about the whole business: http://www.ioccc.org/




beefy23

Hi Jack,

thanks very much for those pointers. I had a quick look at that contest you gave the link to and can't believe those code examples, complete gobbledegook to me. Great to see some humour in the matter.

After reading your post I went and played with autoformat and expected it to move my curly bracket positions all over the place but surprisingly it didn't. I then went and Googled the matter and came across a writeup on different methods of indentation. The differences seem legion, but like you say I'll probably start to see a general pattern used by most coders. I was relieved to see one method was along the lines of what I suggested Robin could use for teaching beginners and in fact in the writeup it said that method is one of the easiest for beginners to understand, although it does take up more line for the same amount of code. It also said it is very common for C.

Here's a part of that writeup (italics):

Allman / "East Coast" / Horstmann

Example: GNU-example in Allman style

Code: [Select]
int f(int x, int y, int z)
{
    if (x < foo(y, z))
    {
        haha = bar[4] + 5;
    }
    else
    {
        while (z)
        {
            haha += foo(z, z);
            z--;
        }
        return ++x + bar();
    }
}

This style is named after Eric Allman, who wrote a lot of utilities for the BSD family of operating systems, which also is a reason why this style is sometimes incorrectly referred to as the BSD style. Please note that this style might sometimes be called BSD style, but that this is wrong. For BSD itself, just as for UNIX and Linux, 1TBS is used. You can read about this in the man pages of the different BSD derivates e.g. for ?FreeBSD and ?OpenBSD.

This style is usually preferred by newbes to C-derived programming languages for being the easiest. Despite the fact that the inventors of C, UNIX and BSD use 1TBS, this style is very common for C.

The main disadvantage of this style is the waste of precious screen lines. Per block at least one additional line is needed compared to 1TBS. In C, C++ and similar languages with comparable preprocessors there is one single situation where this style shows an advantage over 1TBS.


I accept that is not the norm, but I am surprised by that too. It is so easy to read and I equate it to looking at the graphical representation of a computer folder system, where you can see a folder inside a folder inside a folder with great ease, but in this case it's functions. I'm guessing as I get more proficient at C then I'll see functions and nested functions easier without my preferred bracketing method. Right now though some of the code I've looked at is incredibly confusing to my beginner eyes. I see an opening curly bracket, then in the same line another opening one. My eyes continue scanning serially along the lines and oh my God another opening bracket. Somewhere each of these opening brackets have a closing bracket and a lot of my effort is spent identifying individual functions and the nested functions inside them. Welcome to the world of C I tell myself LOL.

As per your suggestion I'll keep an eye out for what seems to be the norm in coding style. Even if I don't use it personally, my sketches are fairly simple at present and I can change it to the general method if I post it on the forum.

Cheers,

Keith.

JChristensen

Ha, well that'll learn me, I had no idea the topic was so thoroughly documented with names for styles and so forth. I should have known :D


I was relieved to see one method was along the lines of what I suggested Robin could use for teaching beginners and in fact in the writeup it said that method is one of the easiest for beginners to understand, although it does take up more line for the same amount of code. It also said it is very common for C.


Yeah I couldn't complain too much about that one. At least some thought went into it. If the worst thing is that it wastes some space, but makes things easier for beginners to understand, then I can live with it.

Quote

I'm guessing as I get more proficient at C then I'll see functions and nested functions easier without my preferred bracketing method.


In C and C++, while blocks of code can be nested, functions cannot be nested inside other functions.

Quote

Right now though some of the code I've looked at is incredibly confusing to my beginner eyes. I see an opening curly bracket, then in the same line another opening one. My eyes continue scanning serially along the lines and oh my God another opening bracket. Somewhere each of these opening brackets have a closing bracket and a lot of my effort is spent identifying individual functions and the nested functions inside them. Welcome to the world of C I tell myself LOL.


Actually that sounds like really bad style. That's where I'd just hit the Autoformat button before even attempting to read it.

JChristensen

Keith, if you don't already have one, an editor that recognizes the language can really help by providing "ident guides" (the vertical lines) and the ability to collapse or expand blocks of code. The Arduino IDE can be rigged to work with an external editor via Preferences.

beefy23

#70
Mar 29, 2014, 12:25 am Last Edit: Mar 29, 2014, 12:31 am by beefy23 Reason: 1

In C and C++, while blocks of code can be nested, functions cannot be nested inside other functions.


Cheers Jack,

ha ha, there's the beginner in me coming out.

Code: [Select]
int f(int x, int y, int z)
{
   if (x < foo(y, z))
   {
       haha = bar[4] + 5;
   }
   else
   {
       while (z)
       {
           haha += foo(z, z);
           z--;
       }
       return ++x + bar();
   }
}


I'm obviously describing things very wrong, time to re-educate myself. In the above example for instance you've got "while(z)" inside "else". I've been calling both of those functions. I thought anything between and open & closing curly bracket was a function.

You are completely correct about just trying to get things working and not focussing on learning C properly. I'm impatient (and excited LOL) to get the end result. I've built a CNC plasma cutting table and this project I've been working on is to make my table do something the standard software cannot do. I've got so much on my plate I've just done what's necessary to get it working. I hadn't touched C before I got an Arduino for this project. Then in addition I've been learning PCB making using the UV exposure method, and Diptrace PCB design software (love it). So yeah, rush rush, cram into my head what I can as quick as I can, etc. This is the result of my very first Arduino project so I'm quite elated

https://www.youtube.com/watch?v=yg-s-EAqMfI

The Arduino is controlling the plasma cutter directly instead of the computer. I'm just working on the "Mark II" version now with some additions to the PCB hardware and improved features in the code. The ease of use the Arduino provides made it possible.

Thanks as well for that pointer about the external editor, good information.

Edit:
Ha ha, just looked at the two images you supplied, and it's Notepad++. I just downloaded and installed it two days ago, as well as another one called Programmers Notepad. I was Googling for a way to print my code in colour (make it easy for the beginner again). Wow so now I can link to it from the Arduino IDE, awesome. Time to look at Preferences.

Keith.

JChristensen

Mighty impressive project there!

Curly braces enclose a block of one or more statements. The block of statements could be the body of a function. So in the example, the function is named "f" (very original) and the outermost pair of braces enclose the function body.

The function f() expects three integers as its input arguments and its return value is likewise an integer.

Within the function we have an if statement, which if the condition (x < foo(y, z)) is true, executes a block that consists of one statement, haha = bar[4] + 5;

If the condition is false, then the else block gets executed. Within the else block is a while statement that executes a block of two statements as long as the condition (z) is true.

Sounds worse than it is when it's written out like that. Don't analyze it too much because it's just an example and a lousy one. For one thing, the function only returns a value if the else branch is taken. That's at least bad form, and likely to cause a problem, because the caller would expect the function to return an integer regardless. Another function foo() is called in two places within f(), but we don't know what it does. So again just an example.

beefy23

Thanks Jack,

I'll have to sit down with that one a bit and let it sink in.

Got the external editor working. Now there's no more copying and pasting just so I can print in colour, and all the coding is done in  a much better editor. Thanks a million, that's helped a lot.

Keith.

mrburnette

@Keith,

Welcome.  Many of our most experienced members believe in tough-love.  You do not have to like it, or dislike it but you should take away that they spend countless hours a week in these forums attempting to help answer questions; all non-paid and often thankless work.  Formatting before posting (as requested in the stickies at the top of the topics) is my and your easy of making their job a bit easier.  After all, we came in with the question/need.

I personally spend from 1 to 2 hours daily, often more if available.  It is hard work, often frustrating.  I don't like being rude, but I am certain I have been sometimes.  Unlike writing a project column (I do) there is no draft review before publishing, "Post" click and move on to the next needy person.  Very few members give back from experience, so as you acquire knowledge and experience, consider taking on a few newbie questions... It is a gratifying experience and you will grow from the research you do on their behalf.

Best Arduino wishes,

Ray

beefy23

Hi Ray,

reading what you say has only gave me further disappointment.

A comment such as "that's horrible" is not tough love. It does nothing to help / educate the person it's aimed at. Tough love applied in this situation should be helping someone, not just putting something down with no explanation why.  So far not one member has said Pete could have refrained from putting in a criticising & pointless comment, yet seems I'm getting a gentle talking to from more than one member because I reacted to that comment. I think that is completely screwed up.

I have been a member of a cnc forum for several years, and am at the stage where I help more than ask questions. I have never gave a comment like what I got here, because of the hard thankless work I put into answering newbies questions. I understand all too well the lack of thanks for answering questions and as you'll see from my posts, I try to make of point of expressing thanks when someone helps me. I've been pretty resentful on many occasions because of zero thanks or response when I've put time into a detailed answer, but that has never led me to make the type of comment that I reacted to on here. If someone is getting hot and bothered with all the hard work of being a charity to others, and they resort to pointless irritating comments then maybe they need to take a break from the forum, and ask why they are doing it in the first place.

And based on what has been said to me so far, why would I want to help others on this forum. The very first time I suggest something with the good intention of helping beginners read code easier (whether my suggestion is right or wrong, I was trying to help), I get a crap comment fired at me. I react to that comment then I'm the one getting the talking to (however gentle). The message I keep getting, put bluntly, is that on this forum, derisive comments are completely acceptable, and the person giving them has justification for giving those comments.

Don't count on me to give help if this is the risk I put myself at on this forum. It will not be a gratifying experience when I have to eat dirt because someone does not like what I said.

Keith.

Go Up