|
A few posts above I also commented on flags.
[flags]
public enum D_SOMEFLAGS : ulong
{
NONE = 0x0000000000000000,
VALIDATED = 0x0000000000000001,
CHANGED = 0x0000000000000002,
}
would it not be better (using my example there) to add something like
...
CHANGED_AND_VALIDATED = 0x0000000000000003;
...
to the enumeration?
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
Yes and I add such extra pieces to enumerations too. However, in the situation I mentioned there are a lot of various flags and the additional enum member would look sth like
CHANGED_AND_VALIDATED_AND_FLAG3_AND_FLAG5_AND_FLAG11_AND_FLAG12_AND_.... = some code
I have nothing against long names in programming but if a name of one of constants starts taking more than 10% of a whole method content then something is going wrong I think.
Although 0x0301 contains just three flags, it's very simple to determine which flags are used (x0100 , x0200 and x0001 ), therefore there is nothing bad in ecode boolean names.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
True, but in that case usually some kind of operation is associated with a particular combination of flags. You might use the name of this operation instead of naming all Flags involved. You can still elaborate in the comments. Something like this:
...
MODIFIED_BY_USER = 0x90aebeee7a3f017b,
...
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
Dammmit we still agree. I was thinking of it when I was posting my message and wondering if you express that. Hmm I think we have a dead end in this discussion. Cool signature by the way.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
Agreement is the best conclusion we can reach.
Until next time then.
A while ago he asked me what he should have printed on my business cards. I said 'Wizard'.
I read books which nobody else understand. Then I do something which nobody understands. After that the computer does something which nobody understands. When asked, I say things about the results which nobody understand. But everybody expects miracles from me on a regular basis. Looks to me like the classical definition of a wizard.
|
|
|
|
|
HTML
Please, who decided that tags like <br> didn't have to be closed. Now parsers have to waste their time checking for a closing tag. Also, how could people think that <b><i></b></i> is ok? And what about <div><div></div>?
And what about JavaScript and the like? Why consider ' and " only within a script tag, and then allow <, but outside a script tag treat any instance of < as a tag opener?
People's laziness in writing HTML slows down my computer by wasting processing.
But seriously, why did people decide that HTMLers would be too stupid/lazy to close tags and layer them correctly?
|
|
|
|
|
To add to it, how hard would it be to write an HTML editor that closes the tags for those lazy HTMLers
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
My favourite part was when the OP forgot to tick the "Ignore HTML tags in this message (good for code snippets) checkbox!!
--------------------------------------------------------
Knowledge is knowing that the tomato is a fruit.
Wisdom is not putting it in fruit salad!!
|
|
|
|
|
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
<b><i></i></b> Looks OK to me.
|
|
|
|
|
Fixed
|
|
|
|
|
Actually, that is what makes the web so great. By lowering the barrier to entry it let many people without technical skills get information out. If we raise the level of skill to put out a simple web page, then we'll leave some people out. Anybody that likes and gets serious will want to get better to do more complex things. Or they'll get a copy of Frontpage (or something like that).
Hogan
|
|
|
|
|
Yes, but closing tags in order and closing all tags is not complicated at all, and no technical skills are required to do so.
|
|
|
|
|
I have to agree. It just isn't that hard to properly format tag.
Bill W
|
|
|
|
|
jamie550 wrote: Also, how could people think that is ok?
Because when applying that formatting in your favorite word processor you only need to apply bold and italic once each. You don;t have to apply one separately on each side of the other. Having learned how to do the task one way, a user will always try to do a conceptually similar task the same way in other applications.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
dan neely wrote: Because when applying that formatting in your favorite word processor you only need to apply bold and italic once each. You don;t have to apply one separately on each side of the other. Having learned how to do the task one way, a user will always try to do a conceptually similar task the same way in other applications.
This is not true, in WordPerfect For DOS you must start a Bold section and then close the bold section. The same for italic and underline.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
Which would mean that the 5% of lusers who learned word processing on WP would get it right, but the 95% whose first PC had a GUI would still be doing it the wrong way.
Today's lesson is brought to you by the word "niggardly". Remember kids, don't attribute to racism what can be explained by Scandinavian language roots.
-- Robert Royall
|
|
|
|
|
jamie550 wrote: But seriously, why did people decide that HTMLers would be too stupid/lazy to close tags and layer them correctly?
That was an excellent guess, as a matter of fact. People _are_ too lazy to close tags, a chance that some people realized that.
|
|
|
|
|
who decided that tags like <br> didn't have to be closed
Well, that's named HTML, and it have been around for many years. Way before XML was invented...
Now parsers have to waste their time checking for a closing tag
You just have to use an HTML parser, using the right DTD, indicating which tags must be closed and which might be left "open", and what is their scope (closed by another kind of tag), instead of an XML parser...
Incorrect HTML: that's another story, that's why browsers are so tolerant (more or less: a browser might close a div by itself, another will take the div ends at the bottom of the document...).
I don't understand the rant about JS...
Anyway, should I have to parse HTML pages, I would use a good library like TagSoup to handle all these peculiarities.
|
|
|
|
|
Hi all,
I am new to this forum and generally any programming help forum for that matter.
I have a case where i want to maintain both C and C++ api library. So therefore i choose to make my C++ support a thin wrapper around the C code. However, i do not know what is the most effective way to achieve this without unnecessary memory and performance overhead. Below is an example case.
/*Begin Code Sample*/
/*Start time.h*/
struct Time
{
int seconds,
int nanoseconds
};
void timeAdd(struct Time* time, struct Time* delta);
void timeSub(struct Time* time, struct Time* delta);
/*End time.h*/
/*Start timer.h*/
struct Timer
{
struct Time time;
void (*callback)(struct Timer *timer);
};
void timerSetCallback(struct Timer *timer, void (*callback)(struct Timer *timer));
void timerStart(struct Timer *timer);
void timerStop(struct Timer *timer);
/*End timer.h*/
/*Start time.hxx*/
namespace C
{
#include "time.h"
}
class Time
{
public:
Time()
{
m_time.seconds = 0;
m_time.nanoseconds = 0;
};
~Time(){};
int seconds(){return m_time.seconds;}
int nanoseconds(){return m_time.nanoseconds;}
void setSeconds(int seconds){m_time.seconds = seconds};
void setNanoseconds(int nanoseconds){m_time.nanoseconds = nanoseconds};
void add(Time &time){C::timeAdd(&m_time, &time.m_time);};
void sub(Time &time){C::timeSub(&m_time, &time.m_time);};
protected:
C::Time m_time;
};
/*End time.hxx*/
/*Start timer.hxx*/
#include "timer.h"
class Timer : public Time
{
public:
Timer():Time(){m_timer.callback = &Timer::callback;};
~Timer(){C::timerStop(&m_timer);};
start(){m_timer.time = m_time; C::timerStart(&m_timer);};
stop(){C::timerStop(&m_timer);};
protected:
static void callback(struct Timer *timer);
C::Timer m_timer;
};
/*End Code Sample*/
Now while this works for this simple case, it has a few drawbacks like the additional memory used to allocate m_time in class Time when all of struct Time api's would have even worked for struct Timer and hence struct Time m_time could have been "replaced" by struct Timer m_time but instead both exist in class Timer.
It also is the simpler of the cases where the struct sizes are relatively small and the call to Timer::start() was easily managed by a copy of the struct.
So now, my question is how can c++ wrappers be written for such cases without the additional memory overhead? Given their similarity, I definitely want class Timer to be a subclass of class Time!
However, i do have the flexibility to modify both the C and C++ code but i need both the C and C++ code to be equally capable, clean and efficient. How can i do it?
|
|
|
|
|
Kishore Jonnalagadda wrote: However, i do have the flexibility to modify both the C and C++ code but i need both the C and C++ code to be equally capable, clean and efficient. How can i do it?
Posting in the correct forum would be a good start.
Try here[^]
Prepare to be flamed.
I'm largely language agnostic
After a while they all bug me
|
|
|
|
|
You should have started by reading the header of this forum, specifically where, in bold red letters, it says:
Do not post programming questions in this forum.
|
|
|
|
|
Probably the bold text should be in all capital and font size 36!
|
|
|
|
|
No programming questions in this particular forum
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
My apologies for being on the wrong forum. I have posted again at http://www.codeproject.com/script/Forums/View.aspx?fid=1647
Cheers!
Kishore
|
|
|
|