Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c > #144440 > unrolled thread
| Started by | luser droog <luser.droog@gmail.com> |
|---|---|
| First post | 2019-06-04 16:57 -0700 |
| Last post | 2019-06-05 06:54 -0700 |
| Articles | 13 — 9 participants |
Back to article view | Back to comp.lang.c
Alternatives to spaghetti code luser droog <luser.droog@gmail.com> - 2019-06-04 16:57 -0700
Re: Alternatives to spaghetti code Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> - 2019-06-05 01:59 +0200
Re: Alternatives to spaghetti code nobody@example.org (Scott) - 2019-06-05 01:09 +0000
Re: Alternatives to spaghetti code fir <profesor.fir@gmail.com> - 2019-06-05 06:19 -0700
Re: Alternatives to spaghetti code fir <profesor.fir@gmail.com> - 2019-06-05 06:49 -0700
Re: Alternatives to spaghetti code fir <profesor.fir@gmail.com> - 2019-06-05 07:05 -0700
Re: Alternatives to spaghetti code fir <profesor.fir@gmail.com> - 2019-06-05 07:19 -0700
Re: Alternatives to spaghetti code Keith Thompson <kst-u@mib.org> - 2019-06-04 18:42 -0700
Re: Alternatives to spaghetti code David Brown <david.brown@hesbynett.no> - 2019-06-05 09:03 +0200
Re: Alternatives to spaghetti code Jorgen Grahn <grahn+nntp@snipabacken.se> - 2019-06-06 18:34 +0000
Re: Alternatives to spaghetti code mark.bluemel@gmail.com - 2019-06-05 02:46 -0700
Re: Alternatives to spaghetti code Malcolm McLean <malcolm.arthur.mclean@gmail.com> - 2019-06-05 06:45 -0700
Re: Alternatives to spaghetti code fir <profesor.fir@gmail.com> - 2019-06-05 06:54 -0700
| From | luser droog <luser.droog@gmail.com> |
|---|---|
| Date | 2019-06-04 16:57 -0700 |
| Subject | Alternatives to spaghetti code |
| Message-ID | <75690eea-6786-40e5-8201-cbbf3133b26b@googlegroups.com> |
Spaghetti code is obviously bad news, but what about other types of pasta-modeled code. Are there similar problems with tortellini code or lasagna code?
[toc] | [next] | [standalone]
| From | Sjouke Burry <burrynulnulfour@ppllaanneett.nnll> |
|---|---|
| Date | 2019-06-05 01:59 +0200 |
| Message-ID | <5cf705de$0$1821$e4fe514c@textnews.kpn.nl> |
| In reply to | #144440 |
On 05.06.19 1:57, luser droog wrote: > Spaghetti code is obviously bad news, but what about other > types of pasta-modeled code. Are there similar problems with > tortellini code or lasagna code? > Only for Italian software.
[toc] | [prev] | [next] | [standalone]
| From | nobody@example.org (Scott) |
|---|---|
| Date | 2019-06-05 01:09 +0000 |
| Message-ID | <5cf7150d.2476638299@core> |
| In reply to | #144440 |
On Tue, 4 Jun 2019 16:57:43 -0700 (PDT), luser droog <luser.droog@gmail.com> wrote: >Spaghetti code is obviously bad news, but what about other >types of pasta-modeled code. Are there similar problems with >tortellini code or lasagna code? A lot of code is lasagna code. Layers upon layers upon layers, and at the bottom there's just a thin puddle of suspiciously orange grease. Except for networking code. That's rigatoni code. You know...tubes....
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2019-06-05 06:19 -0700 |
| Message-ID | <cebf1200-adab-41d6-a74c-d7927f1c7220@googlegroups.com> |
| In reply to | #144444 |
W dniu środa, 5 czerwca 2019 03:07:35 UTC+2 użytkownik Scott napisał: > On Tue, 4 Jun 2019 16:57:43 -0700 (PDT), luser droog > <luser.droog@gmail.com> wrote: > > >Spaghetti code is obviously bad news, but what about other > >types of pasta-modeled code. Are there similar problems with > >tortellini code or lasagna code? > > A lot of code is lasagna code. Layers upon layers upon layers, and at > the bottom there's just a thin puddle of suspiciously orange grease. > > Except for networking code. That's rigatoni code. You know...tubes.... layers are great in programming, modules too, depending on how one thinks of mosules (if bigger sized or those small ones, layer may be build of pack of modules, and tehen few that layers can be insine one module if snybody would fit to that scenario that could be nice hovever some code maybe also a bit a side of that also one term of division i use is 'subsystem' as to sphagetti i could mock anybody who writes that, but incidentally like in my green.fire.dll lin i get about 100 .c files one of that 100 (related to mouse wrapping) is a sphagetti one im a bit to weary to writhe why now (in short, in generall scenario to write something a bit messy/fast only to make it work, than right about that polite (polish) it s generally quite good imo in that case hovever i managed with some unusual effort to make something work, but thenx to mostly windows eent system who made such code like teared in natural order of execution or things like that, it become real piece of sphagetti such confsing that not big thet it become real small sphagetti..and this is really untypical to me i think one day i would need to start new project and write it proper way on standalone app then integrate this what i will find into my lib as repairing it in place is exceptionally unpleasant overally as i said this windows 'template' in winapi provokes sphagetti imo (you may need a fil to generate some state variables around it (probably redundant state variables) and it make smess), i was not yet doing that cleaning
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2019-06-05 06:49 -0700 |
| Message-ID | <cf5ecebd-f58d-4d40-a12f-04a84a14b584@googlegroups.com> |
| In reply to | #144472 |
W dniu środa, 5 czerwca 2019 15:19:44 UTC+2 użytkownik fir napisał: > W dniu środa, 5 czerwca 2019 03:07:35 UTC+2 użytkownik Scott napisał: > > On Tue, 4 Jun 2019 16:57:43 -0700 (PDT), luser droog > > <luser.droog@gmail.com> wrote: > > > > >Spaghetti code is obviously bad news, but what about other > > >types of pasta-modeled code. Are there similar problems with > > >tortellini code or lasagna code? > > > > A lot of code is lasagna code. Layers upon layers upon layers, and at > > the bottom there's just a thin puddle of suspiciously orange grease. > > > > Except for networking code. That's rigatoni code. You know...tubes.... > > layers are great in programming, modules too, > depending on how one thinks of mosules (if bigger sized or those small ones, layer may be build of pack of modules, and tehen few that layers can be insine one module > if snybody would fit to that scenario that could be nice hovever some code maybe also a bit a side of that > > also one term of division i use is 'subsystem' > > as to sphagetti i could mock anybody who writes that, but incidentally like in my green.fire.dll lin i get about 100 .c files one of that 100 (related to mouse wrapping) is a sphagetti one > > im a bit to weary to writhe why now > > (in short, in generall scenario to write something a bit messy/fast only to make it work, than right about that polite (polish) it s generally quite good imo > > in that case hovever i managed with some unusual effort to make something work, but thenx to mostly windows eent system who made such code like teared in natural order of execution or things like that, it become real piece of sphagetti such confsing that not big thet it become real small sphagetti..and this is really untypical to me > > i think one day i would need to start new project and write it proper way on standalone app then integrate this what i will find into my lib as repairing it in place is exceptionally unpleasant > > overally as i said this windows 'template' in winapi provokes sphagetti imo (you may need a fil to generate some state variables around it (probably redundant state variables) and it make smess), i was not yet doing that cleaning layers i especially like from one reason, 1) you may build your code up on your layers which you can define as handy as you invent and it is very nice 2) (this mentioned reason) you may get back to lower layers after writting the upper and improve it (this i find especially nice) as to styles of coding tere are numerous one, and soem are worth of mocking (criticisizing)..one is what i recently possibly mentioned, if librery gives you api that operates on its underlaying ram pools (ram blocks) in a way that is not especially clear to user i could name such coding as a 'mamba' code (from a monster that could eat your ram) (maybe also there could be met something like that above but not eating ram but eating cpu cycles/watt power (though its rarely seen) - godzilla coding ? also some variont is a coding that may hang your aplication on some api its uses - if this api makes hangs for few seconds its terrible (soem winsock2 i used could do that, its terrible, got no name for that) also code who defines many typedefs liek winapi is worth mocking imo (mockingbird code?) (if someone would need some abstract type thay could rather be established on c leve) .. worth maybe noting that c itself made that error by its function pointer typedefs, which are trash..feels same bad as winapi typedefs or macros
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2019-06-05 07:05 -0700 |
| Message-ID | <cad9991a-61cd-4e8a-bdbf-7e455e366ea8@googlegroups.com> |
| In reply to | #144475 |
also that codeing type that dont gives you direct and full acceds to underlaying resuorces but give you crippled api for tht needs separate name (example is winapi TTF rendering, where you need mess with those dibs and other crap - instead being able to direct it and use it oer your own ram array) various api i seen in my life was like trash more or less (even if there is a way to do things proper and not being imited the time to find it out is a bit longer than it should, and the way is not so strightforward as it should ;c )
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2019-06-05 07:19 -0700 |
| Message-ID | <5942fe40-7284-407b-86d1-c03e27e60a25@googlegroups.com> |
| In reply to | #144472 |
W dniu środa, 5 czerwca 2019 15:19:44 UTC+2 użytkownik fir napisał: > > as to sphagetti i could mock anybody who writes that, but incidentally like in my green.fire.dll lin i get about 100 .c files one of that 100 (related to mouse wrapping) is a sphagetti one > its now like more 120 .c files now one mentioned is real sphagetti one, and few other related to winapi window are slightly tainted by sphagetti/chaos
[toc] | [prev] | [next] | [standalone]
| From | Keith Thompson <kst-u@mib.org> |
|---|---|
| Date | 2019-06-04 18:42 -0700 |
| Message-ID | <lnv9xkvmds.fsf@kst-u.example.com> |
| In reply to | #144440 |
luser droog <luser.droog@gmail.com> writes:
> Spaghetti code is obviously bad news, but what about other
> types of pasta-modeled code. Are there similar problems with
> tortellini code or lasagna code?
Probably a joke, but there are other pasta-derived terms for bad code.
https://en.wikipedia.org/wiki/Spaghetti_code#Related_phrases
Ravioli code is a term specific to object-oriented
programming. It describes code that comprises well-structured
classes that are easy to understand in isolation, but difficult
to understand as a whole.
Lasagna code refers to code whose layers are so complicated and
intertwined that making a change in one layer would necessitate
changes in all other layers.
--
Keith Thompson (The_Other_Keith) kst-u@mib.org <http://www.ghoti.net/~kst>
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
[toc] | [prev] | [next] | [standalone]
| From | David Brown <david.brown@hesbynett.no> |
|---|---|
| Date | 2019-06-05 09:03 +0200 |
| Message-ID | <qd7pf6$1e0$1@dont-email.me> |
| In reply to | #144446 |
On 05/06/2019 03:42, Keith Thompson wrote: > luser droog <luser.droog@gmail.com> writes: >> Spaghetti code is obviously bad news, but what about other >> types of pasta-modeled code. Are there similar problems with >> tortellini code or lasagna code? > > Probably a joke, but there are other pasta-derived terms for bad code. > > https://en.wikipedia.org/wiki/Spaghetti_code#Related_phrases > > Ravioli code is a term specific to object-oriented > programming. It describes code that comprises well-structured > classes that are easy to understand in isolation, but difficult > to understand as a whole. > > Lasagna code refers to code whose layers are so complicated and > intertwined that making a change in one layer would necessitate > changes in all other layers. > When I talk about "lasagne code", I don't see the layers as being intertwined - merely that there are lots and lots of layers. I see this often in "software development kits" for microcontrollers. Often in this sort of programming, you need efficient code - small, fast code means smaller, cheaper devices, lower power, easier electronics, etc. And whereas modern x86 cpus excel at getting fast results from inefficient code, with their superscaler execution, branch predictions, register renaming, etc., on embedded microcontrollers inefficient assembly means poor results. Very often, actions on the microcontroller actually only need simple code - driving a pin or sending a character on a UART might not need anything more than writing a value to a specific fixed address for a hardware register. But SDK's with their layers of drivers, abstractions, indirections, etc., can easily mean you have a half-dozen nested function calls to get to that single write instruction, and a half-dozen returns, with each function in the path doing nothing useful except passing on responsibility to the next one. So that is what /I/ mean by "lasagne code". (It is quite different from code where you /usefully/ have layers for abstractions and interfaces.) You could have "tagliatelle code", which looks modular when viewed from a distance, but on closer inspection each module is a tangled mess.
[toc] | [prev] | [next] | [standalone]
| From | Jorgen Grahn <grahn+nntp@snipabacken.se> |
|---|---|
| Date | 2019-06-06 18:34 +0000 |
| Message-ID | <slrnqfin61.cdo.grahn+nntp@frailea.sa.invalid> |
| In reply to | #144461 |
On Wed, 2019-06-05, David Brown wrote: > On 05/06/2019 03:42, Keith Thompson wrote: >> luser droog <luser.droog@gmail.com> writes: >>> Spaghetti code is obviously bad news, but what about other >>> types of pasta-modeled code. Are there similar problems with >>> tortellini code or lasagna code? >> >> Probably a joke, but there are other pasta-derived terms for bad code. >> >> https://en.wikipedia.org/wiki/Spaghetti_code#Related_phrases >> >> Ravioli code is a term specific to object-oriented >> programming. It describes code that comprises well-structured >> classes that are easy to understand in isolation, but difficult >> to understand as a whole. >> >> Lasagna code refers to code whose layers are so complicated and >> intertwined that making a change in one layer would necessitate >> changes in all other layers. > > When I talk about "lasagne code", I don't see the layers as being > intertwined - merely that there are lots and lots of layers. That's how I've heard the phrase explained, too. (By one coworker only.) /Jorgen -- // Jorgen Grahn <grahn@ Oo o. . . \X/ snipabacken.se> O o .
[toc] | [prev] | [next] | [standalone]
| From | mark.bluemel@gmail.com |
|---|---|
| Date | 2019-06-05 02:46 -0700 |
| Message-ID | <09fef9f2-5680-4573-acca-313ad5144654@googlegroups.com> |
| In reply to | #144446 |
On Wednesday, 5 June 2019 02:42:20 UTC+1, Keith Thompson wrote: > luser droog <luser.droog@gmail.com> writes: > > Spaghetti code is obviously bad news, but what about other > > types of pasta-modeled code. Are there similar problems with > > tortellini code or lasagna code? > > Probably a joke, but there are other pasta-derived terms for bad code. > > https://en.wikipedia.org/wiki/Spaghetti_code#Related_phrases > > Ravioli code is a term specific to object-oriented > programming. It describes code that comprises well-structured > classes that are easy to understand in isolation, but difficult > to understand as a whole. > > Lasagna code refers to code whose layers are so complicated and > intertwined that making a change in one layer would necessitate > changes in all other layers. I vaguely remember a whole article (in one of the free computing magazines of the early 1980s) based around pasta models for programming. I can recall that there was a "macaroni code" description, but can no long remember the details - I think ravioli and lasagne were as described above, though the term object-oriented wasn't used.
[toc] | [prev] | [next] | [standalone]
| From | Malcolm McLean <malcolm.arthur.mclean@gmail.com> |
|---|---|
| Date | 2019-06-05 06:45 -0700 |
| Message-ID | <23977d0a-2312-4e0d-8e6d-caeefd55c6d2@googlegroups.com> |
| In reply to | #144440 |
On Wednesday, 5 June 2019 00:57:59 UTC+1, luser droog wrote:
> Spaghetti code is obviously bad news, but what about other
> types of pasta-modeled code. Are there similar problems with
> tortellini code or lasagna code?
>
Not sure what tortellini code is. Lasagna code is a big problem, however.
Firstly, all the interfaces are familiar to the person who designed them,
but not to the reading programmer.
So if you see
y = safe_sqrt(x);
obviously that means that the function does something if x is negative.
But what? Does it terminate with an error message, always return a quiet
NaN, return 0, -1, -sqrt(abs(x)), sqrt(abs(x)) ?
We just don't know, so we've got to find the file in which it is defined,
and check.
Now if this function reads
double safe_sqrt(double x)
{
if(x < 0)
return do_negative_sqrt(x, false);
else
return sqrt(x);
}
That doesn't help us. The function does almost nothing, just passing on
work to do_negative_sqrt(x); And we don't have a clue what the "false"
parameter means. So it's more chasing up.
By the time we've worked out what is going on, our thread of concentration
has snapped. It's hard to go back to the original function and remember
why we wanted to know what safe_sqrt() did in the first place.
[toc] | [prev] | [next] | [standalone]
| From | fir <profesor.fir@gmail.com> |
|---|---|
| Date | 2019-06-05 06:54 -0700 |
| Message-ID | <70729ed7-8b51-4e63-991f-881f4146fe75@googlegroups.com> |
| In reply to | #144474 |
W dniu środa, 5 czerwca 2019 15:45:38 UTC+2 użytkownik Malcolm McLean napisał:
> On Wednesday, 5 June 2019 00:57:59 UTC+1, luser droog wrote:
> > Spaghetti code is obviously bad news, but what about other
> > types of pasta-modeled code. Are there similar problems with
> > tortellini code or lasagna code?
> >
> Not sure what tortellini code is. Lasagna code is a big problem, however.
> Firstly, all the interfaces are familiar to the person who designed them,
> but not to the reading programmer.
>
> So if you see
>
> y = safe_sqrt(x);
>
> obviously that means that the function does something if x is negative.
> But what? Does it terminate with an error message, always return a quiet
> NaN, return 0, -1, -sqrt(abs(x)), sqrt(abs(x)) ?
>
> We just don't know, so we've got to find the file in which it is defined,
> and check.
>
> Now if this function reads
>
> double safe_sqrt(double x)
> {
> if(x < 0)
> return do_negative_sqrt(x, false);
> else
> return sqrt(x);
> }
>
> That doesn't help us. The function does almost nothing, just passing on
> work to do_negative_sqrt(x); And we don't have a clue what the "false"
> parameter means. So it's more chasing up.
>
> By the time we've worked out what is going on, our thread of concentration
> has snapped. It's hard to go back to the original function and remember
> why we wanted to know what safe_sqrt() did in the first place.
i dont find it a problem, i write exactly this way (also invented word safe for myself )
as to using api good lookup page for api is very helpfull, like this "c++ reference" i chose when googling c lib api when i need to use it is very good to me
layers are terribly good if properly written
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.c
csiph-web