Re: Duplicate code




nick_keighley_nos...@xxxxxxxxxxx wrote:
On 8 Dec, 22:57, c.prog....@xxxxxxxxxxxxxx wrote:
nick_keighley_nos...@xxxxxxxxxxx wrote:

In fact if they don't do that I don't see how other
parts of your program can tell which of a or b are set correctly.

Note : this a sample program so actual code differs from it say that
is more complex. Also I don't get what you mean here ; Can you explain
please ?

no not really. If you explain what you are trying to do I might
be able to suggest a sensible design (or someone else might).
The slightly snotty attitude doesn't help you either.

It seems really odd to me that you initialise only one
of two fields. You also cannot tell which one is initialised
without examining something external to the structure. For
instance your 'select' variable may be global

Have you looked at typedef and union? They might be applicable
to you program

Sure typedef was used in original code.Union ? I thought I am the only
one here who over simplifies.

as I said, slightly snotty


--
Nick Keighley

Hi ,
Some notes :

1.As I already said a model is just a model not matching completely
with the original phenomenon. In the particular case structures have
been there for some time and that means that some functions use them
the way they are. Do they look odd ? yes maybe ; but even now I prefer
them like they are , though this may change. Also for the model there
is initialization but in practice there are many various functions
working with them. The ones who work with sub-structures usually act
as duals on both. So the act of updating is simultaneous in most cases
at least it is what I (suppose to) know now. Maybe the names I chose
were not the best also the functions. And interesting fact is that
some suggestions seemed to be ok since they prevent code duplication
(at least this is what my eyes see). Even it was implemented and
worked and it doesn't seem to contain bugs and appears ( to me ) that
it does not do extra work either. Maybe I can work with that too
(personal preference). Of course there are better ways to be found all
the time.

2.I did not mean to act as one who knows more ; In fact I think
everyone here knows more about programming in general and c
programming in particular. That's what the ID stands for "a c prog
(ramming) fan" not a "c programmer" or anything alike. I was just
trying to say that a specific method seems to solve the problems I
currently recognize in a particular project with someone who has
little knowledge. Note that if I post the actual code and everyone
make suggestions ( there would be so many I am sure ) then I would not
be learning because my knowledge, IQ, experience etc is limited and I
can step not run.

3.Please excuse me everyone because it seems that some got sad with my
sayings here ; I may not post on this group anymore.

Thanks for your patience.
.



Relevant Pages

  • Re: Duplicate code
    ... to want to use both a and b even though you initialise ... As I remarked this seems "odd" ... The ones who work with sub-structures usually act ...
    (comp.lang.c)
  • Re: Pace of Arctic climate change sounds alarm
    ... > doesn't need to worry as much about the dust kicked up by the odd ... > forced to act on merely for climactic reasons. ...
    (sci.astro.amateur)
  • Re: Can I overload
    ... It looks like dotnet won't marshal this which seems odd as it's ... just a plain old guid. ... I've created my own class to act as a variant and ...
    (microsoft.public.dotnet.framework.interop)
  • Bumpers #682 - Thursday 9.22.05 - Show #2432
    ... QUOTES, RAMBLINGS, and such ... ... - The only thing I could say at the end of ACT 4, "What an odd ... I enjoyed Dave's comment at the top of ACT 6. ...
    (alt.fan.letterman)