Good commenting practices [closed] - iphone

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 11 years ago.
Improve this question
I just completed with one of my applications which is now ready to be tested. But before submitting my application I want to make sure I have used appropriate comments wherever required. Though I use comments in most of my applications but it is this time I have realized that my application is quite complex and thus for the purpose of reviewing the code again and for functional understanding I need proper commenting. I was also worried about the amount of commenting in my application.
What I am looking for are standard commenting practices we need to follow in IPhone development.
Kindly assist.

Good Comments say "why" you did something, not "what" you did.

I usually implement comments in the following situations, (this is by no means exhaustive), and any developer reviewing or debugging your application would appreciate them in these situations:
When I use a third-party or otherwise obscure library;
In deep-nested control structures when they cannot be avoided;
When implementing my own protocols in Obj-C (when they are not obvious);
And in general when something is not obvious to you and/or a potential reviewer
EDIT: And I also suggest implementing sparingly, if you did not get that from the post. It is annoying to read code that is near the over-commenting threshold. You do not want to feel like you are reading an introduction to programming book.

There is nothing special with regard to comments and iPhone development.
Personally I prefer readable (self-documenting) code over comments. That is, using meaningful method and variable names to make the purpose of the code understood. If it still can't be understood then comments might be useful, but don't make them too long. A problem with long comments is that they might fall out of sync with the sources and become misleading.
I think links to other sources of documentation are good, such as stackoverflow questions, bug databases, etc.

These, to me, are the golden principles:
Comments should never explain code (use self-explanatory code with proper names and indentation).
Don't insult the reader's intelligence with unnesseary comments
Comment by code block (if you need to explain a process, don't use seperate comments on each line of the code block).

When Im commenting my code, I act as if I had some half wit programmer sitting right next to me asking me "what does this code do, and why are you doing it?" Ill reply in a nutshell of an answer.
My response to him is what I comment.
// now that we got the data we need lets store it in the Settings Array
// check for NULL if null, change to None Selected
// make sure there is an object here so we dont crash

Related

How to protect unity assembly without compiling to IL2CPP? [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I release a bunch of tools for free, but recently I have began to sell an application, that has private research, and people have been able to get my source code, and one person publically released my entire source. I spent a lot of time on this program, just to have someone crack it, and release my entire source.
How can I go about protecting my program? I have tried HWID, but people are still able to crack it. I know I am limited by C#, but it the most convenient to use. I just need a way to protect my programs from people trying to do this.
You could have a look at the many obfuscation tools that are out there, for example these:
http://gapotchenko.com/eazfuscator.net
http://orangeheap.blogspot.nl
http://confuser.codeplex.com (succeeded by https://yck1509.github.io/ConfuserEx/ and then again by https://github.com/XenocodeRCE/neo-ConfuserEx)
http://ntoolbox.com)
Well, the problem with languages like C#/Java is that they are generally much easier to de-obfuscate. The way to secure this is generally to put this stuff into a webservice, but you said you couldn't really do that. What about porting specific non-trivial functions over to a language like C, and obfuscate that. Your C# program could then use reflection to make calls to this external/unmanaged dll. It would increase the difficulty for de-obfuscating, but the problem is that if someone wants it bad enough, they can figure it out as it is client-side.
It may be that legal action is the only real solution here, but this is not a site for legal advice, and I am not qualified to give it if it were.
Additionally, this could be a business decision. Consider Making your software open-source and post a donation link. I am also not qualified to give business advice, but this is worth considering. It may actually increase your revenue, not to mention the other benefits that come with releasing open-source software.
There's Dotfuscator (http://www.preemptive.com/products/dotfuscator/overview). But the best solution in some cases is to offer what you do as a web site (Software as a Service).
Consider this tool for example to convert VB to C#: http://converter.telerik.com/
Or this tool to format JSON: http://jsonformatter.curiousconcept.com/
This may or may not work for you. I don't know what the nature of the software you're trying to protect is.
No, your code needs to contain the information needed to decrypt itself, its an impossible problem to solve.
Your best solution is to put your intellectual property on a server in the cloud that only you have access to. Give your customers a unique login, audit their access to check for abuse, off load as much grunt work onto your customers machines, but keep your algorithms locked into the cloud.

Code as System image (serialized run-time environment) vs Source (text) [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 6 years ago.
Improve this question
Almost all conventional languages today represent programmers intention as text source, which is then (lets say for sake of simplicity) translated to some bytecode/machine code and interpreted/executed by a VM/CPU.
There was another technique, which, for some reason, isn't that popular theese days: "freeze" the run-time of your VM and dump/serialize the environment (symbol bindings, state, code (whatever that is)) into an image, which you can then transfer, load and execute.
Consequentially, you do not "write" your code in a usual way, but you modify the environment with new symbols, while in "run-time".
I see great advantages to this technique:
Power-boosted REPL: you can introspect your code as you write it, partially evaluate it, test it directly and see the effects of your changes. Then roll back if you've messed up and do it again, or commit it to the environment finally. No need for long compile-run-debug cycle;
Some of the usual problems about dynamic languages (that they cannot be compiled, as compiler cannot reason about environments statically) are obliviated: the interpreter knows where what is located and can subsitute symbol references with static offsets and do other optimizations;
It's easier on programmer's brain: you "offload" different contextual information about the code from your head, i.e. you don't need to keep track about what your code has already done to some variable/data structure or which variable holds what: you see it directly in front of your eyes! In the usual way (writing source), programmers add new abstractions or comments to the code to clarify intents, but this can (and will) get messy.
The question is: what are disadvantages of this approach? Is there any serious critical disadvantage that I am not seeing? I know, there are some problems with it, i.e.:
try building a module system with it, that will not result in dependancy hell or serious linkage problems
security issues
try to version-control such images and enable concurrent development
But these are, IMHO, solvable with a good design.
EDIT1: concerning status "closed,primarily opinion-based". I've described two existent approaches and it is clear and obvious that one is preferred over another. Whether the reasons for that are purely "opinion-based" or there is a reasearch to back this up, is unknown to me, but even if they are opinion-based, if someone would list these reasons for such an opinion to develop, it should, actually, answer my question.
As a daily user of smalltalk, I've to say I haven't found any fundamental disadvantages and have to agree that there are lots of advantages.
It makes metaprogramming, reasoning about your program easy, and much better supports refactoring and code rewriting.
It requires/develops a different way of looking at your code, though. Smalltalk has little to offer to developers who are not interested in abstraction

What to think about when making a project open source? [closed]

Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 7 years ago.
Improve this question
I'm just about to publish a project as open source, and would really like some feedback on a couple of things:
The code is quite clean but the version control history isn't. Mistakes, debug code, perhaps inappropriate code, etc. Should I clear the history before publishing, or import it anyway to the public repository?
Should I prioritize making a tutorial, feature explanations or api documentation?
Other thoughts that makes a new project easy for people to get into?
In my very humble opinion:
1) If you're set on going open source, be proud of your code. We all know there are mistakes and bugs along the way. There are going to be more, too, so don't feel like you can't display those publically. You can!
2) Definitely. Probably in that, order, too, because that's the order that people using your product are going to read them. They'll have to use your software before they decide to work on it.
3) The best advice I can give is to have clear build instructions, hopefully with scripts to help people configure the environment. A common plague with open source software is requiring new developers to download tons of libraries and configure their box to work just right in order to be able to build the software. That, to me, is very frustrating and can put me off very quickly.
Good luck!
Totally your choice, unless you used copyrighted code for which you don't have distribution rights or if there is some issue involving redistribution, credit, whatever.
Hard to say without knowing what it is. What would you need in order to use it? What would you want to see first? (Probably the tutorial...)
Perhaps a start-to-finish example including installation. Perhaps you should go to the trouble of running it a virtual environment or on a new OS install, so you are sure your installation instructions deal with everything.
It should be easy enough to squash some commits together, and the effort will be worth it. Developers often look through the history to get an insight into how the project was designed ground-up.
Definitely. The least you can do is get some documentation engine like Doxygen to generate the documentation. Tutorial is probably unnecessary at this point; the community will write tutorials for you, provided the code is nicely documented.
Good packaging always helps. Generate pre-compiled binaries for more than one architecture, and if feasible, create RPMs and DEBs. This lowers the entry barrier greatly. Nobody contributes to software they don't use. You could additionally use a nice bug tracker like Bugzilla, or use an integrated solution like Launchpad or Trac. Also set up a mailing list and IRC channel. This will help build a community.

