Re: Duplicate code
- From: nick_keighley_nospam@xxxxxxxxxxx
- Date: Tue, 9 Dec 2008 06:35:16 -0800 (PST)
On 9 Dec, 14:12, c.prog....@xxxxxxxxxxxxxx wrote:
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.
I think I was misinterprating what you were trying to.
I thought maybe you wanted to use either structure A or
structure B and using u so you could tell which one.
Hence i thought u should take a different value and
hence my sugestion to consider a union (personally
I hardly ever find a use for union). But you seem
to want to use both a and b even though you initialise
them in different places. As I remarked this seems "odd"
to me. But it's your program and only you can judge
was it right for your problem.
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
don't quote the sig
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.
? they act on both sub-structures?
So the act of updating is simultaneous in most cases
that seems *less* odd
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 ;
its just a couple of us were pressing you for more
details about your actual code. This was because the
code you presented looked "odd" and we were not sure if this
reflected
the real code or just your "model".
When I said "a little snotty" I was thinking of things like
"can you prove (ie. logic) that I said that"? (paraphrasing).
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.
I didn't mean to be that harsh.
--
Nick Keighley
.
- References:
- Duplicate code
- From: c . prog . fan
- Re: Duplicate code
- From: nick_keighley_nospam
- Re: Duplicate code
- From: c . prog . fan
- Re: Duplicate code
- From: nick_keighley_nospam
- Re: Duplicate code
- From: c . prog . fan
- Re: Duplicate code
- From: nick_keighley_nospam
- Re: Duplicate code
- From: c . prog . fan
- Duplicate code
- Prev by Date: Re: cypher
- Next by Date: Re: Duplicate code
- Previous by thread: Re: Duplicate code
- Next by thread: integer and floating point casts queries
- Index(es):
Relevant Pages
|
Loading