|
Chris Losinger wrote: come on over to my world, where i'm looking at C functions that sometimes hit 1000 lines.
Don't, I am getting excited!
|
|
|
|
|
Munchies_Matt wrote: Don't, I am getting excited!
Until you are the one who has to debug them.
Then you're excited in a whole new way.
|
|
|
|
|
It sounds like you support functions with 1000 lines over 15 lines. Extracting out discrete segments of logic into non-public methods/functions not only improves readability but allows you to abstract "complex logic" into an understandable name so new developers can digest it easier.
A caveat, as always, especially since you mention C: If it's for a functional performance requirement, I can't really fault massive functions. I can't seem to find the article but I remember years ago a game engine had to collapse its entire render stack into a single function to improve performance.
|
|
|
|
|
if i was King Lord Programmer here i'd forbid any functions with more than 250 lines.
alas, i am not.
|
|
|
|
|
I agree with you but I would be inclined to place the limit at 200.
|
|
|
|
|
If your slogan was "no functions over 250 lines", I'd vote for you Oooo, or "Even books have chapters."
|
|
|
|
|
Jon McKee wrote: If your slogan was "no functions over 250 lines", I'd vote for you Oooo, or "Even books have chapters."
That wouldn't help, you don't vote for Kings.
Michael Martin
Australia
"I controlled my laughter and simple said "No,I am very busy,so I can't write any code for you". The moment they heard this all the smiling face turned into a sad looking face and one of them farted. So I had to leave the place as soon as possible."
- Mr.Prakash One Fine Saturday. 24/04/2004
|
|
|
|
|
If you cast your vote with a pitchfork or a password reset you do
|
|
|
|
|
3 layers deep is all you need to go.
1st layer: Entry points
2nd layer: logic
3rd layer: detailed code
|
|
|
|
|
Ah, yes. The DoEverythingAndThisAndAlsoThatAndOhThisOtherThingAsWell() function.
|
|
|
|
|
Chris Losinger wrote: come on over to my world, where i'm looking at C functions that sometimes hit 1000 lines.
That's nothing! My record is over 1700 comment lines before the first line of code.
|
|
|
|
|
|
I am actually beginning to hate C++ as well, but the reasons you mention have nothing to do with the language. Try reading some typical Java "enterprise" code and finding a method that actually does something.
|
|
|
|
|
From your post, it would seem that you hate C++ because of how someone else writes Java "enterprise" code.
I suppose that makes some sense somewhere somehow to someone.
Ravings en masse^ |
---|
"The difference between genius and stupidity is that genius has its limits." - Albert Einstein | "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010 |
|
|
|
|
|
And what this has todo with C++? It's more a programming style than a Need in C++
It does not solve my Problem, but it answers my question
modified 19-Jan-21 21:04pm.
|
|
|
|
|
Sorry for mentioning something simplistic, but I think immediately about call graphs …
When I used VC++ 4 or 5 I was extremely impressed by the call graph features … back then ,
I found them very handy, of course … I missed them in early VC#, and they resurfaced
at some point in VC# editions (in last 10 years I think ...), BR
|
|
|
|
|
In my younger days, I was very eager about call graphs myself. Well, that was in the days when you could dive into, say, an OS and understand every detail of it.
Then I started working with communication protocols, and it was still in the days when we believed that the OSI model were for real, with its service APIs and layer borders serving as firewalls both upwards and downwards, and protocol definitions independent of service APIs. But most of all: You had no control over your peer. You had to program according to service and protocol definitions, inside the black box. We used those principles as design guidelines even for non-communication software.
When you are in a firewalling black box, you shall not be concerned with how that service you are invoking fulfills it task. You shall not know the context in which the user of your service offering operates. And you shall send and receive protocol elements without regard for how your peer does his processing. For the in-layer code, OO encapsulation hides so much that we think of object methods almost as as "primitives", not some deep well of calls into calls into calls.
If you are into the telecommunication way of programming, you essentially make all your implmentation designs (and realizations) as finite state machines. Then there is very little left for the call graphs to do. I am no longer programming communication protocols, but I've fallen into the habit of FSM style and layered design; now that you mention call graphs, to me that is a long lost memory. But I do not miss it.
|
|
|
|
|
Quote: If you are into the telecommunication way of programming, you essentially make all your implementation designs (and realizations) as finite state machines. Then there is very little left for the call graphs to do. good point indeed … I used FSM's years ago in text analysis and this reminds me somewhat vaguely about cases of equivalency between FSM and grammars … a grammar looks like a tree so in such cases a call graph would apply … Perhaps it is difficult/impossible to generalize, BR
|
|
|
|
|
I'm in love with modern C++.
|
|
|
|
|
I still really need to catch up with all the improvements. I've been swimming in C#-land for so long. Haven't done anything serious in C++ in quite a few years beyond some C++/CLI here and there.
|
|
|
|
|
Really? In love?
Are you just saying that or do programming languages really do it for you?
|
|
|
|
|
Well, Java cannot do that for me.
|
|
|
|
|
Munchies_Matt wrote: On and on and on you search, looking for code that actually DOES something!
Why do you think that C++ program should do something?
|
|
|
|
|
You are free to move to Managed C++ if you don't like this one.
|
|
|
|
|
Now, I hope I'm not the only one here who experienced it as well... A couple of weeks ago my Win 10 taskbar buttons became completely unresponsive: nither "Start" nor the "Search" button showed anything on screen, but the change desktop worked fine and left click showed the alternative menu as always.
The trouble began after a day installing / uninstalling stuff. The only way to "fix" it, after following the usual suggested ones, was to restore a System Restore Point, effing off a couple of useful programs I installed and some executables I had in my Documents folder.
My Windows 10 does not have either Cortana nor Windows Store or apps support (it's the LTSB version) so it's not one of them. To rest more easily I installed ClassicShell, so that the Start menu manager is something different from the standard but I'm not entirely sure it will prevent the problem forever.
Well, that's it, just ranting and seeking if someone had the problem before and found what triggered it (I was deep in the middle of urgent vital work so I didn't have time to put on my spleunking gear and explore the system's innards).
GCS d-- s-/++ a- C++++ U+++ P- L+@ E-- W++ N+ o+ K- w+++ O? M-- V? PS+ PE- Y+ PGP t+ 5? X R+++ tv-- b+(+++) DI+++ D++ G e++ h--- ++>+++ y+++* Weapons extension: ma- k++ F+2 X
|
|
|
|