-
Content Count
3701 -
Joined
-
Last visited
-
Days Won
185
Everything posted by David Heffernan
-
Is it really that bad to Use boolean parameters to make your functions do two things?
David Heffernan replied to Mike Torrettinni's topic in General Help
It's strange then that you don't seem to read what people post. I get a sense sometimes that you ask questions but have already decided what the answer is. -
Is it really that bad to Use boolean parameters to make your functions do two things?
David Heffernan replied to Mike Torrettinni's topic in General Help
Names mean nothing. You have to understand what people say, and judge it for yourself. Stop following people blindly based on reputation. Try to develop your own critical assessment of what you read. -
Is it really that bad to Use boolean parameters to make your functions do two things?
David Heffernan replied to Mike Torrettinni's topic in General Help
You weren't following his advice. You misunderstood what he said. I already said this. Did you also misunderstand what I said? -
Is it really that bad to Use boolean parameters to make your functions do two things?
David Heffernan replied to Mike Torrettinni's topic in General Help
Nick's point is fine. I think you just misunderstood it to mean that you needed to replace all boolean args. Following somebody else's recipe without really grasping the issue won't make your code any better. It will just give you work to do and make it likely that you will introduce bugs to your code? If you don't have comprehensive tests for all of your code then you are in big danger of that. -
The Case of Delphi Const String Parameters
David Heffernan replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
This makes no sense whatsoever. -
The Case of Delphi Const String Parameters
David Heffernan replied to Mike Torrettinni's topic in RTL and Delphi Object Pascal
There is a well known design flaw with passing arguments to const arguments. procedure Foo(const Bar: IMyInterface); .... Foo(TMyImplementingClass.Create); As we know, Foo won't increment the reference count because Bar is const. Possible issues are the object is leaked, or released early inside Foo (e.g. if something inside takes a reference and then releases it). This should be fixed by having the compiler realise at the call site that something needs to take a reference to the interface while the function is executing, and emitting the necessary code at the call site. I've given up hope that this will ever be fixed. On the other hand, perhaps I should be pleased that Idera consider itself to be one of the hottest companies around. -
Is it really that bad to Use boolean parameters to make your functions do two things?
David Heffernan replied to Mike Torrettinni's topic in General Help
Use some judgement. You don't need to get rid of all booleans. Code like: SetControlsEnabled(True); SetMenusEnabled(True); SetFeaturesEnabled(True); is perfectly fine. Does it make sense when you read it? Yes, of course it does. What you need to watch out for is code like: EnumerateFrogs(True); Nobody reading that can infer what the argument does. -
That's not a problem with the Delphi side of things, that would be a basic design flaw of the library. If the consumer of the library has to call functions that it can't access, in order to use the library, then the library is unusable. You are better off not to speculate and guess like this. If the asker has a question, trust them to ask it.
-
Not really. You still declare it as a pointer and call the library function to open the file, and a pointer is returned. Only the library needs to know the implementation. It's a pointer to an opaque struct.
-
Then an untyped pointer will do.
-
This question is only useful to you if the answer is yes. The answer is no. And you are none the wiser. What you perhaps should have asked about was the underlying reason why you are concerned with a FILE*
-
Security - How freaky can you get!
David Heffernan replied to Clément's topic in Algorithms, Data Structures and Class Design
And my point is that you are giving yourself a false sense of security. It will take you extra time to develop your own licensing system, and then it gets cracked anyway. You may as well use a standard off the shelf tool and save yourself the time. Plus your paying users are able to use a system that they are familiar with for other software. -
Security - How freaky can you get!
David Heffernan replied to Clément's topic in Algorithms, Data Structures and Class Design
If somebody wants to crack your program then your home brew protection won't hold up either. -
Security - How freaky can you get!
David Heffernan replied to Clément's topic in Algorithms, Data Structures and Class Design
This won't work either. -
Security - How freaky can you get!
David Heffernan replied to Clément's topic in Algorithms, Data Structures and Class Design
All of these security hardware devices are crackable. HASP has a terrible record. And the prices they charge are just ludicrous. You should view these things as a means to help your paying customers use the right amount of licences. They are not going to help you stop hackers cracking your program. -
Security - How freaky can you get!
David Heffernan replied to Clément's topic in Algorithms, Data Structures and Class Design
All of this advice is kinda pointless if the attacker is inside your building! -
You said "stolen" which seemed odd. I don't know where you get your monetary figures from.
-
Leave it as an enum, but set the right enum size http://docwiki.embarcadero.com/RADStudio/Sydney/en/Minimum_enumeration_size_(Delphi)
-
You missed the language member. And probably the enum is actually an int and so 4 bytes.
-
I'm pretty sure that he chose to go to MS. And it looks like an inspired decision now. Look what he has built there.
-
When sorting a “StringList” is very costly
David Heffernan replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
We've talked about this before I think. Stefan and I developed one for spring4d. You'll find it in the develop branch. As I'm sure you know, Timsort is stable. -
When sorting a “StringList” is very costly
David Heffernan replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
These days I use Timsort for this reason. -
When sorting a “StringList” is very costly
David Heffernan replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
You don't need a new control. You just need not to use it to store your data. Store your data in a non visual control. -
When sorting a “StringList” is very costly
David Heffernan replied to dummzeuch's topic in Tips / Blogs / Tutorials / Videos
Paying the price for using a GUI control to hold your data, rather than to view your data. -
Performance of MOVE vs + for concatenating mixed type values
David Heffernan replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
The funny thing about this, is that the RTL code that implements a concatenation does this: Sum the length of all input strings. Allocate a new string of that length. Loop through all the input strings, moving their content to the new string. Return that new string. So even if this was your bottleneck, the RTL is already optimised!! In that original post that you linked, you were concatenating two strings, but repeatedly in a loop. So you had one allocation per expression. Here you have a single expression concatenating 11 strings. And that also has one allocation, because the RTL is, in this instance, not stupid. Bottom line is that your code using Move should be slower!! Please, please, please, take on board the lesson that optimisation starts with first identifying, with confidence, what your bottleneck is. If you can just take that lesson, then you will save lots of your time (and ours).