Results 1 to 20 of 22

Thread: QtCreator automatic member declaration

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtCreator automatic member declaration

    Quote Originally Posted by akiross View Post
    Wait, what are we talking about? The fact that automation may speed up my coding process OR the fact that an lazy/unaware user will fail in using the automation?
    The problem is not that automatic tools are bad, the problem is that choice is good. I (me, myself) would like to have an auto-include feature in QtCreator. You think that lazy/unexperienced users may fail in using it? Well, so just do as auto-declaration/definition: not making it "auto" but having a tool to do it with a right click
    If using the tool requires a concious decision in each and every case then I have nothing against it and implementing it for simple cases is a trivial thing to do.


    Thanks, there's no need for examples: as you, I can think a lot of cases in where automation will NOT aid unaware users. But this is the fact: unawareness is the problem, not automation.
    Automation is a double-edged weapon: it can be really useful if you know what you're doing.
    I couldn't agree more. Unfortunately here we're dealing mostly with people who'd like to use Qt (and tools that go with it) to its full potential with a minimum effort on their side (the most common phrase on this forum is "I'm a newbie in Qt and C++") so I may be biased. On the other hand there are experienced people who suggest inexperienced people to use solutions they do not understand so I'm forseeing questions about code not compiling because of missing includes (of course without understanding that missing includes are the problem) and an answer such as "right click and choose 'insert missing include' from the menu". That's a straight road to encountering a situation when such an automatic include fails for some reason and the newbie ending up here or elsewhere saying "my program doesn't work" (and no details).

    Ahah nice But I don't think that it's the case. You know, Whitehead said "Civilization advances by extending the number of important operations which we can perform without thinking of them". This is why studying is more and more important in our society:
    Unfortunately what we observe in practise is quite the opposite - people on average are becomming dumber and dumber because they can't do simple things without help from a machine that does it for them. Of course there is an elite who can do all that and they drive the civilization forwards but we're rarely dealing with "elite" in everyday life.

    because if the button exists is ok, but we must be sure to understand why the button is there and why we have to learn anyway.
    First one has to learn that if the button exists and all one does is push the button then one is obsolete as we can automate button-pushing as well. Still many people fail to see that yet they call themselves "professionals" ("I'm a pro button-pusher? Hmm.... naaa.... I'm a pro software developer!").


    Sorry, I don't think I've ever said "without even knowing". Au contraire, I said "asking the user".
    Point taken. As I already said, asking the user is ok.

    I don't. This is what I call "automatic and tedious work" and I program the machines to do it for me.
    That's fine with me but there are more people than just you. If you provide a general mechanism you have to be aware that the general population will be using it and most of it will not be part of the "elite" I mentioned earlier. Sometimes it is best to learn by your own mistakes. If you have a tool that corrects mistakes for you all the time then you will never understand what you are doing wrong. If you do understand then such automation is fine. This is an educational aspect vs engineering aspect. Once you are a qualified engineer, automation helps. But earlier it prevents you from becoming a qualified engineer.

    Everytime I include an header file - writing by hand - for a class that is not ambiguous, I think "in the time I'm wasting writing these headers I could solve bugs or add new features".
    Then you are either a very lousy typer or an excellent bug chaser.

    This is a nice phrase, but did you thought it through?
    Yes, I did.
    Do you have the skills (not knowledge) to do everything that an automatic tool is doing for you?
    When it comes to programming? Probably yes.
    Why do you use compilers?
    I see where you're going but that's a blind path I'm using a compiler because I'm using a language that requires compiling. It doesn't mean I wouldn't be able to repeat what the compiler does if I had to, provided I had time to do it. I understand how computers work, how programs are executed, why they fail and how to fix it. I'm using Qt Designer not because I lack the skills to implement a class manually but because the time required to do it is much shorter (and you can't compare it to bug chasing and adding an include statement). When placing a widget on a form I'm aware of exact C++ statements my actions cause. Unfortunately many people simply can't do something in code and they rely on Designer (Creator, button, whatever) to do it for them. That's what I mean by augmentation vs replacement.

    Why do you use C++ and not programming directly in hex in your computer?
    Yeah, that's a blind path. I use C++ but I understand that it is then translated to binary and how it is executed.

    But the fact is that for some jobs skills are simply not required anymore. That may be sad, but it's true.
    I don't agree. You may not posses the manual skills but you should know the skills are there. If you have a car, you should know that it has an engine and how (more or less) it works. If your car stops in the middle of nowhere you will either be able to check basic things (such as if there is gas in the tank) or be stranded until help arrives. Sure you can consider this knowledge obsolete and just wait for assistance but then I won't consider you a person that "knows much about cars".

    I bet you would be dead as me if civilization will fail tomorrow and we would go back to the stone age.
    I would be terribly bored but probably not so much dead, at least not that quickly. I may fail to implement my knowledge but then my knowledge may help me find someone who can.

    Math is usually a valid reference for correctness of a problem.
    But you need a formal math model of the problem which is not a trivial thing to obtain. I doubt you make formal models of each piece of code you write.


    That code you wrote is right for b not equal to 0 and for non-overflowing integers. There is no problem with the code.
    Sure there is a problem with the code. You have some constraints you do not check. You are implicitly assuming (hoping?) they will hold. The fact that code "works" doesn't mean it is "correct". The fact that the code is correct in some conditions doesn't mean it is correct in general so if you do not enforce the conditions you can't say the code is correct. If your program fails to check the conditions prior to doing some operation then it is buggy, incorrect.

    Ehehe that's a nice case You couldn't say that MY code is not correct after someone else edited it.
    The fact that you cannot prove incorrectness of a theory doesn't validate the theory (and your code uses "b" and does not "create" it so no change of your code is required to make it fail). It works the other way round. You can't say your drug is effective if you only give it to healthy people and see they don't show symptoms of the disease. And your drug doesn't become ineffective when you give it to someone ill and it doesn't work (or kills the poor guy). It has always been ineffective, there was just no proof of that.

    Anyway, the starting topic was: I would like QtCreator to have a feature to auto-include headers.
    When you're done implementing it, let us know where we can download the plugin from, I'm sure many people will benefit from it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  2. #2
    Join Date
    Feb 2007
    Location
    Italy
    Posts
    69
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtCreator automatic member declaration

    Quote Originally Posted by wysota View Post
    If using the tool requires a concious decision in each and every case then I have nothing against it and implementing it for simple cases is a trivial thing to do.
    Quote Originally Posted by wysota View Post
    When you're done implementing it, let us know where we can download the plugin from, I'm sure many people will benefit from it.
    The problem is that I've no much time for coding and I (sadly) prefer keep on with something that noises me (i.e. lack of an automatic feature like this) instead of "wasting" my time learning QtCreator's internals and developing an extension. It's not really a waste, but knowing myself (short-memory) and my objective, doing that wouldn't be productive. If someone knows QtCreator and likes to implement this feature, I'll gladly accept it, but it's just not my role to make it. Do you make your car better just because you think it can be improved? I don't think, even if you could be given enough time.

    Quote Originally Posted by wysota View Post
    I couldn't agree more. Unfortunately here we're dealing mostly with people who'd like to use Qt (and tools that go with it) to its full potential with a minimum effort on their side (the most common phrase on this forum is "I'm a newbie in Qt and C++") so I may be biased. On the other hand there are experienced people who suggest inexperienced people to use solutions they do not understand so I'm forseeing questions about code not compiling because of missing includes (of course without understanding that missing includes are the problem) and an answer such as "right click and choose 'insert missing include' from the menu". That's a straight road to encountering a situation when such an automatic include fails for some reason and the newbie ending up here or elsewhere saying "my program doesn't work" (and no details).
    Your point is valid, but sometimes I had to remember myself that openness is good (it's good if someone wants to learn and I can help), but I also have to remember that programming is not for everyone. I know people who practiced for years in programming (even ones with a master degree), but they can't obviously write a "good" piece of code. With computers and internet diffusions, people will try to use them (as I did myself many years ago) without understanding what they are doing. In this case, natural selection applies. If one starts programming without knowledge of Qt AND C++, well probably should try a more serious path and check if programming is what he really want to do.

    Quote Originally Posted by wysota View Post
    Unfortunately what we observe in practise is quite the opposite - people on average are becomming dumber and dumber because they can't do simple things without help from a machine that does it for them. Of course there is an elite who can do all that and they drive the civilization forwards but we're rarely dealing with "elite" in everyday life.
    This is a consequence, I think, of what I said above. But being computers an established technology, I think it's common that someone starts using them, starting to understand and know them and finishing (maybe) with studying them and understand all what's below the surface. Computers are so complex that it's normal to have "elite" and "noobs". You just can't avoid that. So, give that button: good people (both experienced and unexperienced) will do good things with it.

    Quote Originally Posted by wysota View Post
    That's fine with me but there are more people than just you. If you provide a general mechanism you have to be aware that the general population will be using it and most of it will not be part of the "elite" I mentioned earlier. Sometimes it is best to learn by your own mistakes. If you have a tool that corrects mistakes for you all the time then you will never understand what you are doing wrong.
    But you can learn and try to understand!! This is what make "the elite": even if one is unexperienced, you can tell he's "elite" when he goes deep and improve himself and his knowledge!

    Quote Originally Posted by wysota View Post
    Then you are either a very lousy typer or an excellent bug chaser.
    Ahaha probably the first But usually co-workers say I'm fast in writing code, so maybe I just "feel" the pain in the ass in wasting writing time. Anyway, to add an header implies moving up and down in the code, losing focus, etc. It's not really something I can call "funny to do" even if it's short. Anyway, even if it was a single second to include one header, imagine how many seconds would you save in your entire career.

    Quote Originally Posted by wysota View Post
    I see where you're going but that's a blind path
    (cut)
    Yeah, that's a blind path. I use C++ but I understand that it is then translated to binary and how it is executed.
    I don't think it's a blind path: my point was to show that automation is extremely complex and present in a number of levels. It's very good if you can understand how things work, but I think it's even better if an automation can be introduced without compromising your understanding. Now, with introduction of namespaces C++ has did a great thing: provided a structure for organizing code which goes beyond the "file level". I'm trying to say that, since the language has the features required to uniquely identify a piece of code, why are we required to handle files with a preprocessor and include them? I think that we have the tools to automate completely and without ambiguity the inclusion process, and I think it's the kind of automation that could help programmers, hiding something that doesn't really need an understanding, but which can be understood easily if you want to (and this choice, to learn or not, is legitimate, even if experienced programmers may agree that it's better to know it).
    Do you get what I'm saying? As instance, let's compare C++ and Java on this aspect: in C++ you write classes in a namespace, in Java in a package. In C++ you include FILES, in Java you import CLASSES. The fact that Java handles a class in each file with the same name is irrelevant to the fact that the Java compiler automatically finds, in the classpath, what you need. In C++ we are still handling files. And THAT'S GOOD, but I'm saying that this process is often tedious and can be automated because C++ provides the foundations to build such an automation

    Quote Originally Posted by wysota View Post
    Sure you can consider this knowledge obsolete and just wait for assistance but then I won't consider you a person that "knows much about cars".
    That's my point: you can, it's not wrong. Personally, I'd really like to be an engineer who's capable of fixing EVERYTHING is broken, from a microwave to a space shuttle. But I just can't. I don't consider myself a good programmer and code is the thing I most care about So it's inevitable that sometimes, somehow, some automations and technology are unknown, in a Black Box. It's inevitable. You can have an understanding about how they work, but you'll never have the skills about everything. You could try, and I admire people who does, but it's not realistic: humanity has so much knowledge that something is constantly out of our reach. Being conscious of this, our society is divided in "areas of expertize" and it's all-right with the fact that I can't fix a car. You can call me an idiot because you can while I can't, but you're not more right than me.

    Quote Originally Posted by wysota View Post
    I would be terribly bored
    Eheh curious, I would be thrilled Would be fun to see if everything I've always studied *in theory* can be made to work.

    Quote Originally Posted by wysota View Post
    But you need a formal math model of the problem which is not a trivial thing to obtain. I doubt you make formal models of each piece of code you write.
    Indeed I don't. But this is going a bit far from the original topic: I was just saying that if a code is correct, no further knowledge can compromise it. "New knowledge" doesn't mean "changing requirements".
    Code doesn't change: what changes is our view of things (i.e. requirements) and code meaning. In fact, you say:

    Quote Originally Posted by wysota View Post
    Sure there is a problem with the code. You have some constraints you do not check. You are implicitly assuming (hoping?) they will hold. The fact that code "works" doesn't mean it is "correct". The fact that the code is correct in some conditions doesn't mean it is correct in general so if you do not enforce the conditions you can't say the code is correct. If your program fails to check the conditions prior to doing some operation then it is buggy, incorrect.
    And this is the point: correctness is not "general", but it's very, very specific about some "requirements" or "specification". It's wrong to say that your code works for EVERY integer, but if I say you to perform a division between two positive, non-null and less-than 1000 integers, that code works indeed. What is wrong is not the code, it's the assumption that the "everything I tested so far is everything it can be tested". I wasn't talking about "it works", but "it's correct".
    And, to conclude, this was NOT was I was implying. I was saying to tbscope that automation do works, that it's reliable and that we actually are using it effectively. What does change is not the automation, but are our needs. And this is why I think my sentence he quoted in post #10 still holds.

    Quote Originally Posted by wysota View Post
    The fact that you cannot prove incorrectness of a theory doesn't validate the theory
    Never said that I said "You couldn't say that MY code is not correct after someone else edited it." which means that after editing you can no longer guarantee the correctness of the original program. Which it's obvious.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtCreator automatic member declaration

    Quote Originally Posted by akiross View Post
    Do you make your car better just because you think it can be improved? I don't think, even if you could be given enough time.
    Don't tempt me, I'm close to doing exactly that.

    In this case, natural selection applies.
    You have taken it out of my mouth, I wanted to write that in the previous post Unfortunately natural selection is an evolutionary and not a revolutionary process and sometime I am wondering what will come first - the weak will die out or I will shoot myself in the head (thus becoming one of the weak).

    So, give that button: good people (both experienced and unexperienced) will do good things with it.
    Unfortunately the remaining 90% of people will come and complain the button does something else than they expected.

    But you can learn and try to understand!! This is what make "the elite": even if one is unexperienced, you can tell he's "elite" when he goes deep and improve himself and his knowledge!
    True, but learning takes time and people are expecting quick results. These two don't go together well. Giving them buttons promotes quick results which demotes learning which brings more "noobs" and less "elite". At the same time you need to be considered a professional to have a job thus more and more noobs consider themselves pro. That's a blind circle, if you ask me.

    Anyway, to add an header implies moving up and down in the code, losing focus, etc.
    Learn Qt Creator shortcuts, they come in handy, especially the ALT+Left and ALT+Right combos.

    Anyway, even if it was a single second to include one header, imagine how many seconds would you save in your entire career.
    Well... you can always use precompiled headers and use things such as #include <QtCore>. This saves even more time.

    I don't think it's a blind path: my point was to show that automation is extremely complex and present in a number of levels.
    Nobody argues with that. The point is at some point you might reach a situation when understanding of low-level mechanisms is required (or beneficial) to do things the right way. There are countless people who think that a single line of C++ code is executed atomically by the CPU and are very suprised when they tackle against multithreading issues. Automation makes people lazy. Automation is good but you should be aware that automation does take place here and you should know what it does. Lots of people (like here) think that including a header file is enough to use external libraries. That's the result of implicit automation provided by IDEs.

    I think it's even better if an automation can be introduced without compromising your understanding.
    No argument here. I'm just worried about the "if" here.

    I'm trying to say that, since the language has the features required to uniquely identify a piece of code, why are we required to handle files with a preprocessor and include them? I think that we have the tools to automate completely and without ambiguity the inclusion process,
    No, you're wrong. A simple situation - C++ is (and will be in forseeable future) compatible with C thus you have to support pure C code. Furthermore C/C++ are quite flexible languages that do not require practically any strict environment. This is not the case with Java, Python and similar languages. There you don't need include statements but you require files to be in proper places and/or to be named according to a strict predefined pattern.

    That's my point: you can, it's not wrong.
    As long as you don't work as a car mechanic, it's fine. It's not fine if such a person starts "repairing" my car.

    Eheh curious, I would be thrilled Would be fun to see if everything I've always studied *in theory* can be made to work.
    I mean I would be bored because I couldn't do lots of things I do everyday

    Indeed I don't. But this is going a bit far from the original topic: I was just saying that if a code is correct, no further knowledge can compromise it.
    But since you don't know that the code really is correct, you cannot make statements about it.

    And this is the point: correctness is not "general", but it's very, very specific about some "requirements" or "specification".
    Yes. But you have to provide those "requirements" and "specification" and you have to ensure the code is executed within boundaries specified by them. If you don't do that, you're assuming a general correctness. If you say "people fly" then without asserting that you mean that they can control machines that can fly and in remaining conditions people don't fly (yeah well... the might -- straight down) the statement is false. If you say that the result of dividing (/) two integers is an integer then without asserting the denominator isn't 0 your statement is false.


    Never said that I said "You couldn't say that MY code is not correct after someone else edited it." which means that after editing you can no longer guarantee the correctness of the original program. Which it's obvious.
    But you don't have to edit the code.
    Qt Code:
    1. int main(int argc, char **argv){
    2. int b = atoi(argv[1]);
    3. int a = 7;
    4. int x = a/b;
    5. return x;
    6. }
    To copy to clipboard, switch view to plain text mode 
    Is this code correct or not? To me you can't say it is correct without showing how you ensure that the program is always ran with a parameter that is not 0. And since in a general case someone may take your code and use it differently than you expect it, you can never assert that and thus the code is incorrect.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Feb 2007
    Location
    Italy
    Posts
    69
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtCreator automatic member declaration

    Quote Originally Posted by wysota View Post
    Don't tempt me, I'm close to doing exactly that.
    Well I can't guess the great wysota can do that : ) From what I can see on this forum, you can freely abandon Qt and start doing something else ([EDIT] Gee in a good sense! : D). But can other people do the same? I can't!

    Quote Originally Posted by wysota View Post
    Unfortunately the remaining 90% of people will come and complain the button does something else than they expected.
    I wouldn't bet on that... 90% will come and complain at the beginning, later on they would probably get how it works and, in future, they will be the ones - like me - that come to a forum asking if a certain feature exists. Usually you expect something because you're used to it, not because it's counter-intuitive. I'm sure you know as well as me that most users don't like to switch even if the future is bright and better - just because learning, as you said, costs time and effort.

    Quote Originally Posted by wysota View Post
    Learn Qt Creator shortcuts, they come in handy, especially the ALT+Left and ALT+Right combos.
    Mmmh actually I knew the Back/Forward, but I'm not really loving it. Probably I'm missing something about how it works or I'm just not used to it. Anyway, since you point this out, I'll give it a more deep try.

    Quote Originally Posted by wysota View Post
    Well... you can always use precompiled headers and use things such as #include <QtCore>. This saves even more time.
    True, but afaik this results in bigger files to compile, slowing down the compilation process. I'm sure that in my personal project I can do that, but I heard of cases in which compiling time was critical (someone told me that he could cut down the compiling time from hours to minutes just by working on include files. This isn't a surprise when it comes to C++ template system).
    So, it's a good suggestion in my particular case, but generally speaking this is the kind of automation that may produce bad results if someone don't know what he's doing.

    Quote Originally Posted by wysota View Post
    Lots of people (like here) think that including a header file is enough to use external libraries. That's the result of implicit automation provided by IDEs.
    I remember I did the SAME exact error when I started to learn C It's like 10 years now, but it's not only a matter of automation: I used to program with notepad and compile by hand, but the manual I was using just didn't mention what a "library" was.

    Quote Originally Posted by wysota View Post
    No, you're wrong. A simple situation - C++ is (and will be in forseeable future) compatible with C thus you have to support pure C code.
    Sure (err almost: I think Stroustroup said that 99% of the C is compatible with C++ or something like that) but the fact that C++ is more flexible than Java isn't a restriction. I'm saying that, with evolution of C++, new approaches can be used. I'm absolutely not saying that I want to remove such features, but I'm saying that (I think) those can be used differently.

    Quote Originally Posted by wysota View Post
    As long as you don't work as a car mechanic, it's fine. It's not fine if such a person starts "repairing" my car.
    Eheh but even here we have elite and amateurs. I'm sure Ferrari Corse's mechanics are the best of the best among all mechanics, but probably to fix 50% of the car issues you don't have to know how to build an engine. In some sense, that could suffice: even if you start fixing your car, you would need a long experience before becoming a real expert in car fixing (especially if you plan to practice only on your car, which hopefully don't break so often lol). Here I'm saying that, even when one does it as "professional", there are different degrees. For example, I know a "professional programmer" that does what I can call "trivial work" with PHP and visual basic, but still he has costumers, because his competence is sufficient for some tasks. The market doesn't care if he's the elite or not. Elite, on the other hand, do cares about the quality of its members.

    Quote Originally Posted by wysota View Post
    I mean I would be bored because I couldn't do lots of things I do everyday
    Ahh ok Well, but surviving and recreating all the known technology is somewhat very appealing, isn't it? Knowing the past and having an occasion to do better things since the beginning! Woot!

    Quote Originally Posted by wysota View Post
    But since you don't know that the code really is correct, you cannot make statements about it.
    It seems you continue to don't get my point XD Let's say I ask you to write a software to keep data of my company. I need to pay the bill of my workers, so everything I need to do is sum a positive wage of every worker and print something.
    If your software crashes with negative wages, it is still correct, because I'm not asking you to handle negative values. This is my point: it doesn't matter if the "absolute behavior" is "unexpected" (and thus, you can call it "wrong"). What it means is that the code is right when you ask it to do what you need to to.
    If in a future society we have negative wages, I can't say that your code is wrong, because a(n implicit) specification was that "wages are positive". After the new knowledge (in future), you can say "that program doesn't satisfy our NEW needs", but it's still working and correct for the requirements it was designed for. Without a formal definition, the code is correct iff the output on tested cases is complying with the specification. Of course, this means that if code and tests were poorly programmed, the software may be used in untested conditions (and thus the program will show itself incorrect), but it may also be that the program will be NEVER tested and used outside such conditions and thus it will never reveal to be fallacious. I don't know you, but if a program does always produce the correct result it will be correct - no matter if that "always" covers only 1/10 of the possible inputs. It's still always.

    Quote Originally Posted by wysota View Post
    Yes. But you have to provide those "requirements" and "specification" and you have to ensure the code is executed within boundaries specified by them. If you don't do that, you're assuming a general correctness.
    No sorry, I can't absolutely agree with that. If no requirements are set, multiple interpretations are legit. Correctness is a function which must depend on requirements and specifications, if you don't provide them, you're not talking about correctness.
    This is why, I think, being a requirement engineer is so hard

    Quote Originally Posted by wysota View Post
    If you say that the result of dividing (/) two integers is an integer then without asserting the denominator isn't 0 your statement is false.
    Actually, in mathematics division is not defined with a denominator = 0, so it's perfectly legal to say "for any integer": talking about "division by 0" is a non-sense. The result simply doesn't exists, so specification is not required.
    This doesn't exclude, of course, the fact that you can instruct the computer with a nonsense (i.e. divide by 0) and it will fail.

    Quote Originally Posted by wysota View Post
    But you don't have to edit the code.
    Qt Code:
    1. int main(int argc, char **argv){
    2. int b = atoi(argv[1]);
    3. int a = 7;
    4. int x = a/b;
    5. return x;
    6. }
    To copy to clipboard, switch view to plain text mode 
    Is this code correct or not? To me you can't say it is correct without showing how you ensure that the program is always ran with a parameter that is not 0. And since in a general case someone may take your code and use it differently than you expect it, you can never assert that and thus the code is incorrect.
    Your question is really funny, because you didn't provide me the interpretation of "correct".
    On one side, I can say that this program is correct for every input: as it returns the correct division between 7 and b, where b is a valid input integer. Also it correctly aborts when b=0 or when atoi() returns 0 for unreadable inputs.
    On another side, I could say that if you EXPECT the program not to crash on invalid input, this program is not correct. But, as you see, I had to specify something to EXCLUDE correctness.
    You say it's not correct because you're assuming that it's wrong for a program to abort when a division by zero is performed (and note that this assumption is wrong from the code point of view). But since the alternative to crash is to produce a random value, or to hang forever calculating something that can't be calculated, I think program is correct.

    Without specifications, programs just can't be wrong... Is like dividing by zero: correctness MUST be defined against a specification. If you don't have a specification (explicit, but also implicit of course), you can't talk about "correctness"... At least you can talk about "behavior depending on the inputs", but you can't classify a behavior as right/wrong without a measurement unit. You can't act illegally without law.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QtCreator automatic member declaration

    Quote Originally Posted by akiross View Post
    Well I can't guess the great wysota can do that : ) From what I can see on this forum, you can freely abandon Qt and start doing something else ([EDIT] Gee in a good sense! : D). But can other people do the same? I can't!
    Actually I was thinking about equipping my car with an onboard Qt-driven computer system

    I wouldn't bet on that... 90% will come and complain at the beginning, later on they would probably get how it works and, in future, they will be the ones - like me - that come to a forum asking if a certain feature exists.
    Nnnnnooo... Maybe 10% of those 90% would do that. Just browse the forum and see for yourself. Call me a pessimist but I'd rather call myself a realist.

    Mmmh actually I knew the Back/Forward, but I'm not really loving it. Probably I'm missing something about how it works or I'm just not used to it. Anyway, since you point this out, I'll give it a more deep try.
    It used to work better than what it does now but it's still useful. Especially together with F2.

    True, but afaik this results in bigger files to compile, slowing down the compilation process.
    If you add all the bits, the compilation is much faster. It can save up to ~80% of the compilation time (or maybe even more if your project is complex enough). The downside is you get a really huge file on your disk.

    someone told me that he could cut down the compiling time from hours to minutes just by working on include files.
    Using precompiled headers would have yielded a similar if not better effect.

    So, it's a good suggestion in my particular case, but generally speaking this is the kind of automation that may produce bad results if someone don't know what he's doing.
    I may be misunderstanding what you mean because the final binary code with precompiled headers is exactly the same as without them. This is an area where you can't really hurt yourself. Unless you do something insanely stupid, of course.

    I remember I did the SAME exact error when I started to learn C It's like 10 years now, but it's not only a matter of automation: I used to program with notepad and compile by hand, but the manual I was using just didn't mention what a "library" was.
    That's a different matter.

    I'm saying that, with evolution of C++, new approaches can be used.
    But you still have to support the legacy code.

    If your software crashes with negative wages, it is still correct, because I'm not asking you to handle negative values.
    That's your point of view. I see it that any software that crashes is a badly written software. And I don't agree with the rest of the paragraph you have written but I feel I'm not going to convince you so I won't even try.


    No sorry, I can't absolutely agree with that. If no requirements are set, multiple interpretations are legit.
    And in this moment you can say goodbye to formalism, models and asserting correctness of the code. The most you can do is say your code looks correct or works correctly for the input given. Nothing more. You certainly cannot say your code IS correct.

    Correctness is a function which must depend on requirements and specifications, if you don't provide them, you're not talking about correctness.
    This is why, I think, being a requirement engineer is so hard
    So if you're not talking about correctness please stop saying your code is correct. You can say "my code is." - I can certainly agree with that.

    Actually, in mathematics division is not defined with a denominator = 0, so it's perfectly legal to say "for any integer": talking about "division by 0" is a non-sense. The result simply doesn't exists, so specification is not required.
    A very strange approach to mathematics. You can't say that dividing two integers results in an integer if you can find such pair of integers that result of the operation is undefined. What you can say is that all results of integer divisions are integers. You can't say that diving any two integers results in an integer.

    This doesn't exclude, of course, the fact that you can instruct the computer with a nonsense (i.e. divide by 0) and it will fail.
    It's not a nonsense for a computer. It's perfectly viable to build a computer that will return a result for division by zero. Actually any computer does that, it just signals the special case with an exception.

    Your question is really funny, because you didn't provide me the interpretation of "correct".
    If we continue this path let's start with defining "me", "you", "computer" and the rest of the world. I'm sure you know what I mean by "correct" here.

    But since the alternative to crash is to produce a random value, or to hang forever calculating something that can't be calculated, I think program is correct.
    Crash or produce random value? Hmm... This should work:

    Qt Code:
    1. int main(int argc, char **argv){
    2. if(argc<2) return nan("int"); // or return a predefined value
    3. int b = atoi(argv[1]);
    4. if(b==0) return nan("int"); // or return a predefined value
    5. int a = 7;
    6. int x = a/b;
    7. return x;
    8. }
    To copy to clipboard, switch view to plain text mode 
    If you don't have a specification (explicit, but also implicit of course), you can't talk about "correctness"
    Ah, now we're getting somewhere. I think what you mean is "validation" or "verification" and not "correctness" - http://en.wikipedia.org/wiki/Validat...d_verification
    Correctness would be an absolute state while the other two terms would be determined against some specification.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Feb 2007
    Location
    Italy
    Posts
    69
    Thanks
    12
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QtCreator automatic member declaration

    Quote Originally Posted by wysota View Post
    Actually I was thinking about equipping my car with an onboard Qt-driven computer system
    Cool! I vote for that

    Quote Originally Posted by wysota View Post
    Nnnnnooo... Maybe 10% of those 90% would do that. Just browse the forum and see for yourself. Call me a pessimist but I'd rather call myself a realist.
    Ok, I just assume that most users would complain if a new feature is added and/or removed. But if you say in this forum they don't, well ok: I'm sure you've better knowledge than me on this subject and related statistics.

    Quote Originally Posted by wysota View Post
    It used to work better than what it does now but it's still useful. Especially together with F2.
    Well I just LOVE F2! I'll try that.

    Quote Originally Posted by wysota View Post
    If you add all the bits, the compilation is much faster. It can save up to ~80% of the compilation time (or maybe even more if your project is complex enough). The downside is you get a really huge file on your disk.

    Using precompiled headers would have yielded a similar if not better effect.

    I may be misunderstanding what you mean because the final binary code with precompiled headers is exactly the same as without them. This is an area where you can't really hurt yourself. Unless you do something insanely stupid, of course.
    Well, honestly I didn't know (or just didn't remember) about pre-compiled headers (this is why, to me, including too much was a bad result and I think that such suggestion can produce bad results in compiling time). Now that I'm thinking of precompilation, I can assume the person I was talking to didn't knew either OR in that case he couldn't apply (OR he did, but I think he said that he had to cut headers and not using precompilation).

    Quote Originally Posted by wysota View Post
    That's a different matter.
    Not necessarily: one can be also not documented about the modular structure of Qt, and this is a totally different cause than IDE automation. When opening the QLocalSocket page I don't notice the fact that it's part of network module, I'm assuming that such class is part of the base Qt library, which I may have already liked not automatically. As example, I can say you that when I started used Qt I was using scons, totally avoiding qmake for building a project and I specified every time the library to include, but I initially had an issue about the library to include when using network classes. That is: ignorance can't be blamed only on automation.

    Quote Originally Posted by wysota View Post
    But you still have to support the legacy code.
    Of course you have, that's why I'm not talking about replacing functions but expanding them. This is natural for C++ in respect to C.

    Quote Originally Posted by wysota View Post
    That's your point of view. I see it that any software that crashes is a badly written software. And I don't agree with the rest of the paragraph you have written but I feel I'm not going to convince you so I won't even try.
    From this, it seems you're the kind of person who think that's right to define the division by 0 as infinity.

    Quote Originally Posted by wysota View Post
    And in this moment you can say goodbye to formalism, models and asserting correctness of the code. The most you can do is say your code looks correct or works correctly for the input given. Nothing more. You certainly cannot say your code IS correct.
    I can say the code do something and does always *that* something, so I can't assume that the code is wrong just because I don't agree with what it does. So it must be correct in a (way too general and often disliked) interpretation.

    Quote Originally Posted by wysota View Post
    So if you're not talking about correctness please stop saying your code is correct. You can say "my code is." - I can certainly agree with that.
    I still think it's correct, because it does exactly what it is meant to do, and because without a specification you can't say that is wrong. But if you don't want to call it correct, I can agree to use your terminology in this context. To me, the code is still valid.

    Quote Originally Posted by wysota View Post
    A very strange approach to mathematics. You can't say that dividing two integers results in an integer if you can find such pair of integers that result of the operation is undefined. What you can say is that all results of integer divisions are integers. You can't say that diving any two integers results in an integer.
    Of course we can define two different versions of "division among integers", but a general accepted definition in mathematic is:
    A divides B if exists Q and R such that B = A*Q+R with A, B, Q and R all integers, A non zero.
    So yes, I can say that a definition two integers results in an integer and it's not strange, given a specification that allows me to do that (and such a specification is even sensed and generally accepted). Btw, I think that's the definition used in C and C++.

    Quote Originally Posted by wysota View Post
    It's not a nonsense for a computer.
    I was talking about humans, as we usually are the governor of meaning. But yes, you're right, and that's why that a division by 0 is correct without specifying that a crash is not an option (at least, "correct" in the old interpretation we didn't agree before this post).

    Quote Originally Posted by wysota View Post
    If we continue this path let's start with defining "me", "you", "computer" and the rest of the world. I'm sure you know what I mean by "correct" here.
    No, I'm sorry, I really thought that correct was meaning a failure. And I'm the kind of person who usually like to define you, me, computer, division and correct, because, as you see, not agreeing on this can lead to misunderstandings.

    Quote Originally Posted by wysota View Post
    Ah, now we're getting somewhere. I think what you mean is "validation" or "verification" and not "correctness" - http://en.wikipedia.org/wiki/Validat...d_verification
    Correctness would be an absolute state while the other two terms would be determined against some specification.
    Sorry, until now I used two interpretations for "correctness": one as "does what specification says" and another as "doesn't disagree with the specifications". To me they are naturally equivalent and clear from the context, but I can understand that it's not an absolute interpretation. I don't think it's wrong to think this way, but of course these meanings can disagree with other interpretations (e.g. yours).
    I don't think that correctness is absolute as you can give an incomplete specification.

    Of course we're speculating here: it's obvious that I can understand what you say and I guess you do on what I say. It's only about conventions. I think that you can't reach "absoluteness" if you compare a program to a specification: if you do, the evaluation of correctness is relative to it's specification. Thus I think that "absolutely correct" means that programs do correctly what they describe with their code. "Absoluteness" is reached when no specification is present, but still the concept of correctness can be conceived.

    Anyway, I don't this that this debate won't bring us much further

Similar Threads

  1. QtCreator 2.0 crashes application working in QtCreator 1.3
    By been_1990 in forum Qt Programming
    Replies: 2
    Last Post: 21st September 2010, 12:58
  2. Replies: 22
    Last Post: 8th October 2008, 13:54
  3. static declaration
    By jhearon in forum Qt Programming
    Replies: 1
    Last Post: 18th February 2008, 21:37
  4. Declaration problems
    By scarvenger in forum Qt Programming
    Replies: 1
    Last Post: 7th May 2007, 02:05
  5. Declaration not working
    By kenny_isles in forum Newbie
    Replies: 1
    Last Post: 1st March 2007, 10:13

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.