Learning... anything really [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I'm particularly interested in Windows PowerShell, but here's a somewhat more general complaint:
When asking for help on learning something new, be it a small subject on PHP or understanding a class in Java, what usually happens is that people direct me towards the documentation pages.
What I'm looking for is somewhat of a course. A deep explanation of why something works the way it does.
I know my basic programming, like Java and C#. I've never seen C or C++, though I have seen a bit of assembler. I know what the Stack and Heap are, how boxing and unboxing works, why you have to deep-copy an array instead of copying the pointer and some other things.
Windows PowerShell on the other hand, I know nothing about. And I notice that when reading the small document or some code, I usually forget what it does or why it works.
What I am looking for is preferably, a nice tutorial that explains the beginnings, the concepts, and goes to more difficult things at a steady pace.
The only thing documentation can do is explain what a function does. That's no good to me since I don't know what I want to do yet. I could read about a thousand functions, and forget about most of them, because I don't need to implement them right after it. Randomly wandering through the documentation doesn't do me any good.
So conclude, what is a good tutorial on Windows Powershell? One which explains in clear language what is happening, one which builds on previous things learned.
I don't think googling this is a good idea. Doing a Google search on this would turn up numerous tutorials. And experience tells me that you have to look long and hard to find the gem you're looking for. That's why I'm asking here. Because this is the place where you can find more experienced people. Many of the PowerShell guys among you will know the good ones already, and by asking you, I avoid wasting time that could be spent learning. So to summarize: I will not google this!
I wrote a free eBook along these lines. I will let you be the judge of whether or not it is good but my goal was to provide folks with a good mental model for how PowerShell works. You can download it from here. It is about 60 pages or so. You can find a more comprehensive free ebook online called Master-PowerShell.
Of course, you can peruse StackOverflow for Q&A and also ask questions as you have them.
I like this one
http://arstechnica.com/business/news/2005/10/msh.ars/2
I wouldn't consider doing research on a programming language a failure, even if it takes you forever to find that "gem" you are looking for. Searching for awesome material is an art and the more you do it, the better you get at it. The community won't always be able (or willing) to answer all of your questions for you, especially if they know you haven't done your due diligence to look something up.
"What tutorial do you recommend for learning PowerShell?" might be an answer to your question.
I like to use the O'Reilly Pocket Reference versions of books to get started in a new subject. Easy to take with you on the plane, on a lunch break, or in the necessary (beats People magazine).
Here's the Windows PowerShell Pocket Reference at Amazon. $6.84 for a Used copy.

Where can I get good answers to my Perl-related questions? [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
AFAIK one of the objectives of Stack Overflow is to make sure anyone can come here and find good answers to her Perl related questions. Certainly beginners would ask what is the best online source to learn Perl but others might just want to ask a question.
Probably the friendliest place is the Monastery of Perl Monks. It is a web site with a rating system similar to but more simple than Stack Overflow. You can find lots of good answers there and if you don't find an answer you can always ask.
The other big resource would be the mailing list of your local Perl Mongers group.
Where do you go when you are looking for an answer to a Perl related question?
It's worth noting that http://perlmonks.org, in addition to the fora, has the Chatterbox, where simple questions can be answered immediately in conversation with other users.
It requires setting up an account and logging in before using the Chatterbox, though.
Thus far, I've been pretty content with the quality of Perl answers I've seen here. Many of the most experienced Perl programmers I know from conferences, Perlmonks, use.perl.org, etc. seem to be present here and answering questions seriously and clearly. In cases where an answer has been wrong or simply bad in a sense of promoting bad practice, those answers have been quickly identified, voted down and/or commented-upon.
I'm a great fan of Perlmonks, but it's a different sort of site than this one. Besides being specific to Perl, it also has separate areas set aside for reviewing modules, posting code snippets, reviewing books, etc.
Best place: here. Each time I asked, I got correct answers, in less than 20 minutes. Faster that anywhere else.
I've never asked questions, but that's probably because I tend to write simple scripts rather than applications.
Have always found the Perldoc site to be a good way to work out how to do stuff - and I normally learn a bit more whilst looking.
Sometimes, it might be worthwhile to try to get help via IRC. Quite some time ago, I found the #perl channel on the freenode network to be pretty friendly and helpful. As always it's important that you have exhausted the normal means of solving your problem: Read the documentation, search the web, etc.
However, I'll also take this opportunity to mention where you should not go asking for help: The #perl channel on MagNet aka irc.perl.org. It's a channel where people just hang out and talk about essentially anything but help requests. However, on that network, there's quite a few channels particularly about certain Perl-related projects. The people who lurk in those may well be the primary authors of the relevant piece of software. Those channel's aren't help desks either, but if you have a very challenging and interesting problem, you might be able to get them interested enough to help you. Just make sure you do your homework first and be prepared to get involved yourself.
For documentation on Perl builtins and standard modules, perldoc.perl.org is an web version of the Perl docs with pretty colors and such. I use a keyword bookmark, pd for this.
For finding modules, search.cpan.org is the place to go; for this I use the keyword pm.
When you have a question that requires humans to answer, Perl Monks is my preferred place, though Stack Overflow seems to have attracted a good crowd already.
Usenet is pretty good too
comp.lang.perl.misc, comp.lang.perl.modules and comp.lang.perl.moderated are good places to ask questions IMHO.
The Official Perl 5 Wiki is another great resource with lots of info and links.
(Also see the bottom of the wiki home page for the latest headlines from the Planet Perl feed aggregator. It's useful to look at, because it sometimes suggests questions that you didn't know that you should be asking.)
Incidentally, an ambitious stackoverflow Perl fan could also add a new section to the Perl 5 wiki pointing to questions answered on stackoverflow (and perhaps vice versa).
I favor use.perl.org over perlmonks. I'm not sure why. It's a smaller community, maybe the signal to noise ratio is higher for me.
Incidentally, I get good answers there to any question, not just Perl questions. I ask Java questions, Linux questions, sometimes even cultural questions, and there's always someone there who knows. :)
I am surprised that no one has mentioned the Perl Beginners mailing list.
I like IRC, try #perl on irc.perl.org or irc.freenode.net, or maybe #perlhelp on irc.efnet.nl. Lots and lots of very clever, helpful people always willing to discuss perl-related issues.
Maybe I'll see you there :)
I don't have a specific site, but tend to just google the main keywords of what I am looking for. There are many sites out there, however, I have got the best responses here for very specific stuff.
Have a big AIM/Jabber list filled with knowledgeable Perl people you're friends with.
I talk to my imaginary friends on #catalyst, #perl and other channels on irc.perl.org.
[edit] Bearing in mind that due to the limitations of non face to face communication with people you don't really know, you need to be simultaneously respectful of people whom it might superficially look like are being very rude to you. It pays to be thick skinned on IRC.
I would say Stackoverflow