Enlightened
-
Completely right, of course. Number of parameters is a symptom of this: If a function has a lot of in/out parameters, it likely is interacting with other code too much and shouldn't be logically split off.
I have seen some code in our codebase where an entire function should be run under lock: These often have a wrapper function which only takes the lock, calls the real function, releases the lock, then returns the value. This allows using early return in the inner function without having unlocks all over the place.
I've also been bitten by too-small functions: Several of our helpers to iterate over data structures will execute a function on each member. Sometimes here you do want to pass a lot of arguments.
-
So... apart from anything else, what's the point of the macro having a
do {...} while {0}
wrapper around theif
statement?
Filed under: Not a C coder
-
Compiler optimizes it out. It is the only way to have a macro act like a statement but run multiple lines of code, and is standard practice in C.
-
It is the only way to have a macro act like a statement but run multiple lines of code
Thanks for the explanation. I guess I expected that you could just wrap it in {} but if not, then that makes sense.
-
I expected that you could just wrap it in {}
{}
is not a statement:{...};
is not a valid grammar butdo {...} while(0);
is.I do not know who first invented this idiom, it is weird first time anyone sees it but makes sense.
-
If a function has a lot of in/out parameters, it likely is interacting with other code too much and shouldn't be logically split off.
Using a cleaver, cut the duck through the bones into bite-size pieces
-
Quite. I'd go so far as to say that functions with more than 4 or 5 required parameters are generally a bad code smell, and probably want refactoring…
…[spoiler]to use a parameter object[/spoiler]
-
…to use a parameter object
As someone that spent lots time with both low and high level programmers, usually I see Java programmers doing too small functions and C programmers doing too big ones.
That is the problem with cargo cult and strict rules. A good coder should understand why something is bad and know when it is too much or too little, but I frequently hear people preaching strict rules and applying then when they do more damage than help.
Edit: the worse that happened to me was when they forbid us to use the "+" operator in c# strings anywhere, no exceptions. Because
stringbuilderString.Concat is faster in some rare cases where that would matter.edit: corrected after @aliceif's comment refreshed my memory
-
Edit: the worse that happened to me was when they forbid us to use the "+" operator in c# strings anywhere, no exceptions. Because stringbuilder is faster in some rare cases where that would matter.
I wonder if they know what
String.Concat
is ...
-
stringbuilder
is what's commonly seen as a fast alternative when combining many substrings.String.Concat
is identical to using+
.
-
-
…to use a parameter object
Are only defendable when you need a callback and only get 1 parameter. Otherwise only group things together if they make logical sense.
-
probably want refactoring…
…to use a parameter object
I confess: I've introduced a parameter object a few times. Each time, it replaced keeping a load of stuff in global variables, so it cleaned things up a lot and allowed the code in question to be made reentrant and thread-safe, but it still feels unclean.
-
is what's commonly seen as a fast alternative when combining many substrings.
I agree with that, but they complained about something equivalent to :
string_xyz = "You have this many sandwiches:" + integer_abc;
And it is a silly optimization rule if you're not in a loop or a very intensive process, even if it was more than 2 strings.
-
-
And it is a silly optimization rule if you're not in a loop or a very intensive process, even if it was more than 2 strings.
Show them the MSIL generated. The compiler is smart enough to convert that to a StringBuilder. He just can't do it in loops.
-
I've introduced a parameter object a few times.
If done well, it can turn out that a parameter object actually does represent a functionally coherent unit of state, and that turning a bunch of globals into properties of an object lets you generalize stuff in quite a useful way.
If you've got a whole bunch of different functions that all take the same huge selection of parameters, that's code smell suggesting that this kind of tidy-up might work well.
-
Parameter objects if done right convert functions into methods (as in methods in OO). They can simplify the design. Doing this as an afterthought (when original data types no longer suffice) is tricky. and may require re-designing the entire data modeling. Converting globals to parameter objects, however is always a nice change.
-
If done well, it can turn out that a parameter object actually does represent a functionally coherent unit of state, and that turning a bunch of globals into properties of an object lets you generalize stuff in quite a useful way.
In my case, I could do the job quite nicely. There was a convenient façade function in which I could allocate the parameter object on the stack with the right lifespan, and all the things it was passed into were related. I'm certain it was the most expedient approach, and delivered a good result, but it was still not exactly neat.
You might've used that code. It's the RE engine in PostgreSQL…
-
You might've used that code. It's the RE engine in PostgreSQL...
Well, how do you sleep with the fact that you've indirectly caused Discourse to happen?
-
Well, how do you sleep with the fact that you've indirectly caused Discourse to happen?
Easily enough. I was writing it for something else entirely, and I'm not keen on attaching licenses to my code that prohibit use by anyone. Not even assholes.
-
Samsung views 2016 as the year the TV will become the center for Internet of Things (IoT) extensions in the home. As well as being equipped with GAIA, all 2016 Samsung SUHD TVs will be IoT hub technology enabled, allowing the TV itself to act as the controller for the entire home IoT service.
Yeah. Don't see that going wrong anywhere or working in the long run, seeing how they now have shut down seemingly 80% of services my 2013 "Smart" TV was delivered with.
-
they now have shut down seemingly 80% of services my 2013 "Smart" TV was delivered with.
2013? That'll be three years old tomorrow man! Throw that outdated garbage out and go get yourself a new shiny one!
-
-
Thanks for necroing this thread and reminding me of when @Carsten_Haitzler signed up and went mental
-
-
We should probably quit sneering at Tizen
Hahahaha... ha ha. ha.
No.
-
Sneering at Tizen isn't totally crazy. It's an operating system, after all, and there are certain things we expect from operating systems. Namely: apps, lots of them, and good ones.
TDEMSYR
-
>Sneering at Tizen isn't totally crazy. It's an operating system, after all, and there are certain things we expect from operating systems. Namely: apps, lots of them, and good ones.
TDEMSYR
So that means that every Chinese-knockoff SmartTV that comes pre-loaded with 50k fart apps is a good OS?
Or... oh, hey gaiz, i've found teh best OS evar:
10000000 in 1 NES Multicart (RG84)
https://www.youtube.com/watch?v=dZd1OoPavfM
-
LEAVE TIZEN ALONE
https://www.youtube.com/watch?v=PrrY5e_zcg0
-
So this little
ps aux
gem:/usr/bin/enlightenment -profile samsung -i-really-know-what-i-am-doing-and-accept-full-responsibility-for-it
No, you don't.
-
Every software made by hardware vendor ever was crap.
-
it can mirror whatever is playing on a Samsung Smart TV, so you can keep up on what the rest of that family is watching while you cook. Could Samsung have done that with Android? Probably, but my guess is it's a lot easier to pull off if you control the whole software stack. And looking to the future, there's no reason the Family Hub fridge couldn't have the same Internet of Things integration that Samsung’s Smart TVs are getting
Ahahahaha. Ahahahahaha. Yeah, because streaming video between devices has never been done before ever and definitely doesn't have a wireless display standard or anything like that which would be trivial to implement. I mean, it's not like it's built in to any mainstream OSes. No, it's definitely easier to make your own
betterversion
-
Every software made by hardware vendor ever was crap.
Don't a lot of people like SONY Vegas?
-
Don't a lot of people like SONY Vegas?
Sony bought Vegas. They didn't develop it. If they had, it would undoubtedly be crap.
It was created by a company named Sonic Foundry. Although looking it up, Sony's owned them since like 2003, so that's a long run.
-
So... who thinks that this will actually change anything? Or, to be more precise, change anything for the better?
-
@Rhywden Fucking lol. Just when I'm planning to file a mobbing suit against my boss.
-
@NeighborhoodButcher Ooooh! Keep us updated as much and as soon as you can, will ya? You always have The Good Stuff.
-
@NeighborhoodButcher What's a mobbing suit?
-
@boomzilla it's like that modding suite you have, but you can get sued for abuse of it rather than just trolled.
-
*************************
* The IMPOSSIBLE HAPPEN *
* LOCK STILL TAKEN : *
*************************
-
@NeighborhoodButcher said in Enlightened:
- The IMPOSSIBLE HAPPEN *
- LOCK STILL TAKEN : *
Perhaps from the same people who brought us Your base are belong to us.
-
@NeighborhoodButcher said in Enlightened:
- The IMPOSSIBLE HAPPEN *
- LOCK STILL TAKEN : *
New forum, same old Markdown
-
@RaceProUK said in Enlightened:
New forum, same old Markdown
But now without the BBcode fuckery grafted into it. It's mad, but it's only mad.
-
I heard Samsung is building a C# facade for EFL. This will end well
-
@NeighborhoodButcher said in Enlightened:
I heard Samsung is building a C# facade for EFL. This will end well
Luckily C# has raw pointers in its unsafe mode, allowing you to use
Evas_Object
just as you're used to now!
-
@NeighborhoodButcher said in Enlightened:
I heard Samsung is building a C# facade for EFL. This will end well
Didn't they proclaim C++ to be a bad language for their purposes? And then they go with C#?
-
@Rhywden I think it's a war between people who realize what the situation is and everyone else.
-
@RaceProUK said in Enlightened:
@NeighborhoodButcher said in Enlightened:
************************* * The IMPOSSIBLE HAPPEN * * LOCK STILL TAKEN : * *************************
New forum, same old Markdown
Like this?
-
@NeighborhoodButcher If the creators of this monster hate C++ so much, imagine what they must think of C#.