Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I check that Properties linking to components is not "lost"?

Tags:

delphi

I'm using Delphi 2007. Sometimes properties linking to components get lost. This is typically Action properties and lookupdatasets. I have a few times had some emergency bug fixes and sent out a version to customers with a somewhat catastrophic result due to this :-) Anyone know a way to verify that properties that are supposed to be set really are set, or a way to prevent this from happening?

like image 944
Tom Avatar asked Jan 29 '09 11:01

Tom


People also ask

How do I pass props through link?

To recap, if you need to pass data from Link through to the new component that's being rendered, pass Link s a state prop with the data you want to pass through. Then, to access the Link s state property from the component that's being rendered, use the useLocation Hook to get access to location.

How do you handle shared state between components?

In React, sharing state is accomplished by moving it up to the closest common ancestor of the components that need it. This is called “lifting state up”. We will remove the local state from the TemperatureInput and move it into the Calculator instead.

What happens if you do not add key prop to dynamically created elements?

It will do nothing; you have to call render method to render the component again.

What is useRouteMatch?

useRouteMatch. Provides access to the match object. If it is provided with no arguments, it returns the closest match in the component or its parents. A primary use case would be to construct nested paths.


6 Answers

You can assign such values in code, obviously.

More importantly though, you have to diff every file before committing to sourcecontrol. Always.

Make sure your dfm-files is text, not binary. Then it will be easy to see unwanted changes before check-in/commit.

Diffing everything have stopped a lot of potential blunders for me.

An automatic build and test-system would also give you some confidence in what you deliver.

like image 122
Vegar Avatar answered Oct 10 '22 11:10

Vegar


You've received several good answers about how to detect when this does happen (up voted). But one way to prevent it from happening (sometimes) is to make sure that you have added all of the referenced units to your DPR. If you open a form, for example, which contains components that reference other components on a data module, and that data module has not been added to the DPR/project, you're almost guaranteed to have the IDE remove those references, because it removes references which it cannot determine are valid. If, on the other hand, the data module is in the DPR, then the IDE will be able to find it, and it is less likely to remove the references in the first place

Unfortunately, it still happens from time to time, so you still need to take the precautionary measures detailed in the other answers. But this will make things better, if you don't already do this.

like image 34
Craig Stuntz Avatar answered Oct 10 '22 09:10

Craig Stuntz


Create dunit test project. Run test before release. Sound all bells when test fails.

like image 27
dmajkic Avatar answered Oct 10 '22 11:10

dmajkic


You want a way to verify if the values are set correctly. Well, you can use unit tests for this. Just initiate a form, compare the properties and done.

Comparing the dfm's is also a good way ofcourse but it does not take into account changes due to changed defaults or changes in the code.

like image 39
Toon Krijthe Avatar answered Oct 10 '22 09:10

Toon Krijthe


When you add a form, data module or frame to a project, the IDE inserts a little comment "tag" after the unit name in the dpr file. It has been my experience that if for any reason this tag is not present, the IDE is more prone to losing cross-module component references.

I wholeheartedly support the idea of always viewing differences before each commit to version control, if you are using such as thing.

like image 26
Jozz Avatar answered Oct 10 '22 11:10

Jozz


I hate to say this but Source Code Control can help in these situations. Even with an emergency bug fix you should be checking everything into a source code repository (Perforce is my personal favorite). In a small fix you could see by what files have changed whether you have any changes you are not expecting.

like image 32
Toby Allen Avatar answered Oct 10 '22 11:10

Toby Allen