Not sure how to even search for this topic so I'm just going to ask. I have a couple places in my code where changes to one function have to be also made to a similar function. Basically the operations in the functions are very similar but the data being worked on is different.
I don't like it but for now that's how it is. My question is anyone knows of a way or a tool that will notify me if a certain function has changed. If I get the notification I know to confirm the changes were made to other function.
Please don't tell me to change my code. I know this isn't ideal and thought has been put into alternatives, but nothing elegant has popped up.
Thanks,
Gunner
Here is an idea I have. Maybe it will set the train of thought...
I can add a special comment in my code for a block that I want to be tracked. The comment will have opening and closing syntax:
my_code.php...
//track-start-1234
[CODE]
//track-end-1234
//track-start-5678
[CODE]
//track-end-5678
I will then have a script that I tell to check a list of files, my_code.php, for now. It will look for the special comment syntax. "1234" will represent a file that holds the last modified code for that function, so 1234.php. If the contents between the comments do not match the code stored in the file then an alert is fired. Also I might add a relationship to the other code so the alert says something like
Code 1234 has changed. Please make sure code 5678 has been updated as well.
I think I can add this script to GIT somehow so it either is part of the core git commands like "push" or maybe just another command I have to run as part of our deployment process. A second option might be adding it to phpstorm's code inspector or something like that.
When the code has been modified and everything is good I will just manually copy the new code into the comparison file. There will not be a ton of updates so this will not be too tedious.
For now this is probably the route I'll go, but any critiques or suggestions are definately welcome.
Related
I'm looking for pointers to solutions for a problem that must have been solved multiple times (or pointers to the proper terms to search for):
How to get a reasonably quick/cheap directory snapshot/hash that can be used to determine whether something has changed compared to a previous state (which can be during a previous run of the code)?
Edit: I'm thinking here in the 1st place of added or deleted files/directories, but also of file changes that can be determined without reading the entire file.
Edit2: I'm looking for something cross-platform, and not a notification mechanism (sadly).
Thanks!
Every time when i past some code snippets in Github reply box, it past with weird indentation... which i fix manually every time.. i could possibly indent/format it first in my code editor.. copy and paste directly.. which could work.. however when i am more in a rush.. and copy a block directly from my running code.. it kind of a hassle to format... or even worse when i type code directly there...
is there any browser extension? hide short-cut wizardry that im not aware of in Github to format and indent my reply quickly?
You might want to try: https://github.com/panzerdp/clipboardy, it does look like it keeps formatting not only in GitHub, but also SO and others.
Many other extensions that might be useful here: https://github.com/showcases/github-browser-extensions.
I am looking to develop a framework, for which I dont want get into details.
Suppose if I am having 100+ classes with 1000+ methods in my iPhone application.
In this scenario I want to add NSLog in each method(at start or end or both) of each class.
Manually adding NSLog is possible but is there any better solution?
Like building application in such a way that I can add this Log without me having to do manual work.
Thanks and Regards,
Denis,
Your answer was most useful throughout many forums.
Thanks a lot.
The reason I'm looking for something like this is, we have many client projects and many time it happens that we get some crashing or other issues while QA and UAT. ~80% of them are not reproducible or require some particular scenario. We were using .crash and dsym to track such issues. But it is not that useful in such scenario.
What I'm looking for is providing add hoc build which will log the steps which user has followed so that it will make easy to reproduce such issues.
Currently I am using precompiled headers and first method you have mentioned (searching for the first opening brace then replace it with macro).
I will look into DTrace and objc_msgSend as you mentioned. I will google out these meanwhile if you have any preferred tutorials it will be great.
Thanks and Regards,
:D
So you want to add a trace facility to your code?
Apple doesn't provide anything like this. You'll have to add your trace facility yourself. If your source code style is consistent, this might be relatively easy to do automatically, something like searching for the first opening brace following a line starting with a minus (or plus) sign...
Alternatively, you might want to use the public Objective-C runtime functions to enumerate all classes and all their methods, then method-swizzle each of them with another one that NSLog before jumping to the original.
Alternatively, you can take the open source implementation of objc_msgSend and insert a call to NSLog at the beginning. Note that obj_msgSend tail calls into the method, so that will prevent you from adding a call upon return. Be prepared to humongous output of course. You might want to condition your call to NSLog to the value of the selector parameter to objc_msgSend (such as a common prefix).
Finally, the best way to trace is probably to attach a DTrace probe to the entry to objc_msgSend. For the same tail-call reason mentioned above, you won't be able to attach a DTrace probe to its return though.
But the better question is why do you want to do that.
I am working on zend framework. I have mistakenly created some actions which are not useful for me now. So either I want to remove those actions or rename them. Is there any command by which I can do that. If no, how can I do it manually? Means which are the files I need to edit to remove or rename the action completely.
I think it should be enough to remove the xxxxxAction() methods from your controllers. This is how I've always done it. If you have view scripts associated to the action it's good to remove them too, for housekeeping purposes, although it's not strictly necessary. If you are using Zend_Tool, you'll also need to edit your .zfproject.xml file (it's used only by Zend_Tool).
Perhaps there is another way of doing it, using Zend_Tool, but I'm more used to work "the manual way".
EDIT:
Actually, there is a similar question already posted: Zend_Tool remove controller/action
Hope that helps...
Does anyone know of a software or system for automatically tracking and logging exact line code changes into a log file?
For example, lets say I edit 7 files on Jan 16th, and I add and modify several lines of code in each file.
Is there a software or tool of any kind that would automagically know what edits I made, what was changed, and log the details in date order line-item file?
I am guessing something exists like this, but I cannot find out what I should be searching for. I looked at SVN and some other similar, but didn't get these capabilities from the descriptions I read.
There's nothing that would automagically know this. This sort of information is easy to come by as a side-effect of using virtually any version control system though. It sounds like you're not using any VCS, you should start doing so now. SVN is a good option to start with.